您的位置:首页 > 理论基础 > 计算机网络

网络基础管理

2020-02-01 20:01 519 查看

网络基础管理

1.ip

  • 命令名称: ip link show

作用:查看网络接口所有地址

实例:

[root@localhost network-scripts]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
  • 命令名称: ip -s link show

作用:显示报文的统计信息

实例:

[root@localhost network-scripts]# ip -s link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
RX: bytes  packets  errors  dropped overrun mcast
352        4        0       0       0       0
TX: bytes  packets  errors  dropped carrier collsns
352        4        0       0       0       0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
RX: bytes  packets  errors  dropped overrun mcast
8195791    11348    0       0       0       0
TX: bytes  packets  errors  dropped carrier collsns
1060520    5966     0       0       0       0
  • 命令名称:ip link set lo down和 ip link set lo up

作用:禁用和启用网络接口lo

实例:

[root@localhost network-scripts]# ip link set lo down
[root@localhost network-scripts]# ip link show
1: lo: <LOOPBACK> mtu 65536 qdisc noqueue state DOWN mode DEFAULT qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
[root@localhost network-scripts]# ip link set lo up
[root@localhost network-scripts]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
  • 命令名称:ip a

作用:查看网络接口的ip地址

实例:

[root@localhost network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
inet 192.168.100.128/24 brd 192.168.100.255 scope global dynamic eth0
valid_lft 2588947sec preferred_lft 2588947sec
inet6 fe80::f412:3a46:cc20:22d/64 scope link
valid_lft forever preferred_lft forever
  • 命令名称:ip addr add 192.168.100.22/24 dev eth0

作用:添加ip地址到设备eth0里

实例:

[root@localhost network-scripts]# ip addr add 192.168.100.22/24 dev eth0
[root@localhost network-scripts]# ip a s eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
inet 192.168.100.128/24 brd 192.168.100.255 scope global dynamic eth0
valid_lft 2588634sec preferred_lft 2588634sec
inet 192.168.100.22/24 scope global secondary eth0
valid_lft forever preferred_lft forever
inet6 fe80::f412:3a46:cc20:22d/64 scope link
valid_lft forever preferred_lft forever
  • 命令名称:ip addr del 192.168.100.22/24 dev eth0

作用:删除设备eth的ip地址

实例:

[root@localhost network-scripts]# ip addr del 192.168.100.22/24 dev eth0
[root@localhost network-scripts]# ip a  s dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
inet 192.168.100.128/24 brd 192.168.100.255 scope global dynamic eth0
valid_lft 2588481sec preferred_lft 2588481sec
inet6 fe80::f412:3a46:cc20:22d/64 scope link
valid_lft forever preferred_lft forever

2.route

  • 命令名称:route -n

作用:查看当前路由表的相关信息并以数字方式显示

实例:

[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.2   0.0.0.0         UG    100    0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     100    0        0 eth0
  • 命令名称:route add -net 100.1.1.0/24 gw 192.168.100.2 dev eth0

作用:添加一条到100.1.1.0/24网段网关是192.168.100.2的路由

实例:

[root@localhost network-scripts]# route add -net 100.1.1.0/24 gw 192.168.100.2 dev eth0
[root@localhost network-scripts]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.100.2   0.0.0.0         UG    100    0        0 eth0
100.1.1.0       192.168.100.2   255.255.255.0   UG    0      0        0 eth0
192.168.100.0   0.0.0.0         255.255.255.0   U     100    0        0 eth0
  • 命令名称:route del -net 100.1.1.0/24

作用:删除到100.1.1.0/24的路由

实例:

[root@localhost network-scripts]# route del -net 100.1.1.0/24

3.网络接口配置文件

网络接口即网卡,其配置文件的路径是/etc/sysconfig/network-scripts/ifcfg-INTERFACE_NAME

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
NAME=eth1
UUID=03be31f5-a3c1-4f8d-88b3-aea6e85c869f
DEVICE=eth1
ONBOOT=yes
IPADDR=172.16.12.130
NETMASK=255.255.255.0
GATEWAY=172.16.12.2
DNS1=172.16.12.2

//网卡配置说明
//参数                    说明
BOOTPROTO=none          //引导协议,可选值有{static|none|dhcp|bootp}。如果要使用静态地址,使用static或none都可以
NM_CONTROLLED           //NM是NetworkManager的简写,NM是由RHEL研发的在RHEL6中取代network脚本来实现网络管理、配置的服务脚本
//可选值有{ yes | no }
//此项是设定此网卡是否接受NM控制。CentOS6建议设为“no”
TYPE                    //接口类型。常见的接口类型有:Ethernet,Bridge
UUID                    //设备的惟一标识
HWADDR                  //硬件地址,要与硬件中的地址保持一致,可省
IPADDR=172.16.12.130    //固定IP地址
PREFIX=24               //子网掩码
NETMASK=255.255.255.0   //子网掩码
GATEWAY=172.16.12.2     //默认网关
DNS1=172.16.12.2        //第一个DNS服务器指向
DNS2                    //第二个DNS服务器指向
DNS3                    //第三个DNS服务器指向
DEVICE=eth1             //关联的设备名称,要与文件名的后半部"INTERFACE_NAME"保持一致
NAME="eth1"             //连接名称
ONBOOT=yes              //在系统引导时是否自动激活此网络接口,可选值有{ yes | no }
DEFROUTE=yes            //将接口设定为默认路由[yes|no]
USERCTL={yes|no}        //是否允许普通用户控制此接口的启用与禁用
PEERDNS={yes|no}        //是否在BOOTPROTO为dhcp时接受由dhcp服务器指定的DNS地址,此项设为yes时获得的DNS地址将直接覆盖至/etc/resolv.conf文件中

4.NetworkManager管理网络

  • 命令名称:network-scripts]# nmcli dev

作用:查看设备状态

实例:

[root@localhost network-scripts]# nmcli dev
设备  类型      状态    连接
eth0  ethernet  连接的  eth0
lo    loopback  未托管  --
  • 命令名称: nmcli dev show eth0

作用:查看设定设备的详细状态

实例:

[root@localhost network-scripts]# nmcli dev show eth0
GENERAL.设备:                           eth0
GENERAL.类型:                           ethernet
GENERAL.硬盘:                           00:0C:29:54:2B:8B
GENERAL.MTU:                            1500
GENERAL.状态:                           100 (连接的)
GENERAL.连接:                           eth0
GENERAL.连接路径:                       /org/freedesktop/NetworkManager/ActiveConnection/10
WIRED-PROPERTIES.载波:                  开
IP4.地址[1]:                            192.168.100.128/24
IP4.网关:                               192.168.100.2
IP4.DNS[1]:                             8.8.8.8
IP4.DNS[2]:                             114.114.114.114
IP6.网关:                               --

5.使用原生的network管理网络

//设置NetworkManger开机不启动, 同时停止NetworkManger服务
[root@localhost ~]# systemctl disable NetworkManager
[root@localhost ~]# systemctl stop NetworkManager

//添加一块物理网卡, 然后新增网络连接配置文件
//复制配置eth0配置文件为eth1
[root@localhost ~]# cp /etc/sysconfig/network-scripts/{ifcfg-eth0,ifcfg-eth1}

//编辑网卡配置文件
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
NAME=eth1
UUID=03be31f5-a3c1-4f8d-88b3-aea6e85c869f
DEVICE=eth1
NM_CONTROLLED=no
ONBOOT=yes
IPADDR=172.16.12.130
NETMASK=255.255.255.0
GATEWAY=172.16.12.2
DNS1=172.16.12.2

//重启network网络服务加载网络并设置开机启动
[root@localhost ~]# systemctl restart network
[root@localhost ~]# systemctl enable network

6.ping

  • 命令名称:ping -c 3 -i 3 www.baidu.com

作用://ping命令常用选项:
-c 指定ping的次数
-i 指定ping包的发送间隔
-w 如果ping没有回应, 则在指定超时时间后退出

实例:

[root@localhost network-scripts]# ping -c 3 -i 3 www.baidu.com
PING www.a.shifen.com (182.61.200.7) 56(84) bytes of data.
64 bytes from localhost (182.61.200.7): icmp_seq=1 ttl=128 time=31.1 ms
64 bytes from localhost (182.61.200.7): icmp_seq=2 ttl=128 time=38.6 ms
64 bytes from localhost (182.61.200.7): icmp_seq=3 ttl=128 time=28.0 ms

--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 6008ms
rtt min/avg/max/mdev = 28.007/32.587/38.607/4.450 ms

7.host与nslookup

  • 命令名称:host www.baidu.com

作用:用于查询dns记录

实例:

[root@localhost network-scripts]# host www.baidu.com
www.baidu.com is an alias for www.a.shifen.com.
www.a.shifen.com has address 182.61.200.7
www.a.shifen.com has address 182.61.200.6
  • 命令名称: nslookup www.baidu.com

作用:用于查询dns记录

实例:

[root@localhost network-scripts]# nslookup www.baidu.com
Server:		8.8.8.8
Address:	8.8.8.8#53

Non-authoritative answer:
www.baidu.com	canonical name = www.a.shifen.com.
Name:	www.a.shifen.com
Address: 182.61.200.6
Name:	www.a.shifen.com
Address: 182.61.200.7
  • 命令名称:traceroute www.baidu.com

作用:命令用于路由跟踪, 检测网络故障出现在ISP运营商或是对端服务无法响应

实例:

[root@localhost network-scripts]# traceroute www.baidu.com
traceroute to www.baidu.com (182.61.200.6), 30 hops max, 60 byte packets
1  gateway (192.168.100.2)  0.255 ms  0.195 ms  0.193 ms
2  * * *
3  * * *
4  * * *
5  * * *
6  * * *
7  * * *

8.ss

  • 命令名称:ss -a

作用:查看所有套接字

实例:

[root@localhost network-scripts]# ss -a
Netid  State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
nl     UNCONN     0      0         rtnl:kernel                      *
nl     UNCONN     0      0         rtnl:-188742867                  *
nl     UNCONN     0      0         rtnl:-188742867                  *
nl     UNCONN     4352   0      tcpdiag:ss/6094                     *
nl     UNCONN     768    0      tcpdiag:kernel                      *
nl     UNCONN     0      0         xfrm:kernel                      *
nl     UNCONN     0      0      selinux:systemd/1                   *
nl     UNCONN     0      0      selinux:dbus-daemon/767             *
nl     UNCONN     0      0      selinux:kernel                      *
nl     UNCONN     0      0      selinux:dbus-daemon/767             *
nl     UNCONN     0      0      selinux:systemd/1                   *
nl     UNCONN     0      0        audit:kernel                      *
nl     UNCONN     0      0        audit:auditd/5887                 *
  • 命令名称:ss -t

作用:与tcp协议相关

实例:

[root@localhost network-scripts]# ss -t
State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
ESTAB      0      52     192.168.100.128:ssh                  192.168.100.1:guibase
  • 命令名称:ss -u

作用:与udp协议相关的套接字

实例:

[root@localhost network-scripts]# ss -u
Recv-Q Send-Q   Local Address:Port                    Peer Address:Port
  • 命令名称:ss -l

作用:查看listen状态(监听状态)

实例:

[root@localhost network-scripts]# ss -l
Netid  State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
nl     UNCONN     0      0         rtnl:kernel                      *
nl     UNCONN     0      0         rtnl:-188742867                  *
nl     UNCONN     0      0         rtnl:-188742867                  *
nl     UNCONN     4352   0      tcpdiag:ss/6101                     *
nl     UNCONN     768    0      tcpdiag:kernel                      *
nl     UNCONN     0      0         xfrm:kernel                      *
nl     UNCONN     0      0      selinux:systemd/1                   *
nl     UNCONN     0      0      selinux:dbus-daemon/767             *
nl     UNCONN     0      0      selinux:kernel                      *
nl     UNCONN     0      0      selinux:dbus-daemon/767             *
nl     UNCONN     0      0      selinux:systemd/1                   *
nl     UNCONN     0      0        audit:kernel                      *
nl     UNCONN     0      0        audit:auditd/5887                 *
nl     UNCONN     0      0        audit:systemd/1                   *
nl     UNCONN     0      0      fiblookup:kernel                      *
nl     UNCONN     0      0      connector:kernel                      *
  • 命令名称:ss -n

作用:查看套接字的端口以数字显示

实例:

[root@localhost network-scripts]# ss -n
Netid  State      Recv-Q Send-Q Local Address:Port               Peer Address:Port
u_str  ESTAB      0      0              * 19938                      * 19939
u_str  ESTAB      0      0              * 18864                      * 16761
u_str  ESTAB      0      0              * 19942                      * 19943
u_str  ESTAB      0      0              * 19948                      * 19949
u_str  ESTAB      0      0      /run/systemd/journal/stdout 16663                      * 17603
u_str  ESTAB      0      0      /var/run/dbus/system_bus_socket 16632                      * 15748
u_str  ESTAB      0      0              * 19945                      * 19946
u_str  ESTAB      0      0              * 17603                      * 16663
u_str  ESTAB      0      0      /var/run/dbus/system_bus_socket 16761                      * 18864
u_str  ESTAB      0      0              * 19973                      * 19972
u_str  ESTAB      0      0              * 19943                      * 19942
u_str  ESTAB      0      0              * 19972                      * 19973
u_str  ESTAB      0      0              * 19936                      * 19935
u_str  ESTAB      0      0              * 19954                      * 19955
u_str  ESTAB      0      0              * 19961                      * 19960
u_str  ESTAB      0      0              * 19960                      * 19961
  • 命令名称:ss -p

作用:查看相关的程序及pid

实例:

[root@localhost network-scripts]# ss -p
Netid  State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
u_str  ESTAB      0      0            * 19938                      * 19939                 users:(("master",pid=1363,fd=26))
u_str  ESTAB      0      0            * 18864                      * 16761                 users:(("NetworkManager",pid=813,fd=13))
u_str  ESTAB      0      0            * 19942                      * 19943                 users:(("master",pid=1363,fd=30))
u_str  ESTAB      0      0            * 19948                      * 19949                 users:(("master",pid=1363,fd=36))
u_str  ESTAB      0      0      /run/systemd/journal/stdout 16663                      * 17603                 users:(("systemd-journal",pid=590,fd=21))
u_str  ESTAB      0      0      /var/run/dbus/system_bus_socket 16632                      * 15748                 users:(("dbus-daemon",pid=767,fd=10))
u_str  ESTAB      0      0            * 19945                      * 19946                 users:(("master",pid=1363,fd=33))
u_str  ESTAB      0      0            * 17603                      * 16663                 users:(("vmtoolsd",pid=780,fd=2),("vmtoolsd",pid=780,fd=1))
u_str  ESTAB      0      0      /var/run/dbus/system_bus_socket 16761                      * 18864                 users:(("dbus-daemon",pid=767,fd=18))
u_str  ESTAB      0      0            * 19973                      * 19972

9.作业

1.如何查看系统中每个ip的连接数

[root@localhost network-scripts]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:54:2b:8b brd ff:ff:ff:ff:ff:ff
inet 192.168.100.128/24 brd 192.168.100.255 scope global dynamic eth0
valid_lft 2589667sec preferred_lft 2589667sec
inet6 fe80::f412:3a46:cc20:22d/64 scope link
valid_lft forever preferred_lft forever

2.请列出下列服务使用的端口,http,ftp,ssh,telnet,mysql,dns

http=80/tcp
https=443/tcp
ftp=20,21/tcp
ssh=22/tcp
telent=23/tcp
mysql(mysql数据库)=3306
rsync(远程同步) =873/rsync
redis(redis数据库) =6379/tcp
dns=53/udp

3.如何在虚拟机上新增加一块网卡,并配置IP为172.16.0.10,指定网关为172.16.0.1

[root@localhost network-scripts]# ls
ifcfg-eth0   ifdown-isdn      ifdown-tunnel  ifup-isdn    ifup-Team
ifcfg-lo     ifdown-post      ifup           ifup-plip    ifup-TeamPort
ifdown       ifdown-ppp       ifup-aliases   ifup-plusb   ifup-tunnel
ifdown-bnep  ifdown-routes    ifup-bnep      ifup-post    ifup-wireless
ifdown-eth   ifdown-sit       ifup-eth       ifup-ppp     init.ipv6-global
ifdown-ippp  ifdown-Team      ifup-ippp      ifup-routes  network-functions
ifdown-ipv6  ifdown-TeamPort  ifup-ipv6      ifup-sit     network-functions-ipv6
[root@localhost network-scripts]# cp /etc/sysconfig/network-scripts/{ifcfg-eth0,ifcfg-eth1}
[root@localhost network-scripts]# ls
ifcfg-eth0   ifdown-isdn      ifup          ifup-plusb     ifup-wireless
ifcfg-eth1   ifdown-post      ifup-aliases  ifup-post      init.ipv6-global
ifcfg-lo     ifdown-ppp       ifup-bnep     ifup-ppp       network-functions
ifdown       ifdown-routes    ifup-eth      ifup-routes    network-functions-ipv6
ifdown-bnep  ifdown-sit       ifup-ippp     ifup-sit
ifdown-eth   ifdown-Team      ifup-ipv6     ifup-Team
ifdown-ippp  ifdown-TeamPort  ifup-isdn     ifup-TeamPort
ifdown-ipv6  ifdown-tunnel    ifup-plip     ifup-tunnel

[root@localhost network-scripts]# vi ifcfg-eth1
[root@localhost network-scripts]# cat ifcfg-eth1
TYPE=Ethernet
BOOTPROTO=static
NAME=eth1
UUID=9ce7fa00-8401-4088-a330-49d16236b0c3
DEVICE=eth1
NM_CONTROLLED=no
ONBOOT=yes
IPADDR=172.16.0.10
NETMASK=255.255.255.0
GATEWAY=172.16.0.1
DNS1=8.8.8.8

[root@localhost ~]# systemctl restart network
[root@localhost ~]# systemctl enable network

4.详细描述dns解析过程,以访问www.baidu.com为例

5.如何查看系统中运行了多少个进程

[root@localhost network-scripts]# ss -a
Netid State      Recv-Q Send-Q                                                      Local Address:Port                                                                       Peer Address:Port
nl    UNCONN     0      0                                                                    rtnl:kernel                                                                                 *
nl    UNCONN     0      0                                                                    rtnl:-188742867                                                                             *
nl    UNCONN     0      0                                                                    rtnl:-188742867                                                                             *
nl    UNCONN     768    0                                                                 tcpdiag:kernel                                                                                 *
nl    UNCONN     4352   0                                                                 tcpdiag:ss/2612                                                                                *
nl    UNCONN     0      0                                                                    xfrm:kernel                                                                                 *
nl    UNCONN     0      0                                                                 selinux:systemd/1                                                                              *
nl    UNCONN     0      0                                                                 selinux:dbus-daemon/767                                                                        *
nl    UNCONN     0      0                                                                 selinux:kernel                                                                                 *
nl    UNCONN     0      0                                                                 selinux:dbus-daemon/767                                                                        *
nl    UNCONN     0      0                                                                 selinux:systemd/1                                                                              *
nl    UNCONN     0      0                                                                   audit:kernel                                                                                 *
nl    UNCONN     0      0                                                                   audit:systemd/1                                                                              *
nl    UNCONN     0      0                                                                   audit:auditd/743                                                                             *
nl    UNCONN     0      0                                                               fiblookup:kernel                                                                                 *
nl    UNCONN     0      0                                                               connector:kernel                                                                                 *
nl    UNCONN     0      0                                                                     nft:kernel                                                                                 *
nl    UNCONN     0      0                                                                  uevent:systemd-logind/781                                                                     *
nl    UNCONN     0      0                                                                  uevent:tuned/1129                                                                             *
nl    UNCONN     0      0                                                                  uevent:NetworkManager/813                                                                     *
nl    UNCONN     0      0                                                                  uevent:systemd/1                                                                              *
nl    UNCONN     0      0                                                                  uevent:-4130                                                                                  *
nl    UNCONN     0      0                                                                  uevent:-4132                                                                                  *
nl    UNCONN     0      0                                                                  uevent:-4131                                                                                  *
nl    UNCONN     0      0                                                                  uevent:-4113

6.如何查看系统中启动了哪些端口

[root@localhost network-scripts]# ss -an
Netid State      Recv-Q Send-Q                                                        Local Address:Port                                                                       Peer Address:Port
nl    UNCONN     0      0                                                                         0:0                                                                                      *
nl    UNCONN     0      0                                                                         0:-188742867                                                                             *
nl    UNCONN     0      0                                                                         0:-188742867                                                                             *
nl    UNCONN     768    0                                                                         4:0                                                                                      *
nl    UNCONN     4352   0                                                                         4:2610                                                                                   *
nl    UNCONN     0      0                                                                         6:0                                                                                      *
nl    UNCONN     0      0                                                                         7:1                                                                                      *

7.如何查看是否开启80端口,及查看sshd进程是否存在

[root@localhost network-scripts]# ss -ant|grep 80

[root@localhost network-scripts]# ss -ap|grep sshd
u_dgr  UNCONN     0      0       * 23919                 * 2892                  users:((sshd",pid=1836,fd=4))
u_str  ESTAB      0      0       * 20547                 * 19589                 users:((sshd",pid=1127,fd=2),("sshd",pid=1127,fd=1))
tcp    LISTEN     0      128     *:ssh                   *:*                     users:((sshd",pid=1127,fd=3))
tcp    ESTAB      0      0      192.168.100.128:ssh                  192.168.100.1:infowave              users:(("sshd",pid=1836,fd=3))
tcp    LISTEN     0      128    :::ssh                  :::*                     users:((sshd",pid=1127,fd=4))

8.列出所有处于监听状态的tcp端口

[root@localhost network-scripts]# ss -tanl
State      Recv-Q Send-Q Local Address:Port               Peer Address:Port
LISTEN     0      128               *:22                            *:*
LISTEN     0      100       127.0.0.1:25                            *:*
LISTEN     0      128              :::22                           :::*
LISTEN     0      100             ::1:25                           :::*

9.查看所有的端口信息, 包括 PID 和进程名称

[root@localhost network-scripts]# ss -atp
State      Recv-Q Send-Q Local Address:Port                 Peer Address:Port
LISTEN     0      128             *:ssh                           *:*                     users:(("sshd",pid=1127,fd=3))
LISTEN     0      100     127.0.0.1:smtp                          *:*                     users:(("master",pid=1363,fd=13))
ESTAB      0      52     192.168.100.128:ssh                  192.168.100.1:infowave              users:(("sshd",pid=1836,fd=3))
LISTEN     0      128            :::ssh                          :::*                     users:(("sshd",pid=1127,fd=4))
LISTEN     0      100           ::1:smtp                         :::*                     users:(("master",pid=1363,fd=14))
  • 点赞
  • 收藏
  • 分享
  • 文章举报
Zhangrl_ 发布了25 篇原创文章 · 获赞 1 · 访问量 630 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: