Pascal Hambourg wrote:
>>
>> We are migrating a service and during migration I need a temporary
>> portforward from one machine to another. Both machines are standalone in
>> the internet without additional firewalls and I started with testing by
>> forwarding port 3222 on sourcemachine to port 22 on targetmachine.
>>
>
> You may like to set the default policy for the nat chains too.
>
<skip>
>
>> echo processing PREROUTING -t nat
>> /usr/local/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d
>> SOURCE_IP --dport 3222 -j DNAT --to DESTINATION_IP:22
>
> What about the return path from the server to the client ? It must go
> through the forwarding box in order for the NAT to work properly.
>
Thnx for your assistance.
I set the default-police for both nat-chains too, but no success. But
what do you mean with "return-path" ? I think (which may by complete
nonsense) that the DNAT-target takes care of both ways. All examples and
manuals I found state this single rule as the key-rule for port-forward.
How could I set up the return-path?
I tried
/usr/local/sbin/iptables -t nat -A POSTROUTING -p tcp -o eth0 -s
DESTINATION --sport 22 -j SNAT --to-source SOURCE
but thats just hitting in the air cause I dont really know what it does.
I found it in some howto as part of 1:1-NAT.
>
>> but things dont work as I remembered them to work. Any help?
>
> What do you mean ? Have you done any trace to check what's going on ?
I remember doing lot of port-forwarding many years ago but the details
slipped my mind.
I dont know how to trace/debug this stuff. I tried
tcpdump -i any port 3222
to get any closer to my problem but it seems tcpdump is not the tool of
choice here. I connect from my dynamic client to the first machine which
should forward to the second, but I only see the packages going there
and from tcpdump I would say they are just nuked by my first server
instead of being forwarded
08:44:21.177600 IP xxxxxxxxx.dynamic.xdsl-line.inode.at.17041 >
server1.at.3222: Flags [S], seq 522435283, win 5840, options [mss
1452,sackOK,TS[|tcp]>
08:44:24.187372 IP xxxxxxxxx.dynamic.xdsl-line.inode.at.17041 >
server1.at.3222: Flags [S], seq 522435283, win 5840, options [mss
1452,sackOK,TS[|tcp]>
08:44:30.231874 IP xxxxxxxxx.dynamic.xdsl-line.inode.at.17041 >
server1.at.3222: Flags [S], seq 522435283, win 5840, options [mss
1452,sackOK,TS[|tcp]>
I also included loads of LOG-rules to my setup and watched syslog for
any logs on port 3222, but it didnt reveal more then my tcpdump-output
Apr 26 09:05:25 goldfisch kernel: IN=eth0 OUT=
MAC=00:0e:2e:6c:da:77:00:02:4a:73:70:00:08:00 SRC=xxxx.dynamic.client
DST=server1.at LEN=60 TOS=0x00 PREC=0x00 TTL=58 ID=64205 DF PROTO=TCP
SPT=18674 DPT=3222 WINDOW=5840 RES=0x00 SYN URGP=0
So I'm still out of luck
my iptables-framework has extended in the meantime to the following
echo 1 > /proc/sys/net/ipv4/ip_forward
echo processing flush
/usr/local/sbin/iptables -F FORWARD
/usr/local/sbin/iptables -F INPUT
/usr/local/sbin/iptables -F OUTPUT
echo processing flush -t nat
/usr/local/sbin/iptables -t nat -F POSTROUTING
/usr/local/sbin/iptables -t nat -F PREROUTING
echo processing policy/ACCEPT
/usr/local/sbin/iptables -P FORWARD ACCEPT
/usr/local/sbin/iptables -P INPUT ACCEPT
/usr/local/sbin/iptables -P OUTPUT ACCEPT
echo processing policy -t nat/ACCEPT
/usr/local/sbin/iptables -t nat -P POSTROUTING ACCEPT
/usr/local/sbin/iptables -t nat -P PREROUTING ACCEPT
echo processing PREROUTING -t nat
/usr/local/sbin/iptables -t nat -A PREROUTING -j LOG
/usr/local/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 -d SOURCE
--dport 3222 -j DNAT --to DESTINATION:22
echo processing POSTROUTING -t nat
/usr/local/sbin/iptables -t nat -A POSTROUTING -j LOG
/usr/local/sbin/iptables -t nat -A POSTROUTING -p tcp -o eth0 -s
DESTINATION --sport 22 -j SNAT --to-source SOURCE
echo processing FORWARD
/usr/local/sbin/iptables -A FORWARD -j LOG
/usr/local/sbin/iptables -A FORWARD -p tcp -i eth0 -d DESTINATION
--dport 22 -j ACCEPT
/usr/local/sbin/iptables -A FORWARD -p tcp -o eth0 -s DESTINATION
--sport 22 -j ACCEPT
any help appreatiated !!
thnx
peter
|