On my debian server, I have several anycast IPs configured on the loopback interface with standard configuration on eth0 and eth1.
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet 10.1.0.2/32 scope global lo
inet 10.2.1.10/32 scope global lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 10.155.65.0/22 brd 10.155.67.255 scope global eth0
I have an application running on this server and the application is bound to one of the anycast IPs on the loopback interface. While incoming traffic hits the application as expected, outgoing traffic goes out via the IP address configured on the eth0 interface.
My requirement is to have the traffic go out via the anycast IP rather than the IP configured at eth0.
bind
its sockets to that IP before it callsconnect
. 2) You can use a route with asrc
parameter in the routing table. You can have more than one routing table and make sure the application uses the one you want.