Skip to content

Instantly share code, notes, and snippets.

@srimaln91
Created October 15, 2022 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srimaln91/5f50a340e8c18cc36924431e50cf478a to your computer and use it in GitHub Desktop.
Save srimaln91/5f50a340e8c18cc36924431e50cf478a to your computer and use it in GitHub Desktop.
Enable internet sharing in the local network
# ! /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