Deepin基本环境查看(三)【网络信息】

Linux操作系统(DeepinUbuntu)操作系统中,有许多shell命令可以用来查看网络信息和网络状态。

下面是常见的命令示例

  1. ifconfig:查看所有网卡的信息(已弃用,推荐使用 ip 命令)
ifconfig
  1. ip 命令:查看所有网卡的信息
* 查看所有接口信息:
ip addr show

# 执行结果
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
......
	
* 查看特定接口(例如enp0s31f6)信息:
ip addr show enp0s31f6
# 执行结果
2: enp0s31f6: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
	    link/ether bb:dd:ff:cc:cc:2d brd ff:ff:ff:ff:ff:ff
	    inet 102.15.15.128/24 brd 102.15.15.255 scope global dynamic noprefixroute enp0s31f6
......
  1. netstat:查看所有监听的TCP和UDP端口
* 查看所有活动的网络连接:
netstat -a
# 执行结果
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:microsoft-ds    0.0.0.0:*               LISTEN 
......

* 查看监听中的端口:
netstat -tuln
# 执行结果
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN
......
  1. ss 命令:netstat 的替代品
* 查看所有活动的网络连接:
ss -a
# 执行结果
Netid    State        Recv-Q    Send-Q  Local Address:Port                    Peer Address:Port                        
nl       UNCONN       0         0       rtnl:avahi-daemon/692                       *                            
nl       UNCONN       0         0       rtnl:code/80234                             *
......
  1. route 命令:查看路由表信息
route -n
# 执行结果
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         102.15.15.1        0.0.0.0         UG    100    0        0 enp0s31f6
102.15.15.0        0.0.0.0         255.255.255.0   U     100    0        0 enp0s31f6
......
  1. ping 命令:检查与目标主机的连接状态
ping www.qq.com
# 执行结果
PING ins-r23tsuuf.ias.tencent-cloud.net (121.14.77.221) 56(84) bytes of data.
64 bytes from 121.14.77.221 (121.14.77.221): icmp_seq=1 ttl=53 time=4.83 ms
64 bytes from 121.14.77.221 (121.14.77.221): icmp_seq=2 ttl=53 time=5.00 ms
  1. traceroute 命令:查看与目标主机之间的路由跳数和状态,可能需要安装
sudo apt-get install traceroute # 安装traceroute
traceroute www.qq.com
# 执行结果
traceroute to www.qq.com (121.14.77.201), 30 hops max, 60 byte packets
 1  _gateway (102.15.15.1)  3.501 ms  3.590 ms  3.696 ms
 2  102.253.0.1 (102.253.0.1)  0.556 ms  0.549 ms  0.542 ms
 ......
  1. nmcliNetworkManager的命令行
* 查看所有连接:
nmcli connection show
# 执行结果
NAME      UUID                                  TYPE      DEVICE    
有线连接  a26866c4-0041-4487-99f8-d9b40af8c15a  ethernet  enp0s31f6 
  1. iwconfig:查看无线网络信息
iwconfig
# 执行结果
lo        no wireless extensions.
enp0s31f6  no wireless extensions.
  1. dig 命令:DNS信息查询
dig www.qq.com
# 执行结果
; <<>> DiG 9.11.5-P4-5.1+dde-Debian <<>> www.qq.com
;; global options: +cmd
;; Got answer:
......
  1. host 命令:简单的DNS地址查询
host www.qq.com
# 执行结果
www.qq.com is an alias for ins-r23tsuuf.ias.tencent-cloud.net.
ins-r23tsuuf.ias.tencent-cloud.net has address 121.14.77.201
ins-r23tsuuf.ias.tencent-cloud.net has address 121.14.77.221
......

上一篇:Deepin基本环境查看(二)【内存】
下一篇:Deepin基本环境查看(四)【硬盘/分区、文件系统、硬连接/软连接】

may the odds be ever in your favor ~

你可能感兴趣的:(#,Deepin使用经验,网络,Deepin,linux,运维)