---------------------------------
| |
| |
-----> eth2 (WAN) --------> WG0-->------->-----> eth0 LAN 192.168.220.2
192.168.14.7 | | |
| | eth2 to eth1 |
| ->---->---------->-----> eth1 LAN 192.168.50.2
--------------------------------
I have a machine that has 3 ethernet interfaces and 1 wireguard client interface wg0.
eth2 (WAN) 192.168.14.7 (internet traffic comes from here)
eth0 (LAN) 192.168.220.2
eth1 (LAN) 192.168.50.2
wg0 (wireguard client) 10.125.146.2
My device works as wireguard client with wg0. Wireguard server is on VPS.
I already forward traffic with iptables from wg0 to eth0
lan. So my laptop connected to eth0 192.168.220.2 with public IP from wg0
.
If I connected my another laptop to eth1 the public IP is from wg0
too. I don't want it. I want to connect another laptop to eth1 192.168.50.2
without IP from wg0. I want eth1 to have the public IP that comes from eth2 WAN.
Is it possible to do that?
route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.14.1 0.0.0.0 UG 204 0 0 eth2
10.125.146.0 0.0.0.0 255.255.255.0 U 0 0 0 wg0
169.254.0.0 0.0.0.0 255.255.0.0 U 202 0 0 eth0
169.254.0.0 0.0.0.0 255.255.0.0 U 203 0 0 eth1
192.168.14.0 0.0.0.0 255.255.255.0 U 204 0 0 eth2
192.168.50.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
192.168.220.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
ip route
default via 192.168.14.1 dev eth2 proto dhcp src 192.168.14.7 metric 204
10.125.146.0/24 dev wg0 proto kernel scope link src 10.125.146.2
169.254.0.0/16 dev eth0 scope link src 169.254.50.120 metric 202
169.254.0.0/16 dev eth1 scope link src 169.254.231.124 metric 203
192.168.14.0/24 dev eth2 proto dhcp scope link src 192.168.14.7 metric 204
192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.2
192.168.220.0/24 dev eth0 proto kernel scope link src 192.168.220.2
ip rule show
0: from all lookup local
32764: from all lookup main suppress_prefixlength 0
32765: not from all fwmark 0xca6c lookup 51820
32766: from all lookup main
32767: from all lookup default
ip -4 -br addr
lo UNKNOWN 127.0.0.1/8
eth0 UP 192.168.220.2/24 169.254.50.120/16
eth1 UP 192.168.50.2/24 169.254.231.124/16
eth2 UP 192.168.14.7/24
wg0 UNKNOWN 10.125.146.2/24
ip route show table 51820
default dev wg0 scope link
ip route show table main
default via 192.168.14.1 dev eth2 proto dhcp src 192.168.14.7 metric 205
10.125.146.0/24 dev wg0 proto kernel scope link src 10.125.146.2
169.254.0.0/16 dev eth0 scope link src 169.254.50.120 metric 202
192.168.14.0/24 dev eth2 proto dhcp scope link src 192.168.14.7 metric 205
192.168.50.0/24 dev eth1 proto kernel scope link src 192.168.50.2 linkdown
192.168.220.0/24 dev eth0 proto kernel scope link src 192.168.220.2