I have a server A with a VPN configured to another server B. Currently, server A can ping server B by using the VPN address 10.12.0.1
.
I would like to route all HTTPS traffic via server B and let other traffic use default interface.
To do that, I inspired from this unix stackexchange answer and have run the following commands:
# define route
echo "200 myroute" >> /etc/iproute2/rt_tables
# seems necessary
sysctl -w net.ipv4.conf.wg1.rp_filter=2
# actual routing
ip route add table 200 10.12.0.0/24 dev wg1 src 10.12.0.10
ip route add table 200 default via 10.12.0.1
# actual rule telling HTTPS traffic to use table 200
ip rule add iif lo ipproto tcp dport 443 lookup 200
Then, I run curl https://1.1.1.1
(or any other host) and I get the error Failed to connect to 1.1.1.1 port 443: No route to host
. When I remove the rule, everything works again.
I guess my routing for table 200 is not correct but it seems to match the one from the original answer and the ones for the default interface.
Do you know how I can investigate and debug the issue?
Thank you
Additionnal information:
$ ip route show table 200
default via 10.12.0.1 dev wg1
10.12.0.0/24 dev wg1 scope link src 10.12.0.10
$ ip route show dev wg1
10.12.0.0/24 proto kernel scope link src 10.12.0.10
$ ip route get 1.1.1.1 ipproto tcp dport 443
1.1.1.1 via 10.12.0.1 dev wg1 table 200 src 10.12.0.10 uid 1001
cache
$ ip route
default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.51 metric 202
10.12.0.0/24 dev wg1 proto kernel scope link src 10.12.0.10
192.168.1.0/24 dev eth0 proto dhcp scope link src 192.168.1.51 metric 202
The VPN is a Wireguard VPN. When configured to route all traffic through the VPN, everything works.
Table
parameter is perfect). – clementescolano Jun 10 '21 at 07:54