Skip to content

Instantly share code, notes, and snippets.

@nv1t
Created November 14, 2019 22:28
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 nv1t/eca121dae32e1d7861ca142852bba4ef to your computer and use it in GitHub Desktop.
Save nv1t/eca121dae32e1d7861ca142852bba4ef to your computer and use it in GitHub Desktop.
Shares internet from wlp3s0 through enp0s25
#!/bin/bash
# Shares internet from wlp3s0 through enp0s25
case "$1" in
start)
ifconfig enp0s25 up
ifconfig enp0s25 192.168.0.1
iptables --table nat --append POSTROUTING --out-interface wlp3s0 -j MASQUERADE
iptables --append FORWARD --in-interface enp0s25 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "set other computers in the range of"
echo "192.168.0.0 255.255.255.0"
echo "gateway 192.168.0.1"
echo "dns 192.168.10.1" #this is my router's ip, you should use yours or another dns server
;;
stop)
echo 0 > /proc/sys/net/ipv4/ip_forward
ifconfig enp0s25 down
iptables --table nat --delete POSTROUTING --out-interface wlp3s0 -j MASQUERADE
;;
*)
echo "usage: $0 {start|stop}"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment