linux查看网络|查看端口|查看路由|查看ip

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6

目录

1、ping 测试目的主机是否连通

2、 测试目的主机端口的联通性

【1】telnet

【2】ssh 

【3】curl 

【4】wget 

3、查看本机网络

【1】ifconfig

【2】ip add

【3】hostname -I

4、查看路由

【1】netstat -rn

【2】route -n

【3】ip route


1、ping 测试目的主机是否连通

[root@localhost ~]# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=114 time=119 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=114 time=95.8 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=114 time=65.2 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=114 time=165 ms
^C
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3026ms
rtt min/avg/max/mdev = 65.272/111.340/165.082/36.441 ms

2、 测试目的主机端口的联通性

【1】telnet

  • 下面说明192.168.43.88的22端口开放
[root@localhost ~]# telnet 192.168.43.88 22
Trying 192.168.43.88...
Connected to 192.168.43.88.
Escape character is '^]'.
SSH-2.0-OpenSSH_7.4
  • 下面说明192.168.43.88的8080端口不开放
[root@localhost ~]# telnet 192.168.43.88 8080
Trying 192.168.43.88...
telnet: connect to address 192.168.43.88: Connection refused

【2】ssh 

  • 下面说明192.168.43.88的22端口开放
[root@localhost ~]# ssh -v -p 22 192.168.43.88 
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.43.88 [192.168.43.88] port 22.
debug1: Connection established.
  • 下面说明192.168.43.88的8080端口不开放
[root@localhost ~]# ssh -v -p 8080 192.168.43.88
OpenSSH_7.4p1, OpenSSL 1.0.2k-fips  26 Jan 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for *
debug1: Connecting to 192.168.43.88 [192.168.43.88] port 8080.
debug1: connect to address 192.168.43.88 port 8080: Connection refused
ssh: connect to host 192.168.43.88 port 8080: Connection refused

【3】curl 

  • 下面说明192.168.43.88的22端口开放
[root@localhost ~]# curl 192.168.43.88:22
SSH-2.0-OpenSSH_7.4
Protocol mismatch.
curl: (56) Recv failure: Connection reset by peer
  • 下面说明192.168.43.88的8080端口不开放
[root@localhost ~]# curl 192.168.43.88:8080
curl: (7) Failed connect to 192.168.43.88:8080; Connection refused

【4】wget 

  • 下面说明192.168.43.88的22端口开放
[root@localhost ~]# wget 192.168.43.88:22
--2022-12-10 09:52:27--  http://192.168.43.88:22/
Connecting to 192.168.43.88:22... connected.
HTTP request sent, awaiting response... 200 No headers, assuming HTTP/0.9
Length: unspecified
Saving to: ‘index.html’
  • 下面说明192.168.43.88的8080端口不开放
[root@localhost ~]# wget 192.168.43.88:8080
--2022-12-10 09:54:51--  http://192.168.43.88:8080/
Connecting to 192.168.43.88:8080... failed: Connection refused.

3、查看本机网络

【1】ifconfig

[root@localhost ~]# ifconfig
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255
        ether 02:42:bb:52:3e:b6  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.43.88  netmask 255.255.255.0  broadcast 192.168.43.255
        inet6 2408:8427:b380:fda:1cd0:ead5:4694:a289  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::408a:6cf2:1f46:9da5  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:ba:b5:b6  txqueuelen 1000  (Ethernet)
        RX packets 1951  bytes 744320 (726.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1455  bytes 139226 (135.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

【2】ip add

[root@localhost ~]# ip add
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
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:ba:b5:b6 brd ff:ff:ff:ff:ff:ff
    inet 192.168.43.88/24 brd 192.168.43.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 2408:8427:b380:fda:1cd0:ead5:4694:a289/64 scope global noprefixroute dynamic 
       valid_lft 3529sec preferred_lft 3529sec
    inet6 fe80::408a:6cf2:1f46:9da5/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

【3】hostname -I

[root@localhost ~]# hostname -I
192.168.43.88 172.17.0.1 2408:8427:b380:fda:1cd0:ead5:4694:a289 

4、查看路由

【1】netstat -rn

[root@localhost ~]# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.43.1    0.0.0.0         UG        0 0          0 ens33
172.17.0.0      0.0.0.0         255.255.0.0     U         0 0          0 docker0
192.168.43.0    0.0.0.0         255.255.255.0   U         0 0          0 ens33

【2】route -n

[root@localhost ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.43.1    0.0.0.0         UG    100    0        0 ens33
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.43.0    0.0.0.0         255.255.255.0   U     100    0        0 ens33

【3】ip route

[root@localhost ~]# ip route
default via 192.168.43.1 dev ens33 proto static metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.43.0/24 dev ens33 proto kernel scope link src 192.168.43.88 metric 100 

阿里云国内75折 回扣 微信号:monov8
阿里云国际,腾讯云国际,低至75折。AWS 93折 免费开户实名账号 代冲值 优惠多多 微信号:monov8 飞机:@monov6
标签: linux

“linux查看网络|查看端口|查看路由|查看ip” 的相关文章