Networking

dhclient.conf 在 centos 上失去

  • January 15, 2016

在 centos 6 上,我需要從 dhcp 伺服器獲取值:

cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
HWADDR=00:50:56:27:0E:C8
TYPE=Ethernet
UUID=20924b21-e92a-4944-a054-06d1967155c1
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
PEERDNS=yes 

dhclient 只接受 IP(不是 gw,不是 dns,不是主機名)。

沒有任何 dhclient.conf 甚至沒有範例文件。

創造

/etc/dhcp/dhclient-eth0.conf

並把這些行:

send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;

ifdown eth0
ifup eth0

如果您不想要網關/路由器:-

請求子網遮罩、廣播地址、時間偏移量、
介面人;

引用自:https://serverfault.com/questions/672845