diff options
author | neodarz <neodarz@neodarz.net> | 2017-08-24 17:24:59 +0200 |
---|---|---|
committer | neodarz <neodarz@neodarz.net> | 2017-08-24 17:24:59 +0200 |
commit | 526ea453b3f1dd86ab3bff90f1fa09dce0d337e5 (patch) | |
tree | 736df309ecd92e3672ca1ae0ee4d27b9ee1735e1 | |
parent | 0d28f0d5775a3d1b0ed00016b4d7c75e1fe29b10 (diff) | |
download | dotfiles_ascii-526ea453b3f1dd86ab3bff90f1fa09dce0d337e5.tar.xz dotfiles_ascii-526ea453b3f1dd86ab3bff90f1fa09dce0d337e5.zip |
Add service from wifi to internet
Diffstat (limited to '')
-rwxr-xr-x | scripts/.scripts/internet-from_wifi_to_internet.sh | 21 | ||||
-rw-r--r-- | services-root/internet-from_wifi_to_internet.service | 13 |
2 files changed, 34 insertions, 0 deletions
diff --git a/scripts/.scripts/internet-from_wifi_to_internet.sh b/scripts/.scripts/internet-from_wifi_to_internet.sh new file mode 100755 index 0000000..83d9b2b --- /dev/null +++ b/scripts/.scripts/internet-from_wifi_to_internet.sh @@ -0,0 +1,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 diff --git a/services-root/internet-from_wifi_to_internet.service b/services-root/internet-from_wifi_to_internet.service new file mode 100644 index 0000000..4c68ed4 --- /dev/null +++ b/services-root/internet-from_wifi_to_internet.service @@ -0,0 +1,13 @@ +[Unit] +Description=Internet forwading +After=network-pre.target +Before=network.target netctl.service +Wants=network.target + +[Service] +RemainAfterExit=yes +ExecStart=/home/neodarz/internet.sh start +ExecStop=/home/neodarz/internet.sh stop + +[Install] +WantedBy=multi-user.target |