0

I have a small Haproxy server set up with 2 NICs. The OS is CentOS7 and I have configured both NICs on the same subnet per CentOS documentation.

— 192.168.0.1, 192.168.0.2 ---- both on 192.168.0.0/24 192.168.0.1 is used for management and the web gui, 192.168.0.2 is used for the LB traffic.

Traffic coming into the LB hits the 192.168.0.2 address, but seems to be egressing to the 192.168.0.1 address to the backend servers. I’ve tried specifying “source IP” in the config to no avail.

Version is 1.8.16.

If I do the telnet from the LB CLI inside Linux, the routing seems to work correctly, so it seems the LB application itself isn’t going out on the correct interface/IP.

EDIT-1: Backend servers are on the same subnet as the LBs (192.168.0.0/24).

ip-a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether [mac screened] brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.1/24 brd 192.168.0.255 scope global noprefixroute eth0
           valid_lft forever preferred_lft forever
    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether [mac screened] brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.2/24 brd 192.168.0.255 scope global noprefixroute eth1
           valid_lft forever preferred_lft forever

The following routes and ip rules have been manually added (per the guide https://access.redhat.com/solutions/30564)

# ip route show table eth0table
default via 192.168.0.0 dev eth0 
192.168.0.0/24 dev eth0 scope link src 192.168.0.1
# ip route show table eth1table
default via 192.168.0.0 dev eth1 
192.168.0.0/24 dev eth0 scope link src 192.168.0.2 

ip rules:

0:  from all lookup local 
32762:  from all to 192.168.0.2 lookup eth1table 
32763:  from 192.168.0.2 lookup eth1table 
32764:  from all to 192.168.0.1 lookup eth0table 
32765:  from 192.168.0.1 lookup eth0table 
32766:  from all lookup main 
32767:  from all lookup default 

ip ro

default via 192.168.0.0 dev eth0 proto static metric 100 
default via 192.168.0.0 dev eth1 proto static metric 101 
192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.1 metric 100 
192.168.0.0/24 dev eth1 proto kernel scope link src 192.168.0.2 metric 101
  • Outgoing traffic simply uses the network routes provided. You need to give a lot more info, e.g. on what subnet are the backend servers? What does the routing table look like? Include the output of ip a and ip ro on the haproxy host (presumably the same as the "LB" loadbalancer, although that's an assumption; you could be doing load balancing separately and using haproxy e.g. for SSL offloading; hence we need more info) in your question. – wurtel Jan 10 at 10:50
  • Edited original question to reflect the info. – customcables067 Jan 10 at 16:35
  • @customcables067 192.168.0.0 is this a gateway? – c4f4t0r Jan 11 at 14:21
  • "yes" it's the gateway (I've simplified the IPs from the real setup, so in real life, no, it's not the gateway. I realized the problem after I posted this but didn't wanna go back and edit everything. – customcables067 Jan 11 at 16:29
1

If you want traffic to 192.168.0.0/24 to originate from 192.168.0.2, then you need to add a rule:

ip rule add prio 32761 to 192.168.0.0/24 lookup eth1table

As it is now, no rules match, and routing falls to the main routing table which has 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.1 metric 100 as first most-specific entry, so eth0 will be used with IP address 192.168.0.1.

  • I only want traffic from eth1 to originate from 192.168.0.2 – customcables067 Jan 11 at 18:26
0

Problem ended up being related to NetworkManager controlling the routes somehow. Uninstalled NetworkManager, cleaned up the interface config files and things started behaving as expected, including with tables and rules.

Source: https://www.howtoforge.com/community/threads/first-ip-ok-second-ip-times-out.38613/

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.