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=
    nohook wpa_supplicant
Sudo vim /etc/sysctl.d/routed-ap.conf
Add the following

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
Sudo vim /etc/hostapd/hostapd.conf
Write the following

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

  • 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 '21 at 19:55

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, privacy policy and cookie policy

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