aboutsummaryrefslogtreecommitdiff
path: root/scripts/.scripts/internet-from_wifi_to_internet.sh
blob: 83d9b2b7894247e4f94dc05e8fbcd53e97fca3bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
#sudo ip addr add 192.168.123.102/24 dev enp3s0
#sudo ip route add default via 192.168.123.100 dev enp3s0

if [[ $1 == "start" ]]; then
	/usr/lib/netctl/network start wlp2s0-Livebox-C1D0
	ip addr add 192.168.123.100/24 dev enp3s0
	sysctl net.ipv4.ip_forward=1
	iptables -t nat -A POSTROUTING -o wlp2s0 -j MASQUERADE
	iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
	iptables -A FORWARD -i enp3s0 -o wlp3s0 -j ACCEPT
elif [[ $1 == "stop" ]]; then
	/usr/lib/netctl/network stop wlp2s0-Livebox-C1D0
	iptables -t nat -D POSTROUTING -o wlp2s0 -j MASQUERADE
	iptables -D FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
	iptables -D FORWARD -i enp3s0 -o wlp3s0 -j ACCEPT
	ip addr del 192.168.123.100/24 dev enp3s0
	sysctl net.ipv4.ip_forward=0
else
	echo "error"
fi