-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclusterhost_network_setup.sh
More file actions
52 lines (41 loc) · 1.36 KB
/
clusterhost_network_setup.sh
File metadata and controls
52 lines (41 loc) · 1.36 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
#!/bin/bash
# ------------------------------------------------------------------
# Separate Subnet
# https://willhaley.com/blog/raspberry-pi-wifi-ethernet-bridge/
# Step 1: Add network conf - sudo nano bridge.sh
# copy this script to the file
# Step 2: Execute the script on your Pi like so.
# sudo bash bridge.sh
# Step 3: Reboot.
# sudo reboot
# ------------------------------------------------------------------
set -e
[ $EUID -ne 0 ] && echo "run as root" >&2 && exit 1
apt update && \
DEBIAN_FRONTEND=noninteractive apt install -y \
dnsmasq netfilter-persistent iptables-persistent
# Create and persist iptables rule.
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
netfilter-persistent save
# Enable ipv4 forwarding.
sed -i'' s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/ /etc/sysctl.conf
# The Ethernet adapter will use a static IP of 10.1.1.1 on this new subnet.
cat <<'EOF' >/etc/network/interfaces.d/eth0
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 10.1.2.1
netmask 255.255.255.0
gateway 10.1.2.1
EOF
# Create a dnsmasq DHCP config at /etc/dnsmasq.d/bridge.conf. The Raspberry Pi
# will act as a DHCP server to the client connected over ethernet.
cat <<'EOF' >/etc/dnsmasq.d/bridge.conf
interface=eth0
bind-interfaces
server=8.8.8.8
domain-needed
bogus-priv
dhcp-range=10.1.2.2,10.1.2.254,12h
EOF
systemctl mask networking.service