single host multiple IP address configuration in Linux

来源:互联网 发布:python 定时循环执行 编辑:程序博客网 时间:2024/05/18 03:03

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.




原创粉丝点击