Wifi Client as Gateway instead of WAN

I have an openWRT device with a WLAN and no WAN interface. However, one of the 4 clients clients of the WLAN is connected to the internet via it's own eth0 interface. I would like to set up openWRT to use the WLAN client as the gateway.

On the internet connected client(running ubuntu), I added simple masquerading with iptables rules as documented all over the internet, to forward all incoming wlan0 traffic out towards its own default gateway on eth0.

On OpenWRT, I configured the internet-connected WLAN client to a static DHCP lease (via a host entry in /etc/config/dhcp, then tried to set the client's IP as default gateway using `ip r add default via $CLIENT_IP' , but this doesn't work, probably because of iptables rules.

What do I need to do to configure the routing and iptables to make OpenWRT redirect all traffic to the correct place? What am I doing wrong?

Confession: I have also asked the same question on the stackoverflow network, just with more background information which might or might not be relevant.

  • These settings must be done on the "client" (desired router)...namely setting up enabling routing (i.e. IPv4 forwarding) and or masquerade (i.e. NAT)
  • The default route should be added automatically if you set the gateway properly

This is not conventional but it does work. I have used it before to put an old router with stock firmware that only supports AP mode into service as a wireless repeater / guest access point.

The upstream client of course needs to be configured to route out to the Internet. That the OP has presumably already done.

If running OpenWrt on the downstream AP, start at a default configuration, enable a wifi AP on the lan bridge and add the upstream gateway as option gateway and option dns in the /etc/config/network lan section. This will place the default route in the routing table and also configure the DNS server to recurse out to the upstream router. If that device does not serve DNS, you would point OpenWrt at the ISP or a third party DNS server instead.

There is no need to alter the firewall since everything is in the one LAN zone which is already considered fully trusted.

Higher performance could potentially be achieved by setting DHCP options to inform the other clients to use the upstream gateway directly rather than having the AP as their gateway.

This would be strictly necessary if the AP is not running OpenWrt. Stock firmware assumes it is going to route to the WAN port, so you need to use the AP entirely as a bridge. There the network's DHCP server would be on the upstream client.

This works as you said. I added the gateway and DNS configuration to point to the WLAN client's IP (the client has a DNS resolver on it) and everything started to work as expected.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.