Created
October 15, 2022 17:58
-
-
Save srimaln91/5f50a340e8c18cc36924431e50cf478a to your computer and use it in GitHub Desktop.
Enable internet sharing in the local network
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 | |
# Share internet connection | |
# enxfcde56ff0106 -> interface which has an internet connection | |
# enp1s0 -> Interface which has connected to the network that we have to share the internet | |
# 192.168.100.0/24 -> local subnet | |
# Please replace the above values/interaces with the ones you have in your computer | |
sudo iptables -A FORWARD -o enxfcde56ff0106 -i enp1s0 -s 192.168.100.0/24 -m conntrack --ctstate NEW -j ACCEPT | |
sudo iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT | |
sudo iptables -t nat -F POSTROUTING | |
sudo iptables -t nat -A POSTROUTING -o enxfcde56ff0106 -j MASQUERADE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment