S
S
Sergey Zabodalov2014-06-17 21:30:31
linux
Sergey Zabodalov, 2014-06-17 21:30:31

Linux, how to divide network adapters into conditional routing zones?

There is Linux on which several network adapters are raised. They intersect in places on subnets.
Task: to allocate routing zones. For example:
Let there be 4 interfaces, 3 of them in the same network:
lan0.1 192.168.0.100/24
​​lan0.2 192.168.0.200/24
​​lan1.1 192.168.0.5/24
lan1.2 10.0.0.1/24
Task: configure iptables or something else so that the computer itself goes to the network 192.168.0.0/24 through lan1.1, everything that arrives on lan0.1 masquerades on lan0.2, and lan1.2 masquerades on lan1.1. In this case, packets from zone 0 (lan0.1 and lan0.2) should not fall into zone 1 (lan1.1 and lan 1.2) and vice versa.
How to do this and is it real?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
S
Sergey Zabodalov, 2014-06-18
@zabbius

the task was solved like this:
for lan0.1 and lan0.2, remove all routes from the main table
, add 2 tables:
ip route add 192.168.0.0/24 dev lan0.2 table 101
ip route add 192.168.0.0/24 dev lan0.1 table 102
add rules:
ip rule add iif lan0.1 lookup 101
ip rule add iif lan0.2 lookup 102
now everything that arrives on lan0.1 will go to lan0.2 and back.
you can also add
iptables -A FORWARD -j ACCEPT
iptables -t nat -A POSTROUTING ! -d 127.0.0.1/8 -j MASQUERADE
on lan1.1 and lan1.2 route as usual through the main table

P
Pavel Selivanov, 2014-06-18
@selivanov_pavel

You want something very strange. Describe the task. Maybe you just need a bridge?

C
Cool Admin, 2014-06-18
@ifaustrue

There is clearly something wrong with your network architecture. It looks like you are trying to combine three different subnets with the same addressing, which you probably got as is. Stop and think about changing the addressing, and not about implementing a cruel crutch.

D
DuD, 2014-06-18
@DuD

Maybe VLAN will help you

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question