zoukankan      html  css  js  c++  java
  • 排查电脑的网络问题

    网络是服务器连接外面世界的通道, 即使是内网, 也需要配置好网络
    遇到一台服务器好像dns被污染了, 解析的movie.douban.com的ip地址不正确, 而其他都没有问题

    以下记录排查网络问题的几个方面

    是否可以联网

    首先需要查看网络是否连通
    可以通过ping网关的形式判断网络是否可以连通外界
    如果无法ping通, 通过ip addr 查看ip地址是否配置
    ip addr add 192.168.86.111/24 dev eth0 #给eth0网卡配置ip
    同时可能需要指定网关地址

    启动网卡

    有种可能是网卡现在已经配置ip 但是没有启动
    ip link set eth0 up #启动网卡

    添加dns

    可以ping通网关, 无法ping通域名
    ping www.baidu.com
    这是由于没有配置dns的问题
    编辑/etc/resolv.conf文件
    添加 servername 114.114.114.114 #附录列出常用dns

    添加路由

    可能的情况还有没有配置路由信息
    ip route add default gw 192.168.86.1

    持久化配置

    以上都是临时使用时配置的, 如想开机自动配置, 最简单的是查看局域网有没有dhcp服务器,直接使用dhcp可以方便的上网了
    手动设置需要更改配置文件, 一般是在/etc/network/interface, 需要的信息由网络管理员之前提供

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet static
    address 192.168.86.111
    netmask 255.255.255.0
    network 192.168.86.0
    broadcast 192.168.86.255
    gateway 192.168.86.1
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers 114.114.114.114
    
    up route add-net 10.10.10.10 netmask 255.255.255.255 gw 192.168.86.110 eth0
    

    查询dns可以使用以下两个命令

    nslookup

    其中server可以指定需要的dns服务器, 默认是本机的dns服务器

    nslookup
    > www.baidu.com
    Server:		192.168.75.14
    Address:	192.168.75.14#53
    
    Non-authoritative answer:
    www.baidu.com	canonical name = www.a.shifen.com.
    Name:	www.a.shifen.com
    Address: 115.239.210.27
    Name:	www.a.shifen.com
    Address: 115.239.211.112
    > 
    > server 114.114.114.114
    Default server: 114.114.114.114
    Address: 114.114.114.114#53
    > www.baidu.com
    Server:		114.114.114.114
    Address:	114.114.114.114#53
    
    Non-authoritative answer:
    www.baidu.com	canonical name = www.a.shifen.com.
    Name:	www.a.shifen.com
    Address: 115.239.211.112
    Name:	www.a.shifen.com
    Address: 115.239.210.27
    > 
    > server 223.5.5.5
    Default server: 223.5.5.5
    Address: 223.5.5.5#53
    > www.baidu.com       
    Server:		223.5.5.5
    Address:	223.5.5.5#53
    
    Non-authoritative answer:
    www.baidu.com	canonical name = www.a.shifen.com.
    Name:	www.a.shifen.com
    Address: 115.239.210.27
    Name:	www.a.shifen.com
    Address: 115.239.211.112
    > 
    

    dig

    dig命令功能更加强大
    可以通过 +trace 来追踪路由解析
    示例使用www.baidu.com, 百度应该是使用了cdn, 解析的结果可能比较难理解

    dig www.baidu.com @114.114.114.114 A +trace
    
    ; <<>> DiG 9.8.1-P1 <<>> www.baidu.com @114.114.114.114 A +trace
    ;; global options: +cmd
    .			302116	IN	NS	k.root-servers.net.
    .			302116	IN	NS	h.root-servers.net.
    .			302116	IN	NS	f.root-servers.net.
    .			302116	IN	NS	m.root-servers.net.
    .			302116	IN	NS	c.root-servers.net.
    .			302116	IN	NS	e.root-servers.net.
    .			302116	IN	NS	j.root-servers.net.
    .			302116	IN	NS	a.root-servers.net.
    .			302116	IN	NS	l.root-servers.net.
    .			302116	IN	NS	g.root-servers.net.
    .			302116	IN	NS	i.root-servers.net.
    .			302116	IN	NS	b.root-servers.net.
    .			302116	IN	NS	d.root-servers.net.
    ;; Received 228 bytes from 114.114.114.114#53(114.114.114.114) in 36 ms
    
    com.			172800	IN	NS	a.gtld-servers.net.
    com.			172800	IN	NS	b.gtld-servers.net.
    com.			172800	IN	NS	c.gtld-servers.net.
    com.			172800	IN	NS	d.gtld-servers.net.
    com.			172800	IN	NS	e.gtld-servers.net.
    com.			172800	IN	NS	f.gtld-servers.net.
    com.			172800	IN	NS	g.gtld-servers.net.
    com.			172800	IN	NS	h.gtld-servers.net.
    com.			172800	IN	NS	i.gtld-servers.net.
    com.			172800	IN	NS	j.gtld-servers.net.
    com.			172800	IN	NS	k.gtld-servers.net.
    com.			172800	IN	NS	l.gtld-servers.net.
    com.			172800	IN	NS	m.gtld-servers.net.
    ;; Received 491 bytes from 199.7.83.42#53(199.7.83.42) in 320 ms
    
    baidu.com.		172800	IN	NS	dns.baidu.com.
    baidu.com.		172800	IN	NS	ns2.baidu.com.
    baidu.com.		172800	IN	NS	ns3.baidu.com.
    baidu.com.		172800	IN	NS	ns4.baidu.com.
    baidu.com.		172800	IN	NS	ns7.baidu.com.
    ;; Received 201 bytes from 192.54.112.30#53(192.54.112.30) in 200 ms
    
    www.baidu.com.		1200	IN	CNAME	www.a.shifen.com.
    a.shifen.com.		1200	IN	NS	ns5.a.shifen.com.
    a.shifen.com.		1200	IN	NS	ns1.a.shifen.com.
    a.shifen.com.		1200	IN	NS	ns3.a.shifen.com.
    a.shifen.com.		1200	IN	NS	ns4.a.shifen.com.
    a.shifen.com.		1200	IN	NS	ns2.a.shifen.com.
    ;; Received 228 bytes from 220.181.38.10#53(220.181.38.10) in 23 ms
    

    附录: dns列表

    数据来源: http://www.ip.cn/dns.html

    公共 DNS 服务器 IP 地址

    名称 DNS 服务器 IP 地址
    114 DNS 114.114.114.114 114.114.115.115
    阿里 AliDNS 223.5.5.5 223.6.6.6
    百度 BaiduDNS 180.76.76.76
    DNSPod DNS+ 119.29.29.29 182.254.116.116
    CNNIC SDNS 1.2.4.8 210.2.4.8
    oneDNS 112.124.47.27 114.215.126.16
    DNS 派
    电信/移动/铁通
    101.226.4.6 218.30.118.6
    DNS 派 联通 123.125.81.6 140.207.198.6
    Google DNS 8.8.8.8 8.8.4.4
    OpenDNS 208.67.222.222 208.67.220.220
    V2EX DNS 199.91.73.222 178.79.131.110

    全国各地电信 DNS 服务器 IP 地址

    名称 DNS 服务器 IP 地址
    安徽电信 DNS 61.132.163.68 202.102.213.68
    北京电信 DNS 219.141.136.10 219.141.140.10
    重庆电信 DNS 61.128.192.68 61.128.128.68
    福建电信 DNS 218.85.152.99 218.85.157.99
    甘肃电信 DNS 202.100.64.68 61.178.0.93
    广东电信 DNS 202.96.128.86 202.96.128.166
    202.96.134.33 202.96.128.68
    广西电信 DNS 202.103.225.68 202.103.224.68
    贵州电信 DNS 202.98.192.67 202.98.198.167
    河南电信 DNS 222.88.88.88 222.85.85.85
    黑龙江电信 219.147.198.230 219.147.198.242
    湖北电信 DNS 202.103.24.68 202.103.0.68
    湖南电信 DNS 222.246.129.80 59.51.78.211
    江苏电信 DNS 218.2.2.2 218.4.4.4
    61.147.37.1 218.2.135.1
    江西电信 DNS 202.101.224.69 202.101.226.68
    内蒙古电信 219.148.162.31 222.74.39.50
    山东电信 DNS 219.146.1.66 219.147.1.66
    陕西电信 DNS 218.30.19.40 61.134.1.4
    上海电信 DNS 202.96.209.133 116.228.111.118
    202.96.209.5 108.168.255.118
    四川电信 DNS 61.139.2.69 218.6.200.139
    天津电信 DNS 219.150.32.132 219.146.0.132
    云南电信 DNS 222.172.200.68 61.166.150.123
    浙江电信 DNS 202.101.172.35 61.153.177.196
    61.153.81.75 60.191.244.5

    全国各地联通 DNS 服务器 IP 地址

    名称 DNS 服务器 IP 地址
    北京联通 DNS 202.106.196.115 202.106.46.151
    202.106.0.20 202.106.195.68
    重庆联通 DNS 221.5.203.98 221.7.92.98
    广东联通 DNS 210.21.196.6 221.5.88.88
    河北联通 DNS 202.99.160.68 202.99.166.4
    河南联通 DNS 202.102.224.68 202.102.227.68
    黑龙江联通 202.97.224.69 202.97.224.68
    吉林联通 DNS 202.98.0.68 202.98.5.68
    江苏联通 DNS 221.6.4.66 221.6.4.67
    内蒙古联通 202.99.224.68 202.99.224.8
    山东联通 DNS 202.102.128.68 202.102.152.3
    202.102.134.68 202.102.154.3
    山西联通 DNS 202.99.192.66 202.99.192.68
    陕西联通 DNS 221.11.1.67 221.11.1.68
    上海联通 DNS 210.22.70.3 210.22.84.3
    四川联通 DNS 119.6.6.6 124.161.87.155
    天津联通 DNS 202.99.104.68 202.99.96.68
    浙江联通 DNS 221.12.1.227 221.12.33.227
    辽宁联通 DNS 202.96.69.38 202.96.64.68

    全国各地移动 DNS 服务器 IP 地址

    名称 DNS 服务器 IP 地址
    江苏移动 DNS 221.131.143.69 112.4.0.55
    安徽移动 DNS 211.138.180.2 211.138.180.3
    山东移动 DNS 218.201.96.130 211.137.191.26

    Apple TV DNS 服务器 IP 地址

    名称 DNS 服务器 IP 地址
    上海电信 180.153.225.136
    杭州电信 115.29.189.118
    广东电信 203.195.182.150
    北方联通 118.244.224.124
  • 相关阅读:
    MYSQL profiling分析语句
    进程状态与僵尸进程、孤儿进程
    Nginx跨域设置
    Redis的应用场景
    Nginx的作用
    cgi、fast-cgi和php-fpm的介绍(作用)
    CoreDump开启和Swoole Tracker 3.0配置
    好题总结
    Atcoder总结 Part III
    Atcoder总结 Part II
  • 原文地址:https://www.cnblogs.com/mikeguan/p/6782443.html
Copyright © 2011-2022 走看看