CentOS 6不能ping通域名解决方法

1,配置网口IP

查看网口信息

[root@localhost ~]#ifconfig

[root@localhost ~]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:1A:4C:5F  
          inet addr:192.168.11.128  Bcast:192.168.11.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe1a:4c5f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:832 errors:0 dropped:0 overruns:0 frame:0
          TX packets:345 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:60862 (59.4 KiB)  TX bytes:54382 (53.1 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:20 errors:0 dropped:0 overruns:0 frame:0
          TX packets:20 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1168 (1.1 KiB)  TX bytes:1168 (1.1 KiB)

[root@localhost ~]#

打开对应网络接口的配置文件

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:0C:29:1A:4C:5F
IPV6INIT=yes
ONBOOT=yes
TYPE=Ethernet
UUID="f6f697bb-1a41-4c6d-9174-ec90c51e705a"
NM_CONTROLLED=no
MTU=1500
DNS1=8.8.8.8 #添加DNS地址
USERCTL=no
PEERDNS=no #防止网口在使用 static/no的情况下,重启network服务导致文件/ect/resolve.conf重新修改

2,文件/ect/resolve.conf中配置DNS

; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.11.2

nameserver 8.8.8.8

3,修改文件  /etc/nsswitch.conf

[root@localhost ~]# vim /etc/nsswitch.conf

修改hosts:如下行所示。

hosts:      files  dns

4,重启网络服务

[root@localhost ~]# service network restart

5, 测试ping成功

[root@localhost ~]# ping www.baidu.com
PING www.wshifen.com (103.235.46.39) 56(84) bytes of data.
64 bytes from 103.235.46.39: icmp_seq=1 ttl=128 time=343 ms
64 bytes from 103.235.46.39: icmp_seq=2 ttl=128 time=341 ms
64 bytes from 103.235.46.39: icmp_seq=3 ttl=128 time=342 ms
64 bytes from 103.235.46.39: icmp_seq=4 ttl=128 time=342 ms
^C
--- www.wshifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3687ms
rtt min/avg/max/mdev = 341.933/342.672/343.179/0.747 ms
[root@localhost ~]#

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值