解决linux无法访问外网


当前第2页 返回上一页

1、确定设置了域名服务器,没有的话,建议设置Google的公共DNS服务,它应该不会出问题的。

1

2

[root@localhost ~]# cat /etc/resolv.conf

search localdomain

因为我的DNS没有设置,所以导致了ping外网ping不通。将dns添加到该文件中

1

2

3

4

5

[root@localhost ~]# vi /etc/resolv.conf

search localdomain

nameserver 202.98.96.68

nameserver 61.139.2.69

~

2、确保网关已设置

1

2

# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*

/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.40.1

如果未设置, 则通过如下方式增加网关:

1

# route add default gw 192.168.40.1

或者手工编写/etc/sysconfig/network-scripts/ifcfg*文件后, 重启network服务:

1

# service network restart

3、确保可用dns解析

1

2

# grep hosts /etc/nsswitch.conf

hosts:      files dns

如果以上哪个有问题,修正后,再测试,应该就没问题了:

1

2

3

4

5

6

7

8

#ping -c 3 www.baidu.com

PING www.a.shifen.com (220.181.6.175) 56(84) bytes of data.

64 bytes from 220.181.6.175: icmp_seq=0 ttl=50 time=9.51 ms

64 bytes from 220.181.6.175: icmp_seq=1 ttl=50 time=8.45 ms

64 bytes from 220.181.6.175: icmp_seq=2 ttl=50 time=8.97 ms

--- www.a.shifen.com ping statistics ---

3 packets transmitted, 3 received, 0% packet loss, time 2002ms

rtt min/avg/max/mdev = 8.450/8.977/9.511/0.446 ms, pipe 2

相关文章教程推荐:linux教程

以上就是解决linux无法访问外网的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

Linux怎么进入root权限

Linux中如何查看数据库

Linux系统中如何添加路由

Linux中inode用法教程

Linux中sed命令和awk命令的使用方法

Linux中.sh文件怎么执行

Linux怎么下载安装软件?

在运维过程中怎么对Linux进行基本操作

实例所在物理机的本地存储:本地 ssd 盘

如何使用访问控制 ram 授权访问 ecs 实例和api 的鉴权规则

更多相关阅读请进入《Linux》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...