在 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,甚至没有示例文件。
答案1
创造
/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
答案2
如果你不需要网关/路由器:-
请求子网掩码、广播地址、时间偏移, 接口mtu;