How do I manually set up routing for wireguard?

Which one should I enter the data for configuring routing for wireguard?

I want to make one pc work not through a tunnel.
automatic routing from wireguard is having a problem, the problem is that one of the PCs is not visible from the vds.

The "Allowed IPs 0.0.0.0/0" option in peers wireguard is not suitable, because all computers start working through the tunnel.

How can I make a specific tcp port go to a different gateway?

wireguard gateway 10.0.0.1, home-provider has a different gateway. The task is to pass port 80 through the "home-provider" gateway

Policy Based Routing is the magic word

Using netifd for routing a port is at this moment only working in snapshot as my pr to add this is not backported yet.

If you are using Snapshot with support for port routing you can do it like this:

  1. Create alternative routing table with route via the wan, for routing via the wan you need the gateway of the wan, you can get this with: ifstatus wan | grep nexthop | sed 's/[^0-9.]//g' or look into the routing table with ip route show. Replace in the route below with the real ip address of the wan gateway
    /et/config/network:
config route
	option interface 'wan'
	option target '0.0.0.0/0'
	option table '102'
	option gateway '<wan-gateway>'      #replace with real ip address
  1. Make a rule to add the port to use the created table 102
    /etc/config/network
config rule
	# for ip source:
	#option src '192.168.30.0/24'
	# destination e.g. from all to dest
	#option dest '25.52.71.40/32'
	# for interface
	#option in 'lan'
	# for proto
	#option ipproto 'icmp`
	# for source port
	#option sport '116'
	# for destination port
	option dport '80'           # <<<<< THIS
	#table number to use for lookup
	option lookup '102'      # <<<<< THIS

But unless you are running snapshot and want to do it manually as described use the PBR app

Alternatively you can use a script or setup manually but that has its drawback as described:

2 Likes