-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnuc-setup-wifi-forwarding
More file actions
executable file
·58 lines (50 loc) · 1.54 KB
/
nuc-setup-wifi-forwarding
File metadata and controls
executable file
·58 lines (50 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
ETH=$(ls /sys/class/net | grep e | head -n 1)
WIFI=$(ls /sys/class/net | grep w | head -n 1)
echo "Using ethernet interface '$ETH' and wifi interface '$WIFI'"
echo "Installing dhcpd server and iptables config reader"
sudo apt-get install isc-dhcp-server iptables-persistent
echo "Writing /etc/dhcp/dhcpd.conf"
cat <<EOF | sudo tee /etc/dhcp/dhcpd.conf > /dev/null
# ACTor dhcp server /etc/dhcp/dhcpd.conf
ddns-update-style none;
default-lease-time 600;
max-lease-time 7200;
subnet 192.168.0.0 netmask 255.255.0.0 {
range 192.168.0.61 192.168.0.199;
option routers 192.168.0.60;
option domain-name-servers 1.1.1.1;
}
EOF
echo "Writing /etc/netplan/99-actor-static-ip.yaml"
cat <<EOF | sudo tee /etc/netplan/99-actor-static-ip.yaml > /dev/null
# ACTor static ip config
network:
version: 2
renderer: NetworkManager
ethernets:
$ETH:
addresses:
- 192.168.0.60/16
nameservers:
addresses: [1.1.1.1, 8.8.8.8, 4.4.4.4]
EOF
echo "Writing /etc/sysctl.d/99-ipv4-forward.conf"
cat <<EOF | sudo tee /etc/sysctl.d/99-ipv4-forward.conf > /dev/null
net.ipv4.ip_forward = 1
EOF
echo "Writing /etc/iptables/rules.v4"
cat <<EOF | sudo tee /etc/iptables/rules.v4 > /dev/null
*filter
:INPUT ACCEPT [2117:251017]
:FORWARD ACCEPT [3325:4355368]
:OUTPUT ACCEPT [1972:240413]
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o $WIFI -j MASQUERADE
COMMIT
EOF
echo "REBOOT BEFORE WIFI FORWARDING AND DHCP WILL WORK CORRECTLY. YOU WILL NEED TO RECONNECT TO THE WIFI AFTER LOGGING IN!"