Hi all!
I recently got the idea to add a VPN server on my LAN, so I can connect through a tunnel from the Internet and back out again, so it looks like I'm at my home IP address.
I'm fairly experienced with networking but a complete beginner at Wireguard and OpenWRT.
Here is my current setup, where the lines are cabled Ethernet.
I set the AP up using https://openwrt.org/docs/guide-user/network/wifi/dumbap and it works fine as an AP right now.
The device is a D-Link DIR-842 that I set up using https://openwrt.org/toh/d-link/d-link_dir-842
I wonder, is it possible to also set up a WG server without also converting it to a full-blown router?
This previous topic suggests that it is possible: Setting up a separate Wireguard-Server in LAN
However I tried to follow this instruction: https://openwrt.org/docs/guide-user/services/vpn/wireguard/server but it assumes that the WG server is a router. I tried skipping irrelevant steps but still ended up unable to get a connection in wg show
.
I didn't quite understand why the instructions say to add a list of addresses to the vpn
interface. The example WG_ADDR="192.168.9.1/24"
is a lot more than one address. I set it to '192.168.1.3/32'
for now.
I don't really feel like messing with the ISP router and my existing clients, so I would prefer if DHCP, DNS and any port forwarding is handled on that device if possible but do tell me if it would be better to throw it out and just do the routing on the OpenWRT device instead.
root@OpenWrt:~# wg show
interface: vpn
public key: <my_public_key>
private key: (hidden)
listening port: 51820
peer: <test_client's_public_key>
allowed ips: 192.168.1.4/32
peer: <my_phone's_public_key>
allowed ips: 0.0.0.0/0
I figured I would test this from an internal IP address first, before I start messing with port forwarding in the ISP router, to allow external incoming connections.
Expected behavior:
- I should be able to see my test client being connected using
wg_show
, right? - Test client (an iPhone) should be able to access the Internet once connected
Observed behavior:
- iPhone's VPN settings page reports "Status: connected"
- iPhone is unable to connect to any web pages, except that of my ISP router's setup page on 192.168.1.1, and I don't even know if that is using the VPN tunnel at all.
-
wg_show
is not showing any active connection, just the above output listing the clients.
Here is my /etc/config/network file. What else do you need?
root@OpenWrt:~# cat /etc/config/network
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fdf9:e118:bf5d::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0.1 eth0.2 eth0'
option proto 'static'
option ipaddr '192.168.1.2'
option netmask '255.255.255.0'
option dns '192.168.1.1'
option gateway '192.168.1.1'
option broadcast '192.168.1.255'
option ipv6 '0'
config device 'lan_eth0_1_dev'
option name 'eth0.1'
option macaddr '18:0f:76:39:70:c0'
config device 'wan_eth0_2_dev'
option name 'eth0.2'
option macaddr '18:0f:76:39:70:c2'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '1 2 3 4 0t'
config switch_vlan
option device 'switch0'
option vlan '2'
option ports '5 0t'
config interface 'vpn'
option proto 'wireguard'
option listen_port '51820'
option private_key '<hidden, of course>'
list addresses '192.168.1.3/32'
config wireguard_vpn 'wgclient'
description 'my test client on local network'
option public_key '<test_client's_public_key>'
list allowed_ips '192.168.1.4/32'
config wireguard_vpn 'wgclient2'
description 'external user'
option public_key '<my_phone's_public_key>'
list allowed_ips '0.0.0.0/0'