Hello everyone,
I'm having trouble with wireguard configuration and I haven't been able to sort it out in the last months, so here I am to look for help.
I have three android phones that I want to peer with the openwrt router via wireguard; I also want to route all traffic from mobiles through the openwrt router and to access the other subnets in my home network.
The problem I have is that whenever I add a mobile phone as a peer, the phones added previously are no longer able to connect neither to the internet nor to the peer router, while only the last configured phone is able to.
I think I have quite a complex setup, with various subnets, vlan and other vpn tunnels as well, but I don't think that is the issue: even if I stop all the other vpn-like interfaces, the wireguard vpn works only with the mobile phone I configured last (no matter also if the other mobiles are trying to join or not).
The whole home network and the openwrt router are behind a modem-router from my carrier provider, which has a public ip address and it is port-forwarding wireguerd traffic to the openwrt router on a dedicated 2-hosts-only private subnet; similarly, the openwrt router masquerades all the other private subnets (including the vpn, I guess) when sending data to the carrier modem.
INTERNET <---> Modem <---> OpenWrtRouter <---> local subnets, wifi, etc.
I suppose there is some routing trap somewhere but I can't find it. Also, this setup works fine when I use OpenVPN ('tun0' in my config file) instead of Wireguard ('vpn' in my config file), but I wanted to try wireguard because I had some difficulties in pushing my DNS through OpenVPN and because I thought that the OpenVPN app was draining to much of battery from my mobile phones...
Here is my config/network file (manually edited just to hide personal data):
config interface 'loopback'
option device 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix '...'
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
list ports 'lan4'
config interface 'wan'
option device 'wan'
option proto 'static'
option ipaddr '192.168.1.249'
option netmask '255.255.255.0'
option gateway '192.168.1.254'
option metric '10'
config interface 'wan6'
option device 'wan'
option proto 'dhcpv6'
option auto '0'
option reqaddress 'try'
option reqprefix 'auto'
config bridge-vlan
option device 'br-lan'
option vlan '1'
config bridge-vlan
option device 'br-lan'
option vlan '100'
list ports 'lan1:u*'
list ports 'lan4:u*'
config bridge-vlan
option device 'br-lan'
option vlan '101'
list ports 'lan1:t'
list ports 'lan2:u*'
config bridge-vlan
option device 'br-lan'
option vlan '102'
list ports 'lan1:t'
list ports 'lan3:u*'
config bridge-vlan
option device 'br-lan'
option vlan '103'
list ports 'lan1:t'
config bridge-vlan
option device 'br-lan'
option vlan '104'
list ports 'lan1:t'
config bridge-vlan
option device 'br-lan'
option vlan '105'
list ports 'lan1:t'
config interface 'lan0'
option proto 'static'
option device 'br-lan.100'
option ipaddr '10.0.0.1'
option netmask '255.255.255.0'
config interface 'lan1'
option device 'br-lan.101'
option proto 'static'
option ipaddr '10.1.1.1'
option netmask '255.255.255.0'
option ip6assign '60'
list dns '1.1.1.1'
config interface 'lan2'
option proto 'static'
option device 'br-lan.102'
option ipaddr '10.2.2.1'
option netmask '255.255.255.0'
list dns '1.1.1.1'
config interface 'lan3'
option proto 'static'
option device 'br-lan.103'
option ipaddr '10.3.3.1'
option netmask '255.255.255.0'
config interface 'vec' # This is another vpn I use as a peer, but even if I shut it down I can't make my vpn work as desired
option proto 'wireguard'
option private_key '...'
list addresses '192.168.0.202/24'
list dns '9.9.9.9'
list dns '192.168.0.1'
option disabled '0'
option metric '20'
config wireguard_vec
option description 'Imported peer configuration'
option public_key '...'
option preshared_key '...'
list allowed_ips '192.168.0.0/24'
list allowed_ips '0.0.0.0/0'
option route_allowed_ips '1'
option persistent_keepalive '25'
option endpoint_host '...'
option endpoint_port '...'
config rule
option out 'wan'
option src '10.10.10.0/24'
option disabled '1'
option mark '0x10'
config rule
option src '192.168.1.249/32'
option out 'wan'
option mark '0x10'
option disabled '1'
config device
option name 'br-lan.100'
option type '8021q'
option ifname 'br-lan'
option vid '100'
option macaddr '...:00'
config device
option name 'br-lan.101'
option type '8021q'
option ifname 'br-lan'
option vid '101'
option macaddr '...:01'
config device
option name 'br-lan.102'
option type '8021q'
option ifname 'br-lan'
option vid '102'
option macaddr '...:02'
config device
option name 'br-lan.103'
option type '8021q'
option ifname 'br-lan'
option vid '103'
option macaddr '...:03'
config interface 'tun0' ## This is the openvpn interface and it works fine.
option proto 'none'
option device 'tun0'
list dns '10.0.0.100'
config interface 'vpn'
option proto 'wireguard'
option private_key '...'
option listen_port '...'
list addresses '10.11.11.1/24'
option defaultroute '0' ## I think I've tried also with '1' with no success but I had so many trials and error that I'm no longer sure about anything...
option delegate '0'
option auto '0'
config wireguard_vpn
option description 'mobile1'
option public_key '...'
option preshared_key '...'
list allowed_ips '0.0.0.0/0'
list allowed_ips '10.0.0.0/8'
option route_allowed_ips '1'
option persistent_keepalive '25'
config wireguard_vpn
option description 'mobile2'
option public_key '...'
option private_key '...'
option preshared_key '...'
list allowed_ips '10.0.0.0/8'
list allowed_ips '0.0.0.0/0'
option route_allowed_ips '1'
option persistent_keepalive '25'
config wireguard_vpn
option description 'mobile3'
option public_key '...'
option private_key '...'
option preshared_key '...'
option route_allowed_ips '1'
option persistent_keepalive '25'
list allowed_ips '10.0.0.0/8'
list allowed_ips '0.0.0.0/0'
Here is an example config file that I'm using in one of the mobiles:
[Interface]
PrivateKey = ...
# ListenPort not defined
address = 10.11.11.101/24 ## configured manually in the wireguard mobile UI
dns = 10.0.0.100 ## configured manually in the wireguard mobile UI
[Peer]
PublicKey = ...
PresharedKey = ...
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = <publicIPaddressOfCarrierModem>:<port>
PersistentKeepAlive = 25
The vpn interface belongs to the lan zone in the firewall configuration
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
list network 'vpn'
list network 'tun0'
config zone
option name 'wan'
option input 'DROP'
option output 'ACCEPT'
option forward 'ACCEPT'
option masq '1'
option mtu_fix '1'
list network 'wan'
list network 'wan6'
list network 'vec'
config forwarding
option src 'lan'
option dest 'wan'
Here is the routing table in the router:
root@OpenWrt:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.254 0.0.0.0 UG 10 0 0 wan
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan.100
10.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 vpn
10.1.1.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan.101
10.2.2.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan.102
10.3.3.0 0.0.0.0 255.255.255.0 U 0 0 0 br-lan.103
10.11.11.0 0.0.0.0 255.255.255.0 U 0 0 0 vpn
10.10.10.0 10.10.10.2 255.255.255.0 UG 0 0 0 tun0
10.10.10.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
otherVPNip 192.168.1.254 255.255.255.255 UGH 10 0 0 wan
192.168.1.0 0.0.0.0 255.255.255.0 U 10 0 0 wan
I hope someone could tell me what I've got wrong.
Regards and happy new year