Search This Blog

Monday, June 16, 2014

Ubuntu - setup port forwarding

To enable port forwarding on Ubuntu:

nano /etc/sysctl.conf


Restart the system and check whether ip forwarding is enabled:
cat /proc/sys/net/ipv4/ip_forward   - NETWORK you're forwarding the traffic TO - NETWORK you're forwarding the traffic FROM
IP - just your ip address in network taken from eth0 interface

IP="$(ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}')"
iptables -t nat -A POSTROUTING -s -d -j SNAT --to-source $IP
iptables -t nat -A POSTROUTING -s -d -j SNAT --to-source

#forward :5556 ( network) -> :22 ( network)
iptables -t nat -A PREROUTING -p tcp --dport 5556 -j DNAT --to
iptables -A FORWARD -p tcp -d --dport 5556 -j ACCEPT

No comments:

Post a Comment

If you like this post, please leave a comment :)