zoukankan      html  css  js  c++  java
  • linux网络:常用命令(一)

    1.ifconfig  可以查看Linux的网卡情况

    ifconfig eth0 查看 eth0的信息

    给一块网卡设置多个ip地址: ifconfig eth0:0 192.168.1.12 255.255.255.0

    关闭和开启 网卡 ifdown eth0   ifup eth0

    关闭所有网卡使用 /etc/init.d/network restart

    设置网卡永久生效:

    方法1.在CentOS或RHEL(Rad hat)可以使用setup工具 如果未安装可以yum -y instll setup

    方法2.可以直接修改配置文件/etc/sysconfig/network-script/ifcfg-eth0 

    2.netstat 查询网络状态

    netstat [选项]  当然netstat -rn   -r列出路由列表,功能和route命令一致

    -t 列出TCP协议端口 -u 列出udp协议端口  -n 使用ip地址和端口号显示 -l 列出在监听状态网络服务 -a 列出所有的网络链接


     1 [root@localhostA1 ~]# netstat -tuln
     2 Active Internet connections (only servers)
     3 Proto Recv-Q Send-Q Local Address               Foreign Address             State      
     4 tcp        0      0 0.0.0.0:35086               0.0.0.0:*                   LISTEN      
     5 tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      
     6 tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      
     7 tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      
     8 tcp        0      0 0.0.0.0:1992                0.0.0.0:*                   LISTEN      
     9 tcp        0      0 :::111                      :::*                        LISTEN      
    10 tcp        0      0 :::58614                    :::*                        LISTEN      
    11 tcp        0      0 ::1:631                     :::*                        LISTEN      
    12 tcp        0      0 ::1:25                      :::*                        LISTEN      
    13 tcp        0      0 :::1992                     :::*                        LISTEN      
    14 udp        0      0 0.0.0.0:111                 0.0.0.0:*                               
    15 udp        0      0 0.0.0.0:631                 0.0.0.0:*                               
    16 udp        0      0 0.0.0.0:931                 0.0.0.0:*                               
    17 udp        0      0 0.0.0.0:951                 0.0.0.0:*                               
    18 udp        0      0 0.0.0.0:37596               0.0.0.0:*                               
    19 udp        0      0 :::111                      :::*                                    
    20 udp        0      0 :::42503                    :::*                                    
    21 udp        0      0 :::931                      :::*  
    View Code

    netstat -rn 演示

    1 [root@localhostA1 ~]# netstat -rn
    2 Kernel IP routing table
    3 Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    4 192.168.181.0   0.0.0.0         255.255.255.0   U         0 0          0 eth0
    5 169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
    6 0.0.0.0         192.168.181.1   0.0.0.0         UG        0 0          0 eth0
    View Code

    3.route命令查看路由列表(可以查看到网关)

    1 [root@localhostA1 ~]# route -n
    2 Kernel IP routing table
    3 Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    4 192.168.181.0   0.0.0.0         255.255.255.0   U     0      0        0 eth0
    5 169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
    6 0.0.0.0         192.168.181.1   0.0.0.0         UG    0      0        0 eth0
    View Code

    4.nslookup域名解析命令

    nslookup [主机名或ip]

    或者 直接运行nslookup 在回车后输入 server 用来查看你的当前主机的DNS服务器

    这个命令Windows的DOS命令行也是通用的因为他是一条网络协议命令 在一些网络设备上也是通用的例如Cisco路由器上

  • 相关阅读:
    STL源码剖析之_allocate函数
    PAT 1018. Public Bike Management
    PAT 1016. Phone Bills
    PAT 1012. The Best Rank
    PAT 1014. Waiting in Line
    PAT 1026. Table Tennis
    PAT 1017. Queueing at Bank
    STL源码剖析之list的sort函数实现
    吃到鸡蛋好吃,看看是哪只母鸡下的蛋:好用的Sqlite3
    cJSON
  • 原文地址:https://www.cnblogs.com/patf/p/4613105.html
Copyright © 2011-2022 走看看