您的位置:首页 > 运维架构 > Linux

single host multiple IP address configuration in Linux

2011-11-01 11:01 417 查看
Just write for avoid the forget.

1. configure multiple IP address in /etc/hosts

If we want to assign two IP addresses to a single host named "test", we can just simply configure the /etc/hosts like:

192.168.1.1 test
192.168.1.2 test

After this configuration, if we call the C function gethostbyname("test") to get the IP addresses of host "test", most probably it returns only one single IP address.

2. turn the "multi on" in /etc/host.conf

add the following line to the end of /etc/host.conf

multi on

After this modification, the gethostbyname("test") will return two IP addresses.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  function linux c