linux修改成静态Ip 后无法联网

Ø  修改/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

HWADDR=00:0C:29:93:01:A4

ONBOOT=yes

BOOTPROTO=static

IPADDR=192.168.1.31

NETMASK=255.255.255.0

GATEWAY=192.168.1.253

 

注意:1.mac地址不能修改,

2.bootproto设置成static

 

Ø  修改/etc/resolv.conf

# DNS1=xxx.xxx.xxx.xxx

# DNS2=xxx.xxx.xxx.xxx

# DOMAIN=lab.foo.com bar.foo.com

dns 192.168.1.253

 

nameserver 10.0.0.1

nameserver 192.168.1.253

 

dns 为主机的默认网关,通过 ipconfig

 

主机ipconfig

无线局域网适配器 WLAN:

 

   连接特定的 DNS 后缀 . . . . .. . :

   本地链接 IPv6 地址. . . . . .. . : fe80::3831:e8e7:

  IPv4 地址 . . . . . . . . . . . . : 192.168.1.101

   子网掩码  . . . . . . . . . . . . : 255.255.255.0

   默认网关. . . . . . . . .. . . . : 192.168.1.253

 

也可通过在dhcp模式下得到的值

使用dhcp时执行
ifconfig
route -n
cat /etc/resolv.conf
然后使用静态地址时把你看到的网关、dns、ip所在网段都设置正确

 

注意:/etc/resolv.conf文件中的内容在service network restart 后会重新生成,

所有设置后不要执行service network restart 或重启

 

 

Ø  vmware设置成桥接模式

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章