*** Forward packet from one port to another in same machine
sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination 192.168.254.47:8080
-A action
-dport dynamic port
DNAT destination NAT
*** To clean the NAT table sudo iptables -t nat -F *** To Masquerade in case you want to forward to another ip address sudo iptables -t nat -A POSTROUTING -p tcp --dport 80 -j MASQUERADE
This is used if you want to forward to different IP.
*** To make these entries persistent. Once all configuration is done. Configure below command apt-get install iptables-persistent
-A action
-dport dynamic port
DNAT destination NAT
*** To clean the NAT table sudo iptables -t nat -F *** To Masquerade in case you want to forward to another ip address sudo iptables -t nat -A POSTROUTING -p tcp --dport 80 -j MASQUERADE
This is used if you want to forward to different IP.
*** To make these entries persistent. Once all configuration is done. Configure below command apt-get install iptables-persistent
In case of persistent, entries will remain even after reboot of device.
No comments:
Post a Comment