Wifi connection for faster transfers? I hate iptables and they hate me...

조회수 72회
읽지 않은 첫 메시지로 건너뛰기

Perry das Schnabeltier

읽지 않음,
2022. 7. 20. 오전 4:39:3922. 7. 20.
받는사람 ClusterHAT
I´ve set up 1x 4b with 4x zero 2w´s with the 2022-04-04-2-bullseye-ClusterCTRL-arm64-lite-CNAT.zip image and the corresponding client images. And since the usb-connection isn´t that fast, i´ve decided to try to split the network traffic over wifi. So far what i´ve done/achieved:

For the controler i´ve done:

#i´ve scp´ed my ssh key to /root/.shh/isd_ra

sudo apt install dnsmasq hostapd iptables pssh

#configuring dhcpcd
sudo nano /etc/dhcpcd.conf
>interface wlan0 
>static ip_address=192.168.179.1/24 
>nohook wpa_supplicant
sudo systemctl restart dhcpcd

#configuring dnsmasq
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf_backup
sudo nano /etc/dnsmasq.conf
>interface=wlan0
>no-dhcp-interface=eth0
>dhcp-range=192.168.179.10,192.168.179.50,255.255.255.0,24h
>dhcp-option=option:dns-server,192.168.179.1
sudo systemctl restart dnsmasq
sudo systemctl enable dnsmasq

#configuring hostapd
sudo nano /etc/hostapd/hostapd.conf
>interface=wlan0
>ssid=<ssid>
>router channel=1 
>hw_mode=g 
>ieee80211n=1 
>ieee80211d=1 
>country_code=<wifi-country-code>
>wmm_enabled=1
>auth_algs=1 
>wpa=2 
>wpa_key_mgmt=WPA-PSK 
>rsn_pairwise=CCMP 
>wpa_passphrase=<wifi-key>
>ignore_broadcast_ssid=1
sudo nano /etc/default/hostapd
>RUN_DAEMON=yes 
>DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo systemctl unmask hostapd 
sudo systemctl start hostapd 
sudo systemctl enable hostapd

#configuring pssh
sudo nano /etc/root/.config/pssh-hosts
>p1
>p2
>p3
>p4
sudo nano /root/.bash_aliases
>alias pssh='parallel-ssh -i -h ~/.config/pssh-hosts -t 0' $1
sudo nano /root/.bashrc
>if [ -f ~/.bash_aliases ]; then
>. ~/.bash_aliases
>fi
sudo nano /etc/hosts
>172.19.181.1 p1
>172.19.181.2 p2
>172.19.181.3 p3
>172.19.181.4 p4

#configuring iptables for nating the wlan0
iptables -t nat -A POSTROUTING -s 192.168.179.0/24 ! -o br0 -j MASQUERADE


For the client´s i´ve just customized the image with the rpi-imager tool...
hostname: p1-4
ssh: activate with public key 
add user: <user> + <password>
wifi: <ssid> + hidden ssid + <wifi-key> + <country>
timezone: <timezone>

After flashing the images to micro-sd cards and inserting them, powereing the clients with "sudo clusterctrl on" and waiting for the clients to resize the file-system and boot up

root@cluster:~# pssh uptime
[1] 10:09:11 [SUCCESS] p4
 10:09:11 up 6 min,  0 users,  load average: 0.00, 0.07, 0.04
[2] 10:09:11 [SUCCESS] p1
 10:09:11 up 6 min,  0 users,  load average: 0.00, 0.05, 0.03
[3] 10:09:11 [SUCCESS] p2
 10:09:11 up 6 min,  0 users,  load average: 0.00, 0.08, 0.06
[4] 10:09:11 [SUCCESS] p3
 10:09:11 up 6 min,  0 users,  load average: 0.08, 0.07, 0.04


So far so good, the clients are running, getting an usb-ip and an wifi ip and access the internet via nat-ing on the controler... Now my question: to make the 4x zero 2w´s use the wifi gateway to communicate with everything except the usb-subnet (172.19.181.0/24) i just have to delete the usb0 gateway from the clients?

root@p1:~# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.19.181.254  0.0.0.0         UG    203    0        0 usb0
0.0.0.0         192.168.179.1   0.0.0.0         UG    302    0        0 wlan0
172.19.181.0    0.0.0.0         255.255.255.0   U     203    0        0 usb0
192.168.179.0   0.0.0.0         255.255.255.0   U     302    0        0 wlan0

Chris Burton

읽지 않음,
2022. 7. 20. 오후 1:56:5222. 7. 20.
받는사람 ClusterHAT
Hi, 
So far so good, the clients are running, getting an usb-ip and an wifi ip and access the internet via nat-ing on the controler... Now my question: to make the 4x zero 2w´s use the wifi gateway to communicate with everything except the usb-subnet (172.19.181.0/24) i just have to delete the usb0 gateway from the clients?

On each Pi Zero you can alter the metric so it prefers the default route on wlan0 by adding this to "/etc/dhcpcd.conf" and restart them.

interface wlan0
metric 100

It will then use the usb0 to communicate with the other devices in 172.19.181.0/24 range and go out over WiFi for everything else - and if WiFi is down it will try to go over usb0 and NAT out over the Ethernet.

Chris.
 
전체답장
작성자에게 답글
전달
새 메시지 0개