Answer the question
In order to leave comments, you need to log in
How to build routes correctly?
There is a network 172.16.100.0/24 which needs to be given access to the Internet through the ens19 interface, its address is 10.0.88.111/24, the gateway is 10.0.88.254, I wrote the following:
default via 10.0.88.254 dev ens19
ip route add 172.16.100.0/24 via 10.0.88.111
iptables -A POSTROUTING -t nat -s 172.16.100.0/24 -o ens19 -j MASQUERADE
Answer the question
In order to leave comments, you need to log in
Try like this:
echo > /etc/iproute2/rt_tables 200 ens19
ip rule add from 172.16.100.0/24 lookup ens19
ip route add default via 10.0.88.254 table ens19
iptables -A POSTROUTING -t nat -s 172.16.100.0/24 -o ens19 -j MASQUERADE
You spelled it wrong.
The 172.16.100.0/24 network does not need to know anything about "ens19 interface, its address is 10.0.88.111/24, the gateway is 10.0.88.254"
For it, only an address from its own subnet can be a gateway, so this entry "ip route add 172.16. 100.0/24 via 10.0.88.111" is fundamentally wrong.
Describe the interfaces on the server in more detail.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question