port forwarding on linux

[japanese(日本語)]

this is a sample of  port forwarding on linux.

 

1.add forwarding settings.

# sysctl -w net.ipv4.ip_forward=1
# echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf

2.add forwarding parameter.

#iptables -t nat -A PREROUTING -m tcp -p tcp --dst WAITING_ADDR --dport WAITING_PORT -j DNAT --to-destination DET_ADDR:DEST_PORT
#iptables -t nat -A POSTROUTING -m tcp -p tcp --dst DEST_ADDR --dport DEST_PORT -j SNAT --to-source WAITING_ADDR