Sometimes you need to attach a wired-only device to a wifi network, or like happened to me recently, a client’s wifi printer was not working well with the AP, so kept losing it’s wireless connection. I found that any other device was solid on this wifi AP, so just needed to relay the dhcp issued by the main Wifi AP to the wired LAN.
These instructions are for setting this up via LuCi (the openWRT web interface), and I am using a Linux distro, if your going to use Windoz then you’ll need to search for equivaent commands from Windows terminal (cmd)
Start by identifying the SSID and WPA key for the wifi network you want to connect to, test the connection to ensure you have the correct details.
An example configuration:
- IP address obtained from attaching to the target wireless AP, I called it upink_ssid: 192.168.1.134 (use dhclient -v eth0)
- IP address of the internet uplink: 192.168.1.1 (find this with bash: route -n or cmd: route print)
- LAN IP address to be assigned to manage the openWRT: 192.168.2.1 (up to you but must be different subnet to the IP address issued by wifi AP). In future if you want to manage the openWRT you’ll need to manually set you IP to the same subnet with [ifconfig eth0 192.168.2.23 up netmask 255.255.255.0) .
Install OpenWRT on your device (see Openwrt hardware database for compatible devices)
Connect your LAN cable to that of the OpenWRT LAN port and connect to LuCi via your browser with: http://192.168.1.134/cgi-bin/luci/
There you should set a first password and configure ssh access, install your ssh key or just ssh allow password access – this device is in the same zone as your LAN printer so probably you need not be so security aware. If your managing this device remotely set up a reverse tunnel (which will make management tasks a lot easier). In that case enforce the use of ssh keys for root login.
Set up relayd
Log in to OpenWRT with: ssh email@example.com
Update: opkg update
Install relayd: opkg install luci-proto-relay
The rest can be done via LuCi, browse to: http://192.168.1.134/cgi-bin/luci
Configure Interfaces and Firewalls
In Network | Wifi see listed the default wifi AP, press Scan and join uplink_ssid (enter password on request)
Accept the default for this interface but set Firewall Zone to be lan
In Network | Interfaces | edit lan and set IP4 Gateway and DNS server address to 192.168.1.1. Disable DHCP for the Interface (ignore interface).
In Network | Firewall, edit lan zone to Accept Forwards, choose lan and wwan to be the covered networks.
Ensure you have saved and applied all the changes, then reboot the openWRT.
Your client on the wired should now obtain an IP from the wireless network. (dhclient -v eth0)