目前服务器外网网卡是关闭状态。执行ifconfig命令如下:
[root@appserv3 lala]# ifconfig
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet xx.xx.xx.xx netmask 255.255.255.0 broadcast xx.xx.xx.xx
inet6 xxxx::xxxx:xxxx:xxxx:xxxx prefixlen 64 scopeid 0x20<link>
ether xx:xx:xx:xx:xx:xx txqueuelen 1000 (Ethernet)
RX packets 59294369 bytes 19475249493 (18.1 GiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 48539353 bytes 11472370873 (10.6 GiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
device interrupt 50
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1 (Local Loopback)
RX packets 9648082 bytes 575069270 (548.4 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9648082 bytes 575069270 (548.4 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
而在该情况下ping外网是ping不通的,如ping www.baidu.com,提示connect: network is unreachable。
后来在/etc/resolv.conf文件中加了一个nameserver配置信息后,再次ping时提示
PING www.a.shifen.com (61.135.169.125) 56(84) bytes of data.
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 0 received, 100% packet loss, time 2999ms
请问如何解决该问题使得在外网网卡关闭情况下成功访问外网呢?
你这都
100% loss
了,哪里成功访问外网
了?你这指定的 nameserver 应该是个内网的 DNS 服务器吧?ping 的时候域名会先经过 DNS 解析成 IP,然后 ICMP 这个 IP。
第一步 DNS 解析肯定是通的啊,你这都有一个内网的 DNS 服务器了;第二步 ICMP 挂了啊,都没外网网卡,当然访问不到外网啊。