Skip to content

Instantly share code, notes, and snippets.

@dzervas
Created April 28, 2021 18:41
Show Gist options
  • Save dzervas/cb6b7b5f528fc43d095cb20fff913aaf to your computer and use it in GitHub Desktop.
Save dzervas/cb6b7b5f528fc43d095cb20fff913aaf to your computer and use it in GitHub Desktop.
Internet sharing script
#!/bin/sh
# ./ishare.sh <internet_iface> <target_iface>
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o "${1}" -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i "${2}" -o "${1}" -j ACCEPT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment