前面一篇文章已经讨论过如何基于bind和dhcpd搭建ddns服务器。Ddns可以将一个静态的域名与一个基于dhcp动态分配的IP地址相对应,这样服务的使用者就可以通过域名(FQDN)访问服务器,而不必关心服务器的IP地址是否已经发生了变化。如果服务器上含有多个网卡,而每个网卡上都提供不同的服务,那么多个FQDN就成为一种需要。每个网卡在向dhcp服务器获取IP地址时,分别发送不同的host name给dhcp服务器,这样就可以实现多个网卡多个FQDN。
(1)Ubuntu下的配置
修改/etc/dhcp3/dhclient.conf,添加下面两行
interface "eth0"{ send host-name "example1"; } interface "eth4"{ send host-name "example2"; }
然后sudo dhclient3重新获得IP地址之后就可以通过example1.*.*和example2.*.*分别访问到eth0和eth4。
(2)suse下的配置
在/etc/sysconfig/network/dhcp中有下面一段话
## Type: string ## Default: AUTO # # specify a hostname to send ( -h option) # # specifies a string used for the hostname option field when dhcpcd sends DHCP # messages. Some DHCP servers will update nameserver entries (dynamic DNS). # Also, some DHCP servers, notably those used by @Home Networks, require the # hostname option field containing a specific string in the DHCP messages from # clients. # # By default the current hostname is sent ("AUTO"), if one is defined in # /etc/HOSTNAME. # Use this variable to override this with another hostname, or leave empty # to not send a hostname. # DHCLIENT_HOSTNAME_OPTION="AUTO"
编辑相应的/etc/sysconfig/network/ifcfg-eth[N], 添加DHCLIENT_HOSTNAME_OPTION="example[N]",然后重启网络服务即可。