Last active
August 12, 2017 12:06
-
-
Save WendySanarwanto/46d1ec64e3bad8407de162855fd82e83 to your computer and use it in GitHub Desktop.
NAT-ing Wired Local Area Network's Computers to Linux(Ubuntu) Router that is connected to WAN (Internet), so that the Router can share the internet access to Computers connected to the Wired LAN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Given, `enp6s0` is the Router's LAN interface connected to Wired LAN. | |
# And `enxfcde56ff0106` is the Router's interface connected to WAN or internet devices (e.g. Phone in Tethering mode, Wireless/USB dongle modem) | |
# Reference: http://www.nairabytes.net/81-linux/418-how-to-set-up-a-nat-router-on-ubuntu-server-16-04 | |
# Enable NAT on interface enxfcde56ff0106, use enxfcde56ff0106 for outgoing packets | |
iptables -t nat -A POSTROUTING -o enxfcde56ff0106 -j MASQUERADE | |
# Forward IP-packets from enxfcde56ff0106 to enp6s0 where there is an established initial request; | |
iptables -A FORWARD -i enxfcde56ff0106 -o enp6s0 -m state --state RELATED,ESTABLISHED -j ACCEPT | |
# Forward packages from enp6s0 to enxfcde56ff0106 | |
iptables -A FORWARD -i enp6s0 -o enxfcde56ff0106 -j ACCEPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment