I have following problem: I have three machines with external IP - A, B and C. On machine B i need to forward incoming connection on port 5600 to machine C on port 5601. I have googled a lot with no success. My iptables script looks as follows:
#!/bin/sh
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
modprobe ip_conntrack
modprobe ip_conntrack_ftp
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT
iptables -A INPUT -i eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -i eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -A INPUT -p tcp --destination-port 5600 -j ACCEPT
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp --dport 5600 -j DNAT --to-destination C.C.C.C:5601
iptables -A FORWARD -d C.C.C.C -p tcp --dport 5600 -j ACCEPT
It seems to that incoming connection is passed inside machine B but there is no forward to machine C.
Does anybody have any idea? Thank very much in advance!!!
P.S. I need this to get software license from C on machine A but through B (so C thinks that license is given to B).
Are you also telling your kernel it’s okay to route packets like this:
echo 1 > /proc/sys/net/ipv4/ip_forward
Good luck.
kondora wrote:
> Hello,
>
> I have following problem: I have three machines with external IP - A, B
> and C. On machine B i need to forward incoming connection on port 5600
> to machine C on port 5601. I have googled a lot with no success. My
> iptables script looks as follows:
>
>
> PHP code:
> --------------------
>
> #!/bin/sh
> iptables -F
> iptables -X
> iptables -t nat -F
> iptables -t nat -X
> iptables -t mangle -F
> iptables -t mangle -X
> modprobe ip_conntrack
> modprobe ip_conntrack_ftp
>
> iptables -P INPUT DROP
> iptables -P OUTPUT ACCEPT
> iptables -P FORWARD ACCEPT
>
> iptables -A INPUT -i lo -j ACCEPT
> iptables -A OUTPUT -o lo -j ACCEPT
>
> iptables -A INPUT -i eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
> iptables -A FORWARD -i eth0 -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT
>
> iptables -A INPUT -p tcp --destination-port 5600 -j ACCEPT
> iptables -A INPUT -p tcp --dport 22 -j ACCEPT
>
> iptables -t nat -A PREROUTING -p tcp --dport 5600 -j DNAT --to-destination C.C.C.C:5601
> iptables -A FORWARD -d C.C.C.C -p tcp --dport 5600 -j ACCEPT
>
> --------------------
>
>
> It seems to that incoming connection is passed inside machine B but
> there is no forward to machine C.
>
> Does anybody have any idea? Thank very much in advance!!!
>
> P.S. I need this to get software license from C on machine A but
> through B (so C thinks that license is given to B).
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org