I'm faced with the problem of needing to punch a hole in
a firewall on our portal server so that, in our case,
ssh to port 20022 on external interface of that server
actually just connects to port 22 on another machine
located in the network on the internal interface. I hope
I'm being clear.
I've tried many iterations of iptables rules to accomplish
this. The closest I've come is:
iptables -A PREROUTING -t nat -p tcp -s 0/0 --dport 20022
-j DNAT --to
192.168.0.35:22
And indeed connecting to port 20022 on portal just goes
straight to port 22 on the other (192.168.0.35) machine. The
problem is, as soon as I apply this rule, DNS queries
(portal is also a DNS server) to the external interface stop
working.
I've googled endlessly and found about a thousand variations
by people that are each supposed to solve a subtly different
variation on what I'm trying to do. Nothing I've tried does
what I want without bad side effects like I describe above.