2

We use keepalived to manage our Linux Virtual Server (LVS) load balancer. The LVS VIPs are setup to use a FWMARK as configured in iptables.

 virtual_server fwmark 300000 {
    delay_loop 10
    lb_algo wrr
    lb_kind NAT
    persistence_timeout 180
    protocol TCP

    real_server 10.10.35.31 {
        weight 24
        MISC_CHECK {
            misc_path "/usr/local/sbin/check_php_wrapper.sh 10.10.35.31"
            misc_timeout 30
        }
    }

    real_server 10.10.35.32 {
        weight 24
        MISC_CHECK {
            misc_path "/usr/local/sbin/check_php_wrapper.sh 10.10.35.32"
            misc_timeout 30
        }
    }

    real_server 10.10.35.33 {
        weight 24
        MISC_CHECK {
            misc_path "/usr/local/sbin/check_php_wrapper.sh 10.10.35.33"
            misc_timeout 30
        }
    }

    real_server 10.10.35.34 {
        weight 24
        MISC_CHECK {
            misc_path "/usr/local/sbin/check_php_wrapper.sh 10.10.35.34"
            misc_timeout 30
        }
    }
}

http://www.austintek.com/LVS/LVS-HOWTO/HOWTO/LVS-HOWTO.fwmark.html

[root@lb1 ~]# iptables -L -n -v -t mangle
Chain PREROUTING (policy ACCEPT 182G packets, 114T bytes)
 190M  167G MARK       tcp  --  *      *       0.0.0.0/0            w1.x1.y1.4       multiport dports 80,443 MARK set 0x493e0 
  62M   58G MARK       tcp  --  *      *       0.0.0.0/0            w1.x1.y2.4       multiport dports 80,443 MARK set 0x493e0 


[root@lb1 ~]# ipvsadm -L
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
FWM  300000 wrr persistent 180
  -> 10.10.35.31:0                Masq    24     1          0         
  -> dis2.domain.com:0                Masq    24     3          231       
  -> 10.10.35.33:0                Masq    24     0          208       
  -> 10.10.35.34:0                Masq    24     0          0 

At the time the realservers were setup, there was a misconfigured dns for some hosts in the 10.10.35.0/24 network. Thereafter, we fixed the DNS. However, the hosts continue to show up as only their IP numbers (10.10.35.31,10.10.35.33,10.10.35.34) above.

[root@lb1 ~]# host 10.10.35.31 31.35.10.10.in-addr.arpa domain name pointer dis1.domain.com.

OS is CentOS 6.3. Ipvsadm is ipvsadm-1.25-10.el6.x86_64. kernel is kernel-2.6.32-71.el6.x86_64. Keepalived is keepalived-1.2.7-1.el6.x86_64.

How can we get ipvsadm -L to list all realservers by their proper hostnames?

dmourati
  • 24,720
  • 2
  • 40
  • 69

1 Answers1

1

Looks like you have an issue with name resolution on your machine.

ipvsadm uses gethostbyaddr() every time it displays the list, so it lets your libc grab the name dynamically (call chain: print_conn -> addrport_to_anyname -> addr_to_anyname -> addr_to_host -> gethostbyaddr).

You might need to flush your caches (restart nscd, etc.), or fix your DNS.

Pierre Carrier
  • 2,607
  • 17
  • 28
  • Problem was two of the three nameservers were not configured for the reverse zone. options timeout:1 rotate nameserver 10.10.60.31 nameserver 10.10.60.32 nameserver 10.10.60.33 – dmourati Dec 06 '12 at 19:50