1

Thanks for the help with this. My colleague and I are trying to setup a RPI 4 as a router not connected to the internet. It is just for the purposes of connecting multiple wifi controllers together. The controllers are wifi but the main computer we want to control them with would be plugged into the ethernet port. The problem is all the examples online NAT and we can't figure out how to make the ethernet port just another DHCP addressable interface to the router.

To date the closest recipe we have used is below. It makes routing over the wifi great but we can't talk to anything through the ethernet port.

sudo systemctl unmask hostapd.service
Sudo systemctl enable hostapd.service
Sudo vim /etc/dhcpcd.conf
Go to the bottom and add the following
Interface wlan0
    static ip_address=10.20.1.1/24
    nohook wpa_supplicant
Sudo vim /etc/sysctl.d/routed-ap.conf
Add the following
net.ipv4.ip_forward=1

Then run sysctl -p

Sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Sudo rm /etc/dnsmasq.conf
Sudo vim /etc/dnsmasq.conf
Add the following
interface=wlan0
interface=eth0
dhcp-range=10.20.1.100,10.20.1.200,255.255.255.0,365d
domain=wlan
address=/rt.wlan/10.20.1.1
Sudo vim /etc/hostapd/hostapd.conf
Write the following
country_code=US
interface=wlan0
ssid=switchblade_SN#
hw_mode=g
channel=7
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=switchblade123
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

Needless to say this isn't the only way we have tried. Mostly we have monkeyed with the iptables and the dnsmasq.conf. Pretty much we are just trying to find a way to do LAN/Wifi without internet access. Any help would be appreciated.

Per request this is what we are trying to do: enter image description here

1
  • It's not very clear what you are trying to do. You don't need NAT for local networks, just set each interface to DHCP, enable ip forwarding and then configure the routes on the DHCP server. Perhaps a picture or diagram of what you are trying to do would help. is this what you want WirelesClients -> Wifirouter -Picable>Pi > Piwireless -> Wifirouter2 <- wificlients2. Nov 16, 2021 at 19:55

1 Answer 1

0

It seems you want to run a DHCP server on your Pi and give IP addresses to your other devices connecting to your Pi's wlan0 and eth0. You don't need NAT since the Pi will act like a switch.

The most simple solution is to run another instance of your DHCP server (in your case, dnsmasq) on your eth0, since it seems you already have one running on your wlan0.

Your devices will belong to two different subnets. In order to allow devices in these subnets to talk to each other, you can add iptables rules to allow packet forwarding between wlan0 and eth0 interfaces.

If you want your devices to be in the same subnet (for example, you want to use broadcast packets), then you can:

  • create a bridge br0
  • add eth0 to br0 as slave interfaces
  • add bridge=br0 in your hostapd.conf
  • run your dhcp server on the bridge

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.