Skip to content

Instantly share code, notes, and snippets.

@loveJesus
Created August 5, 2012 02:58
Show Gist options
  • Save loveJesus/3261293 to your computer and use it in GitHub Desktop.
Save loveJesus/3261293 to your computer and use it in GitHub Desktop.
simple same device nat and port forwarding
#Jesus Christ is the Son of God
#I am indebted to the Lord for saving my life, He is awesome. He still does miracles, restores your heart and mind, and provides day to day sanity and wellbeing, direction and Wisdom. Its wonderful, praise His awesome deed of sending His Son, who died on the cross and became a curse so we could become His righteoussness. How great, how awesome is He!
#suppose eth0 is connected to the internet through a gateway/ip, but also a local network.
#this might be the case with a bridged VirtualBox connection, or a switch connecting a router and local computers
#This supposes that the internet connection is established, and a local network on 192.168.1.0/24 and port forwarding 1194 udp connection (openvpn)
#first the nat
iptables -A FORWARD -i eth0 -d 192.168.1.0/24 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -A FORWARD -s 192.168.1.0/24 -o eth0 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
#port forwarding
iptables -t nat -A PREROUTING -p udp -i eth0 –-dport 1189 -j DNAT –-to 192.168.1.91:1194
iptables -A FORWARD -p udp -i eth0 -d 192.168.1.91 –-dport 1194 -j ACCEPT
#in the name of Jesus Christ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment