0

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.

5
  • What do you mean by "goes out via the IP address" exactly? If you mean the source IP address isn't what you want, then you need to tell us what application we're talking about and what protocol we're talking about. Apr 13, 2017 at 8:17
  • @DavidSchwartz -- by "goes out via the IP address", I mean the source IP should be the anycast IP. This is an application developed in Golang and use HTTP to communicate to the remote host. I tried setting the default dialer in the code to the anycast IP.
    – rickydj
    Apr 13, 2017 at 10:15
  • When you say "outgoing traffic", do you mean TCP connections made by this machine? Or do you mean packets that are leaving this machine but that are part of an incoming TCP connection made by a client? Apr 13, 2017 at 10:22
  • @DavidSchwartz -- Yes, TCP connections are made from this machine. When my application initiates a connection to a remote machine, I want that connection to use 10.2.1.10 as the source IP. Currently, my application is using 10.155.65.0 as the source IP. My incoming connections are working fine and the application is servicing the requests. Connections that are initiated by the service is failing because of the issue cited above
    – rickydj
    Apr 13, 2017 at 11:37
  • There are two ways you can fix this: 1) You can configure the application to bind its sockets to that IP before it calls connect. 2) You can use a route with a src parameter in the routing table. You can have more than one routing table and make sure the application uses the one you want. Apr 13, 2017 at 11:50

0

You must log in to answer this question.

Browse other questions tagged .