For ages(>7yr) my automation scripts were adding new external IPs to the servers in this way
ifconfig lo:0 188.8.131.52 netmask 255.255.255.255 ifconfig lo:1 184.108.40.206 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
220.127.116.11 local 18.104.22.168 kernel host lo local 22.214.171.124 local 126.96.36.199 kernel host lo local
but not in ip route show
default via 188.8.131.52 dev eth0 184.108.40.206/24 dev eth0 proto kernel scope link src 220.127.116.11
Testing a route: sends via default route to server`s basic (added to eth0) ip gateway
#ip route get 18.104.22.168 from 22.214.171.124 iif lo 126.96.36.199 from 188.8.131.52 via 184.108.40.206 dev eth0
So, im sending packets from 220.127.116.11 to 192.168.1.1 instead of 18.104.22.168 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?(22.214.171.124 for source 126.96.36.199, 188.8.131.52 for source 184.108.40.206)
is adding multiple like below a good idea or src based routing is better?
auto eth0:0 iface eth0:0 inet static address 220.127.116.11 netmask 255.255.255.0 broadcast 18.104.22.168 gateway 22.214.171.124 auto eth0:1 iface eth0:1 inet static address 126.96.36.199 netmask 255.255.255.0 broadcast 188.8.131.52 gateway 184.108.40.206
Thanks for help!