linux-配置dns-note系列

一、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
    
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Liang_GaRy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值