Journey of Life
October 6, 2015
Forward traffic from one IP address to another
The first thing to do is do enable
IP forwarding
. This is done either by using:
echo "1" > /proc/sys/net/ipv4/ip_forward
or
sysctl net.ipv4.ip_forward=1
Then, we will add a rule telling to forward the traffic on port 1111 to ip 2.2.2.2 on port 1111:
iptables -t nat -A PREROUTING -p tcp --dport 1111 -j DNAT --to-destination 2.2.2.2:1111
and finally, we ask Iptables to masquerade:
iptables -t nat -A POSTROUTING -j MASQUERADE
No comments:
Post a Comment
‹
›
Home
View web version
No comments:
Post a Comment