This is kind of a very niche usecase.
I currently have a OpenWRT as dumb AP behind a ISP modem/router. On the OpenWRT, I have Wireguard client set up, now I'm trying to figure out how to make only one of the LAN ports uses the Wireguard tunnel, but all other stuff go through the normal ISP router.
I have created a new bridge devide br-lan_vpn
, assgined lan4
to it and removed from the default br-lan
, created a new firewall zone lan_vpn
and assigned br-lan_vpn
to that zone. lan_vpn
zone have "accept" for input, output and forward.
Wireguard client interface is in its own firewall zone unsafegway
, allowed br-lan_vpn
to be forwarded to unsafegway
, enabled masquerading.
Currently, curl http://ipinfo.io/json --interface br-lan_vpn
is still failing, but curl http://ipinfo.io/json --interface unsafegateway
is working as expected, so I'm still missing something.
/etc/config/network
:
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 'fdb7:33d7:725a::/48'
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
config device
option name 'lan1'
option macaddr '<shhh>'
config device
option name 'lan2'
option macaddr '<shhh>'
config device
option name 'lan3'
option macaddr '<shhh>'
config device
option name 'lan4'
option macaddr '<shhh>'
config interface 'lan'
option device 'br-lan'
option proto 'static'
option ipaddr '192.168.0.2'
option netmask '255.255.255.0'
option ip6assign '60'
option gateway '192.168.0.1'
config device
option name 'wan'
option macaddr '<shhh>'
config interface 'wan'
option device 'wan'
option proto 'dhcp'
config interface 'wan6'
option device 'wan'
option proto 'dhcpv6'
config interface 'vpn'
option proto 'wireguard'
option private_key '<shhh>'
option listen_port '51820'
list addresses '10.10.36.1/24'
list addresses 'fdee:36::1/32'
config wireguard_vpn 'wgclient_2'
option public_key '<shhh>'
option preshared_key '<shhh>'
list allowed_ips 'fdee:36::2/128'
list allowed_ips '10.10.36.2/32'
config interface 'lan_vpn'
option proto 'static'
option device 'br-lan_vpn'
option ipaddr '192.168.1.2'
option netmask '255.255.255.0'
option gateway '10.10.254.2'
config device
option type 'bridge'
option name 'br-lan_vpn'
list ports 'lan4'
option ipv6 '0'
config interface 'unsafegateway'
option proto 'wireguard'
option private_key '<shhh>'
list addresses '10.10.254.2/24'
list addresses 'fdef:2::1/32'
config wireguard_unsafegateway 'unsafegatewayserver'
option public_key '<shhh>'
option endpoint_host '<shhh>'
option endpoint_port '51830'
option persistent_keepalive '25'
list allowed_ips '0.0.0.0/0'
list allowed_ips '::/0'
/etc/config/firewall
:
config defaults
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option synflood_protect '1'
option flow_offloading '1'
config zone 'lan'
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan'
config zone 'wan'
option name 'wan'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option mtu_fix '1'
list network 'wan'
list network '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 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 zone
option name 'vpn'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'vpn'
config forwarding
option src 'vpn'
option dest 'lan'
config forwarding
option src 'lan'
option dest 'vpn'
config forwarding
option src 'vpn'
option dest 'wan'
config rule 'wg'
option name 'Allow-WireGuard'
option src 'wan'
option dest_port '51820'
option proto 'udp'
option target 'ACCEPT'
config nat
option name 'vpn to lan snat'
list proto 'all'
option src 'lan'
option src_ip '10.10.36.0/24'
option target 'SNAT'
option snat_ip '192.168.0.2'
config zone
option name 'lan_vpn'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'lan_vpn'
list device 'br-lan_vpn'
option family 'ipv4'
config zone
option name 'unsafegway'
option input 'REJECT'
option output 'ACCEPT'
option forward 'REJECT'
option masq '1'
option masq6 '1'
list network 'unsafegateway'
config forwarding
option src 'lan_vpn'
option dest 'unsafegway'
Note that there is also another Wireguard interface named vpn
in there, that is working fine and not related to this topic, I have just included the irrelevant configs here so that if there's a conflict it's easier to find. The relevant interfaces/devices/zones are named br-lan_vpn
/ lan_vpn
/ unsafegway
/ unsafegateway
and the likes.