gedankensplitter/linux_routing.md
2023-01-23 16:29:30 +01:00

23 lines
823 B
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Linux routing things
#### same interface reply
https://gmelikov.com/2018/02/27/linux-network-reply-interface-incoming/
Long story short: local corporate server have 2 interfaces:
1) Public Internet IP address (eth0)
2) Local network IP address (eth1)
By default Linux tries to reply on interface with default route (eth0 in this case), even if request came from different iface (eth1). Lets fix it.
We need to create an `ip rule` with IP adresses table and configure it for all interfaces:
```
echo 200 reth0 >> /etc/iproute2/rt_tables
echo 201 reth1 >> /etc/iproute2/rt_tables
ip rule add from <ip address of eth0> table reth0
ip route add default via <gateway of eth0> dev eth0 table reth0
ip rule add from <ip address of eth1> table reth1
ip route add default via <gateway of eth1> dev eth1 table reth1
```