V
V
Vi2016-07-19 07:22:46
linux
Vi, 2016-07-19 07:22:46

Nat setup when one physical interface?

In general, I have a Linux router on the network, only one physical interface is connected to it and there are 4 virtual ones.
So today it turned out that the MASQUERADE rule turned out to replace all addresses, that is, in the local network, if network A ( 10.0.0.0/24 ) accessed network B ( 172.16.0.0/24 ) then the router replaced the address with the one specified in the iptables rule.
In general, I have not yet been able to figure out how to make sure that local networks are routed in the usual way and that the replacement occurs only when someone tries to access the external network to access the Internet.
I'm looking for solutions and tips

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir, 2016-07-19
@redsabien

iptables -t nat -A POSTROUTING -s 10.0.0.0/24 ! -d 172.16.0.0/24  -o eth0 -j SNAT --to-source 208.77.188.166
iptables -t nat -A POSTROUTING -s 172.16.0.0/24  ! -d 10.0.0.0/24  -o eth0 -j SNAT --to-source 208.77.188.166

208.77.188.166 - which source can be substituted
instead of "SNAT --to-source 208.77.188.166" MASQUERADE, but SNAT is preferable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question