一、linux下配置dns
-
什么是dns?
如果服务器需要上外网,这个dns就得配,用来解析域名的
-
修改/etc/resolv.conf这个文件
[root@master7 ~]# vim /etc/resolv.conf # Generated by NetworkManager nameserver 114.114.114.114
-
使用echo命令
[root@master7 ~]# cat /etc/resolv.conf # Generated by NetworkManager nameserver 114.114.114.114 nameserver 8.8.8.8
-
配置/etc/sysconfig/network-scripts/ifcfg-eth0
[root@master7 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=Ethernet BOOTPROTO=static NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=192.168.117.35 PREFIX=24 GATEWAY=192.168.117.2 DNS1=114.114.114.114
- 这里注意大小写,最好是DNS1=XXXXX,小写可能是不生效的。
- 修改过后重启网卡
-
实验
[root@master7 ~]# ping -c 3 -i 0.1 www.baidu.com PING www.a.shifen.com (182.61.200.7) 56(84) bytes of data. 64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=1 ttl=128 time=46.3 ms 64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=2 ttl=128 time=47.3 ms 64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=3 ttl=128 time=47.2 ms --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 212ms rtt min/avg/max/mdev = 46.349/46.974/47.312/0.476 ms [root@master7 ~]# ping -c 3 -i 0.1 www.baidu.com ping: www.baidu.com: Name or service not known
二、命令
-
ping 命令,检测网络的联通行
- -c:指定检测多少次
- -i:自定间隔多少时间ping一次
[root@master7 ~]# ping -c 3 -i 0.1 www.baidu.com PING www.a.shifen.com (182.61.200.7) 56(84) bytes of data. 64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=1 ttl=128 time=46.3 ms 64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=2 ttl=128 time=47.3 ms 64 bytes from 182.61.200.7 (182.61.200.7): icmp_seq=3 ttl=128 time=47.2 ms --- www.a.shifen.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 212ms rtt min/avg/max/mdev = 46.349/46.974/47.312/0.476 ms