For ages(>7yr) my automation scripts were adding new external IPs to the servers in this way
ifconfig lo:0 22.214.171.124 netmask 255.255.255.255 ifconfig lo:1 126.96.36.199 netmask 255.255.255.255 ...
This worked fine with all (>10) providers i worked with and i never had problems.
Now i realized, that i was adding ips to loopback and it might be wrong
and lo just left after playing in 127.0.0.0/8 sandbox =)
A short investigation figured out, that necessary route adds automatically and packet arrived to these ips is routed correctly
lo route is visible in routel as
188.8.131.52 local 184.108.40.206 kernel host lo local 220.127.116.11 local 18.104.22.168 kernel host lo local
but not in ip route show
default via 22.214.171.124 dev eth0 126.96.36.199/24 dev eth0 proto kernel scope link src 188.8.131.52
Testing a route: sends via default route to server`s basic (added to eth0) ip gateway
#ip route get 184.108.40.206 from 220.127.116.11 iif lo 18.104.22.168 from 22.214.171.124 via 126.96.36.199 dev eth0
So, im sending packets from 188.8.131.52 to 192.168.1.1 instead of 184.108.40.206 and it works on MANY configurations with no questions asked by MANY providers.
Q1: Why is this working?
Q2: Which way of adding multiple gateways is better?(220.127.116.11 for source 18.104.22.168, 22.214.171.124 for source 126.96.36.199)
is adding multiple like below a good idea or src based routing is better?
auto eth0:0 iface eth0:0 inet static address 188.8.131.52 netmask 255.255.255.0 broadcast 184.108.40.206 gateway 220.127.116.11 auto eth0:1 iface eth0:1 inet static address 18.104.22.168 netmask 255.255.255.0 broadcast 22.214.171.124 gateway 126.96.36.199
Thanks for help!