Answer the question
In order to leave comments, you need to log in
Two network cards in one subnet, lartc, iproute2, 2 providers. How to setup?
Good evening, dear colleagues. I ask for your help with an interesting question.
There is a router - it looks into the LAN with two physical network cards that are plugged into a single switch (in neighboring ports).
OS: Debian 8.
I assigned IPs 192.168.0.1 (eth1) and 192.168.0.200 (eth2) to the cards
. Two providers are also connected to this router.
Using iptables, I enabled masquerade from the 192.168.0.0/24 subnet in all directions.
accordingly, if the client on its side sets the IP address of any of these cards (eth1,2) as the gateway, it gets access to the Internet through the default gw on the router.
The task was set - so that when installed on the client's workstation as a gateway 192.168.0.200, the Internet would go through the second provider.
was solved using three lines in iproute2
echo 1 2PR >> /etc/iproute2/rt_tables
ip rule add iif eth2 lookup 2PR
ip route add default via 10.0.0.1 table 2PR
where 10.0.0.1 is the gateway of the second provider
, now when the user puts in as the gateway 192.168.0.200 the traffic goes through the second dip (checked on 2ip.ru).
but! There are two interesting plugs that I can't figure out.
1) when diagnosing a route through traceroute, I observe that the gateway is 192.168.0.1. even if 192.168.0.200 is registered on the client in the ipv4 configuration. How does this happen?
2) Raised a DHCP server on both interfaces, which issues the first provider as a gateway (eth 1 , 192.168. through the second provider, which is also sooo strange.
3) Antiviruses from users swear that there are 2 gateways in LAN, and even with DHCP raised.
What could be the reason for this behaviour?
Answer the question
In order to leave comments, you need to log in
you need to mark established connections through the second provider in iptables mangle
in ip rule to catch these marks by wrapping traffic in table 2PR the
output should contain a route in 192.168.0.0/24 with only one line
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.200 table 2PR
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question