zoukankan      html  css  js  c++  java
  • linux 网络设备,网卡配置 ,相关

    网络设备,网卡配置:
    Eth0是物理网卡:唯一mac地址,Bcast:广播地址,MAsk:子网掩码,
    Lo:系统自带的回环的ip地址,可以做一些基本的测试应用,比如没有网卡就用127.0.0.1,
    
    root@ubuntu:/# ifconfig ens33 down  (停掉某个网卡,重启操作系统可以起起来)
    root@ubuntu:/# ifconfig ens33 up  (启动某个网卡)
    
    root@ubuntu:/# ifconfig ens33 192.168.115.129   (修改ip地址,临时生效,配置文件才能永久生效)
    root@ubuntu:/# ifconfig ens33 192.168.115.129 netmask 255.255.255.0 (修改子网掩码,临时生效,配置文件才能永久生效)
    
    root@ubuntu:~# hostname  (root是账号,ubuntu是计算机名称)
    ubuntu
    root@ubuntu:~# hostname yaowenpc  (修改主机名称,这只是临时修改,重启后就还原,永久修改要修改配置文件)
    root@yaowenpc:/# 
    DNS:解析域名,计算机没配置dns地址是没法上网的,DNS地址都是由供应商提供的,要手动指定,中国电信中国联通都会提供自己的dns地址,无论怎么上网走的网络都是电信或者联通的,(流浪www.baidu.com需要dns才能到百度服务器)
    root@yaowenpc:/etc# vim resolv.conf  (查看dns配置文件)
    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 127.0.1.1
    nameserver 219.141.136.10  :电信的dns
    nameserver 202.106.0.20  :联通的dns
    ~      
    root@yaowenpc:/etc# ping www.baidu.com
    PING www.a.shifen.com (163.177.151.110) 56(84) bytes of data.
    64 bytes from 163.177.151.110: icmp_seq=1 ttl=128 time=13.9 ms
        
    Curl工具(http工具):
    root@yaowenpc:/etc# curl -v -L www.baidu.com
    * Rebuilt URL to: www.baidu.com/
    *   Trying 163.177.151.109...
    * Connected to www.baidu.com (163.177.151.109) port 80 (#0)
    > GET / HTTP/1.1
    > Host: www.baidu.com
    > User-Agent: curl/7.47.0
    > Accept: */*
    > 
    < HTTP/1.1 200 OK
    < Server: bfe/1.0.8.18
    < Date: Thu, 15 Feb 2018 07:08:53 GMT
    < Content-Type: text/html
    < Content-Length: 2381
    < Last-Modified: Mon, 23 Jan 2017 13:27:57 GMT
    < Connection: Keep-Alive
    < ETag: "588604dd-94d"
    < Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
    < Pragma: no-cache
    < Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
    < Accept-Ranges: bytes
    < 
    <!DOCTYPE html>
    <!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hi           

     # curl http://www.baidu.com >> /yw/baidu.html

    网络测试和测试工具:
    排查网络信息:QQ无法登陆了,邮箱不能使用了,网页打不开了。
    如果自己电脑打不开一个网站,比如:被强了,南北互联(南方使用的是联通,北方使用的电信,导致间断性不能访问)。
    
    Ping是发送数据包到对方主机,
    Ping  网关 (网关是一台能够上网的服务器,通过网关才能够上网),如果有数据包返回,表示电脑和网关是互通的,说明局域网是互通的。
    
    有没有配置dns地址,计算机要上网,需要域名解析,cat /etc/resolv.conf
    root@yaowenpc:/# nslookup  (nslookup验证有没有配置dns地址,dns配置的对不对)
    > www.baidu.com  (nslookup是一个工具用来解析域名,输入www.baidu.com域名)
    Server:        127.0.1.1  (server  127.0.1.1是主dns服务器去解析,有没有www.baidu.com这个域名,有的话就解析出来,没有就去别的dns服务器上查找)
    Address:    127.0.1.1#53    (Address:    127.0.1.1#53,其他dns服务器从1到53上面去查找)
    Non-authoritative answer:  
    www.baidu.com    canonical name = www.a.shifen.com.
    (百度的服务器的另2个名字和ip地址)
    Name:    www.a.shifen.com
    Address: 163.177.151.109
    Name:    www.a.shifen.com
    Address: 163.177.151.110
    
    root@yaowenpc:/# nslookup www.baidu.com
    Server:        127.0.1.1
    Address:    127.0.1.1#53
    Non-authoritative answer:
    www.baidu.com    canonical name = www.a.shifen.com.
    Name:    www.a.shifen.com
    Address: 163.177.151.110
    Name:    www.a.shifen.com
    Address: 163.177.151.109
    
    
    要能够上网:必须有一个ip地址可以跟网关通信,要有域名解析功能dns, cat /etc/resolv.conf。
    
    
    Traceroute是跟踪路由,访问百度需要经过多少个设备。
    root@yaowenpc:/# traceroute www.baidu.com
    traceroute to www.baidu.com (163.177.151.110), 30 hops max, 60 byte packets
     1  192.168.115.2 (192.168.115.2)  0.140 ms  0.056 ms  0.090 ms
     2  * * *
     3  * * *
     4  * * *
     5  * * *
     6  * * *
    
    
    root@yaowenpc:/# netstat -r
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    default         192.168.115.2   0.0.0.0         UG        0 0          0 ens33
    link-local      *               255.255.0.0     U         0 0          0 ens33
    172.17.0.0      *               255.255.0.0     U         0 0          0 docker0
    192.168.115.0   *               255.255.255.0   U         0 0          0 ens33
  • 相关阅读:
    汉语-词语:办法
    汉语-词语:做法
    汉语-词语:说法
    汉语-词语:看法
    汉语-词语:想法
    汉语-词语:音色
    汉语-词语:声纹
    职业:斜杆青年
    汉语-流行词汇:傻白甜
    汉语-词语:慧根(生理学概念)
  • 原文地址:https://www.cnblogs.com/yaowen/p/8449677.html
Copyright © 2011-2022 走看看