Help with local wireguard config Site-To-Site

Hello, sorry if this has already being solved but I really can't fix my problem.
What I want to do is the following.
I want to replace a softethervpn bridge with a local wireguard vpn. The main reason is to create a site-to-site vpn to connect 2 LAN network.
One LAN have a public ip and can be reached by opening without a problem.
The second LAN is behind a Carrier-grade NAT (isp give a private ip with dhcp and lots of user share the same public ip, can't open port and the internal private ip can't be reached from internet)

So I need the VPN to permit connection to the second LAN using the first LAN as a server. From what I read only, wireguard should permit to do this.

Ip description
LAN1: 192.168.2.1/23 public ip is reachable with DDNS
LAN2: 192.168.3.1/24

LAN1 can access device on LAN2 and LAN2 can access device on LAN1 like they were on the same bridge.

I setup the wireguard interface and LAN2 can establish a valid connection. Problem is that only the wireguard interface ip is pingable but any local ip is not.

Anyway both wireguard interface are assigned to LAN firewall zone.

The LAN1 config:

config interface 'VPN'
	option proto 'wireguard'
	option private_key 'MMI......'
	option listen_port '51820'
	list addresses '172.16.0.1'

config wireguard_VPN
	option public_key 'bTc...'
	option description 'Local'
	option endpoint_port '51820'
	option route_allowed_ips '1'
	list allowed_ips '172.16.0.2/32'
	list allowed_ips '192.168.3.1/24'
	list allowed_ips '192.168.2.1/24'

LAN2 config:

config interface 'vpn_ta'
	option proto 'wireguard'
	option private_key '0CX...'
	list addresses '172.16.0.2'
	option listen_port '51820'

config wireguard_vpn_ta
	option endpoint_host '1'?!?!?! i'm stupid'
	option public_key 'HiH...'
	option persistent_keepalive '25'
	option endpoint_port '51820'
	option description 'Taranto'
	option route_allowed_ips '1'
	list allowed_ips '172.16.0.1/32'
	list allowed_ips '192.168.3.1/24'
	list allowed_ips '192.168.2.1/24'

wg LAN1:

interface: VPN
  public key: HiH....
  private key: (hidden)
  listening port: 51820

peer: bTc....
  endpoint: [1?!?"?!"?!"?]:51820
  allowed ips: 172.16.0.2/32, 192.168.3.0/24, 192.168.2.0/24
  latest handshake: 59 seconds ago
  transfer: 9.18 KiB received, 3.76 KiB sent

wg LAN2:

interface: vpn_ta
  public key: bTc...
  private key: (hidden)
  listening port: 51820

peer: HiH...
  endpoint: [!?"?"?"?!]:51820
  allowed ips: 172.16.0.1/32, 192.168.3.0/24, 192.168.2.0/24
  latest handshake: 1 minute, 22 seconds ago
  transfer: 2.50 KiB received, 9.04 KiB sent
  persistent keepalive: every 25 seconds

Change the configs as follows:

LAN 1

config interface 'VPN'
	option proto 'wireguard'
	option private_key 'MMI......'
	option listen_port '51820'

config wireguard_VPN
	option public_key 'bTc...'
	option description 'Local'
	option endpoint_port '51820'
	option route_allowed_ips '1'
	list allowed_ips '192.168.3.0/24'

LAN 2

config interface 'vpn_ta'
	option proto 'wireguard'
	option private_key '0CX...'
	option listen_port '51820'

config wireguard_vpn_ta
	option endpoint_host ''
	option public_key 'HiH...'
	option persistent_keepalive '25'
	option endpoint_port '51820'
	option description 'Taranto'
	option route_allowed_ips '1'
	list allowed_ips '192.168.2.0/24'
1 Like

pls hide my address LOL 8also from edit history

No luck...
Still LAN2 can't ping 192.168.2.1
LAN1 can't ping 192.168.3.1
Here the wg command
LAN1:

interface: VPN
  public key: HiH...
  private key: (hidden)
  listening port: 51820

peer: bTc...
  endpoint: [1?!?!?]:51820
  allowed ips: 192.168.3.0/24
  latest handshake: 1 minute, 46 seconds ago
  transfer: 212 B received, 8.87 KiB sent

LAN2

interface: vpn_ta
  public key: bTc...
  private key: (hidden)
  listening port: 51820

peer: HiH....
  endpoint: [1?!?!]:51820
  allowed ips: 192.168.2.0/24
  latest handshake: 17 seconds ago
  transfer: 248 B received, 13.26 KiB sent
  persistent keepalive: every 25 seconds

What's the output of uci export network; uci export firewall; ip -4 addr ; ip -4 ro li tab all ; ip -4 ru?

Should i hide something? You want this from both lan?

Yeah, both LANs. Hide anything sensitive, so wireguard keys, public IPs/addresses etc.

1 Like

Hoping i cleared it the right way... there is a wireguard firewall zone but currently there is nothing added (leftover from some tests)

LAN1:

package 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 'fd49:5134:465f::/48'
        option packet_steering '1'

config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.2.1'
        option netmask '255.255.254.0'
        option stp '1'
        option ip6assign '64'
        option ip6hint '0001'
        option ifname 'lan1 lan2 lan3 lan4 tap_softether'

config interface 'guest'
        option proto 'static'
        option netmask '255.255.255.0'
        option _orig_ifname 'wlan1-1'
        option _orig_bridge 'false'
        option type 'bridge'
        option metric '10'
        option ipaddr '192.168.20.1'
        option ip6assign '64'
        option ip6hint '0002'

config interface 'wan'
        option proto 'pppoe'
        option ipv6 'auto'
        option metric '0'
        option keepalive '0'
        option ifname 'wan'
        option username 'sadsa'
        option password 'a'

config interface 'modem'
        option proto 'static'
        option netmask '255.255.255.0'
        option ifname 'wan'
        option ipaddr '192.168.1.7'

config interface 'hetunnel'
        option proto '6in4'
        option peeraddr '...'
        option ip6addr '...'
        option tunnelid '550591'
        option username '...'
        option password '...'
        list ip6prefix '...'

config interface 'VPN'
        option proto 'wireguard'
        option private_key 'MMI...
        option listen_port '51820'
        option auto '0'

config wireguard_VPN
        option public_key 'bTc...'
        option description 'Local'
        option endpoint_port '51820'
        option route_allowed_ips '1'
        list allowed_ips '192.168.3.0/24'

package firewall

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option src_ip 'fc00::/6'
        option dest_ip 'fc00::/6'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule 'guest_rule_dns'
        option name 'Allow DNS Queries'
        option src 'guest'
        option target 'ACCEPT'
        option proto 'tcp udp'
        option dest_port '53'

config rule 'guest_rule_dhcp'
        option name 'Allow DHCP request'
        option src 'guest'
        option proto 'udp'
        option target 'ACCEPT'
        option dest_port '67-68'

config defaults
        option input 'ACCEPT'
        option output 'ACCEPT'
        option drop_invalid '1'
        option forward 'REJECT'
        option synflood_protect '1'

config zone
        option name 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        option network 'lan VPN'

config zone
        option name 'wan'
        option output 'ACCEPT'
        option masq '1'
        option mtu_fix '1'
        option input 'REJECT'
        option forward 'REJECT'
        option network 'modem wan wan_6 wan6 guest_wan_6 hetunnel'

config include
        option path '/etc/firewall.user'

config zone 'guest_zone'
        option name 'guest'
        option network 'guest'
        option input 'REJECT'
        option forward 'REJECT'
        option output 'ACCEPT'

config forwarding
        option dest 'wan'
        option src 'guest'

config forwarding
        option dest 'wan'
        option src 'lan'

config rule
        option target 'ACCEPT'
        option proto 'udp'
        option name 'Guest-DHCPv6'
        option family 'ipv6'
        option src 'guest'
        option src_port '546'
        option dest_port '547'

config rule
        option target 'ACCEPT'
        option name 'Guest-SLAAC'
        option family 'ipv6'
        option src 'guest'
        option proto 'icmp'
        list icmp_type 'router-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'neighbour-advertisement'
        list icmp_type '141'
        list icmp_type '142'
        list icmp_type '148'
        list icmp_type '149'

config rule
        option target 'ACCEPT'
        option name 'Guest-Ping'
        option family 'ipv6'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option src 'guest'

config rule
        option name 'Guest-MLD'
        option src 'guest'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        list icmp_type '151/0'
        list icmp_type '152/0'
        list icmp_type '153/0'
        option family 'ipv6'
        option target 'ACCEPT'

config include 'miniupnpd'
        option type 'script'
        option path '/usr/share/miniupnpd/firewall.include'
        option family 'any'
        option reload '1'

config rule
        option name 'WireGuard VPN'
        list proto 'udp'
        option src 'wan'
        option target 'ACCEPT'
        option dest_port '51820'

config zone
        option name 'wireguard'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option masq '1'
        option mtu_fix '1'
        option forward 'ACCEPT'

config forwarding
        option src 'wireguard'
        option dest 'lan'

config forwarding
        option src 'lan'
        option dest 'wireguard'

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
7: wan@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.1.7/24 brd 192.168.1.255 scope global wan
       valid_lft forever preferred_lft forever
34: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.2.1/23 brd 192.168.3.255 scope global br-lan
       valid_lft forever preferred_lft forever
35: br-guest: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.20.1/24 brd 192.168.20.255 scope global br-guest
       valid_lft forever preferred_lft forever
40: pppoe-wan: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1492 qdisc cake state UNKNOWN group default qlen 3
    inet .... peer 192.168.100.1/32 scope global pppoe-wan
       valid_lft forever preferred_lft forever
default via 192.168.100.1 dev pppoe-wan proto static
192.168.1.0/24 dev wan proto kernel scope link src 192.168.1.7
192.168.2.0/23 dev br-lan proto kernel scope link src 192.168.2.1
192.168.3.0/24 dev VPN proto static scope link
192.168.20.0/24 dev br-guest proto static scope link metric 10
192.168.100.1 dev pppoe-wan proto kernel scope link src ....
.... via 192.168.100.1 dev pppoe-wan proto static
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.1.0 dev wan table local proto kernel scope link src 192.168.1.7
local 192.168.1.7 dev wan table local proto kernel scope host src 192.168.1.7
broadcast 192.168.1.255 dev wan table local proto kernel scope link src 192.168.1.7
broadcast 192.168.2.0 dev br-lan table local proto kernel scope link src 192.168.2.1
local 192.168.2.1 dev br-lan table local proto kernel scope host src 192.168.2.1
broadcast 192.168.3.255 dev br-lan table local proto kernel scope link src 192.168.2.1
broadcast 192.168.20.0 dev br-guest table local proto kernel scope link src 192.168.20.1
local 192.168.20.1 dev br-guest table local proto kernel scope host src 192.168.20.1
broadcast 192.168.20.255 dev br-guest table local proto kernel scope link src 192.168.20.1
local .... dev pppoe-wan table local proto kernel scope host src ....
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

LAN2:

package 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 'fd06:5ac8:f7c4::/48'

config interface 'lan'
        option type 'bridge'
        option proto 'static'
        option ipaddr '192.168.3.1'
        option ip6assign '64'
        option metric '0'
        option netmask '255.255.254.0'
        option stp '1'
        option ifname 'lan1 lan2 lan3 lan4 tap_vpn-bridge'

config interface 'wan'
        option ifname 'wan'
        option proto 'dhcp'

config interface 'wan6'
        option proto 'dhcpv6'
        option ifname '@wan'
        option reqaddress 'try'
        option reqprefix 'auto'

config interface 'vpn_ta'
        option proto 'wireguard'
        option private_key '0CX...'
        option listen_port '51820'
        option auto '0'

config wireguard_vpn_ta
        option endpoint_host '...'
        option public_key 'HiH...'
        option persistent_keepalive '25'
        option endpoint_port '51820'
        option description 'Taranto'
        option route_allowed_ips '1'
        list allowed_ips '192.168.2.0/24'

package firewall

config defaults
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'REJECT'
        option synflood_protect '1'

config zone
        option name 'lan'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        option network 'lan vpn_ta'

config zone
        option name 'wan'
        option output 'ACCEPT'
        option forward 'REJECT'
        option masq '1'
        option mtu_fix '1'
        option input 'ACCEPT'
        option network 'wan modem wan6'

config forwarding
        option src 'lan'
        option dest 'wan'

config rule
        option name 'Allow-DHCP-Renew'
        option src 'wan'
        option proto 'udp'
        option dest_port '68'
        option target 'ACCEPT'
        option family 'ipv4'

config rule
        option name 'Allow-Ping'
        option src 'wan'
        option proto 'icmp'
        option icmp_type 'echo-request'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-IGMP'
        option src 'wan'
        option proto 'igmp'
        option family 'ipv4'
        option target 'ACCEPT'

config rule
        option name 'Allow-DHCPv6'
        option src 'wan'
        option proto 'udp'
        option src_ip 'fc00::/6'
        option dest_ip 'fc00::/6'
        option dest_port '546'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-MLD'
        option src 'wan'
        option proto 'icmp'
        option src_ip 'fe80::/10'
        list icmp_type '130/0'
        list icmp_type '131/0'
        list icmp_type '132/0'
        list icmp_type '143/0'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Input'
        option src 'wan'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        list icmp_type 'router-solicitation'
        list icmp_type 'neighbour-solicitation'
        list icmp_type 'router-advertisement'
        list icmp_type 'neighbour-advertisement'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-ICMPv6-Forward'
        option src 'wan'
        option dest '*'
        option proto 'icmp'
        list icmp_type 'echo-request'
        list icmp_type 'echo-reply'
        list icmp_type 'destination-unreachable'
        list icmp_type 'packet-too-big'
        list icmp_type 'time-exceeded'
        list icmp_type 'bad-header'
        list icmp_type 'unknown-header-type'
        option limit '1000/sec'
        option family 'ipv6'
        option target 'ACCEPT'

config rule
        option name 'Allow-IPSec-ESP'
        option src 'wan'
        option dest 'lan'
        option proto 'esp'
        option target 'ACCEPT'

config rule
        option name 'Allow-ISAKMP'
        option src 'wan'
        option dest 'lan'
        option dest_port '500'
        option proto 'udp'
        option target 'ACCEPT'

config include
        option path '/etc/firewall.user'

config redirect 'adblock_dns'
        option name 'Adblock DNS'
        option src 'lan'
        option proto 'tcp udp'
        option src_dport '53'
        option dest_port '53'
        option target 'DNAT'

config offload_option
        option flow_offloading '0'

config include 'miniupnpd'
        option type 'script'
        option path '/usr/share/miniupnpd/firewall.include'
        option family 'any'
        option reload '1'

config forwarding
        option src 'wireguard'
        option dest 'lan'

config zone
        option name 'wireguard'
        option input 'ACCEPT'
        option output 'ACCEPT'
        option forward 'ACCEPT'
        option masq '1'
        option mtu_fix '1'

config forwarding
        option src 'lan'
        option dest 'wireguard'

config include 'qcanssecm'
        option type 'script'
        option path '/etc/firewall.d/qca-nss-ecm'
        option family 'any'
        option reload '1'

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
9: wan@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.1.170/24 brd 192.168.1.255 scope global wan
       valid_lft forever preferred_lft forever
39: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 192.168.3.1/23 brd 192.168.3.255 scope global br-lan
       valid_lft forever preferred_lft forever
default via 192.168.1.254 dev wan proto static src 192.168.1.170
192.168.1.0/24 dev wan proto kernel scope link src 192.168.1.170
192.168.2.0/24 dev vpn_ta proto static scope link
192.168.2.0/23 dev br-lan proto kernel scope link src 192.168.3.1
... via 192.168.1.254 dev wan proto static
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1
broadcast 192.168.1.0 dev wan table local proto kernel scope link src 192.168.1.170
local 192.168.1.170 dev wan table local proto kernel scope host src 192.168.1.170
broadcast 192.168.1.255 dev wan table local proto kernel scope link src 192.168.1.170
broadcast 192.168.2.0 dev br-lan table local proto kernel scope link src 192.168.3.1
local 192.168.3.1 dev br-lan table local proto kernel scope host src 192.168.3.1
broadcast 192.168.3.255 dev br-lan table local proto kernel scope link src 192.168.3.1
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default

Are these LANs remote from each other? Do you have any other LANs at either site that use the same subnet as used at the other site?

At the moment I'm guessing it's a routing, rather than connectivity issue. If it were the latter you shouldn't be getting a handshake between the two ends.

1 Like

Can 192.168.2.1/23 cause a problem? Aside from that nope...
On LAN1 i don't have any subnet that use 192.168.3.1 and on LAN2 i don't have 192.168.2.1

Could be that the softether bridge is the problem here?
Can you confirm that the config you provided should work for my use case?

Possibly. Can you change it to /24 for testing?

Again, it is possible. If that's something else which you can easily remove for testing then I'd do that.

Yeah, it should work. The required config for a site to site VPN with wireguard is straightforward.

2 Likes

Changed to 192.168.2.1/24
Disabled softether
network restart...
No luck...

Will try to reboot..

Any idea how to understand why this doesn't work?

Definitely don't use /23 or .254 netmasks. There need to be two separate networks with routing in between them.

The route command will show almost all you need to know. Each main router holds a .172 address corresponding to its end of the tunnel. The route to the other LAN is via the tunnel address of the other router.

2 Likes

I found the problem... br-lan on LAN2 was set to 192.168.2.1 and gateway set to 192.168.3.1 (dhcp start to 256)
This cause the wireguard route to be overwritten... Now it all work...

Anyway should i add the wireguard interface to the br-lan bridge?
I notice samba share doesn't appear but they are reachable.

I'd leave it separate. Just add the interface to the LAN firewall zone.

Any idea why the share doesn't appear? (i solved this with the softether bridge by putting the 2 lan in a big netmask (23) and set the gateway accordingly so the share and the service can announce and see each other... but i don't know if this is doable for wireguard...)

Discovery protocols are based on broadcast packets that don't forward. You will need to manually enter the IP or set up DNS on both sides.

2 Likes

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