Hi.
I have the following solution where one wireless interface is on the host and the other is in the network namespace.
root@OpenWrt:~# ip link
6: wg: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/none
43: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1280 qdisc noqueue state UP mode DEFAULT group default qlen 1000
link/ether 7e:ea:9e:65:22:46 brd ff:ff:ff:ff:ff:ff
root@OpenWrt:~# ip -netns vpn link
3: wlan1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
link/ether cd:fa:df:33:eb:48 brd ff:ff:ff:ff:ff:ff permaddr fb:ab:6b:f8:0b:3a
wlan0
is used as the access point
and wlan1
is used as the station
.
The wg
interface is a Wireguard VPN that is linked to the network namespace.
But it does not work out-of-the-box and requires some customization (e.g. installing the ip-tiny
package, disabling some services and executing additional commands).
For example, WiFi and wpad
must be disabled (otherwise it won't work properly).
root@OpenWrt:~# wifi down
root@OpenWrt:~# service wpad stop
Then create a network namespace.
root@OpenWrt:~# ip netns add vpn
Create wireguard and configure it.
root@OpenWrt:~# ip -netns vpn link add wg type wireguard
root@OpenWrt:~# ip -netns vpn link set wg netns 1
root@OpenWrt:~# wg setconf wg /etc/wg.conf
root@OpenWrt:~# ip -4 address add .../32 dev wg
root@OpenWrt:~# ip -6 address add .../128 dev wg
root@OpenWrt:~# ip link set wg up
Configure the `station' using one of the wireless interfaces.
root@OpenWrt:~# iw phy phy1 set netns name vpn
root@OpenWrt:~# ip netns exec vpn iw phy phy1 interface add wlan1 type managed
root@OpenWrt:~# ip netns exec vpn wpa_supplicant -i wlan1 -c /etc/wpa_supplicant.conf -B
root@OpenWrt:~# ip netns exec vpn udhcpc -i wlan1 -b
Now configure the `access point' using the second wireless interface.
root@OpenWrt:~# iw phy phy0 interface add wlan0 type managed
root@OpenWrt:~# hostapd -i wlan0 /etc/hostapd.conf
Be aware that this is not a step-by-step instruction. It lacks some steps.
When all these steps are completed, clients can connect to the access point
placed on interface wlan0
, and the router itself is connected to the public network using a station
on interface wlan1
, with all traffic encrypted by Wireguard.
But that means that there is no longer a way to configure WiFi with /etc/config/wireless
.
And a bunch of commands have to be run to configure all that.
There is no WAN / LAN configuration yet, but it will be implemented the same way, and /etc/config/network
will probably be useless for WAN as well.
So my question is what is the proper way to implement this in OpenWrt using standard utilities / scripts / configurations?
Or there is no easy way to do it and I need to write my own scripts handling all settings using ip
/ iw
utilities and configurations such as hostapd.conf
and dnsmasq.conf
?
Thanks.