linux 测试网络端口通不通_RHEL7网络管理,提高运维效率

f4bc0767e9defa31e73488a3678ca5c9.png

随着服务器的增多,网络环境越来越复杂,linux网络管理越来越显的重要,接下来我们介绍一下linux网络管理命令来提高运维效率。

1b06fb2b9342837edad7060d7b979c84.png

ping检查网络连通性

ping 常常用来测试与目的主机的连通性。

可以ping通
[root@chao ~]# ping 172.16.1.254
PING 172.16.1.254 (172.16.1.254) 56(84) bytes of data.
64 bytes from 172.16.1.254: icmp_seq=1 ttl=128 time=0.529 ms
64 bytes from 172.16.1.254: icmp_seq=2 ttl=128 time=0.297 ms
64 bytes from 172.16.1.254: icmp_seq=3 ttl=128 time=0.135 ms
64 bytes from 172.16.1.254: icmp_seq=4 ttl=128 time=0.245 ms
64 bytes from 172.16.1.254: icmp_seq=5 ttl=128 time=0.214 ms
^C
--- 172.16.1.254 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 0.135/0.284/0.529/0.133 ms
[root@chao ~]#
不可以ping通
[root@chao ~]# ping 172.16.1.250
PING 172.16.1.250 (172.16.1.250) 56(84) bytes of data.
From 172.16.1.16 icmp_seq=1 Destination Host Unreachable
From 172.16.1.16 icmp_seq=2 Destination Host Unreachable
From 172.16.1.16 icmp_seq=3 Destination Host Unreachable
From 172.16.1.16 icmp_seq=4 Destination Host Unreachable
From 172.16.1.16 icmp_seq=5 Destination Host Unreachable
From 172.16.1.16 icmp_seq=6 Destination Host Unreachable
From 172.16.1.16 icmp_seq=7 Destination Host Unreachable
From 172.16.1.16 icmp_seq=8 Destination Host Unreachable
^C
--- 172.16.1.250 ping statistics ---
9 packets transmitted, 0 received, +8 errors, 100% packet loss, time 8003ms
pipe 4

配置网络

设置ip
[root@chao ~]# ifconfig ens33:1 172.16.1.114 netmask 255.255.255.0 up
更改MAC地址
[root@chao ~]# ifconfig ens33:1 hw ether 00:0c:29:0b:07:77

修改路由表

显示路由表
[root@chao ~]# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         172.16.1.254    0.0.0.0         UG    100    0        0 ens33
172.16.1.0      0.0.0.0         255.255.255.0   U     100    0        0 ens33
192.168.122.0   0.0.0.0         255.255.255.0   U     0      0        0 virbr0
添加路由
[root@chao ~]# route add -net 172.16.2.0 netmask 255.255.255.0 gw 172.16.1.254
删除路由
[root@chao ~]# route del -net 172.16.2.0 netmask 255.255.255.0

查看网络状态

查看所有端口
[root@chao ~]# netstat -a|head -4
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN
tcp        0      0 chao:domain             0.0.0.0:*               LISTEN
查看tcp端口
[root@chao ~]# netstat -at
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:sunrpc          0.0.0.0:*               LISTEN
tcp        0      0 chao:domain             0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN
tcp        0      0 localhos:x11-ssh-offset 0.0.0.0:*               LISTEN
tcp        0     36 chao:ssh                172.16.1.100:57418      ESTABLISHED
tcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
tcp6       0      0 localhos:x11-ssh-offset [::]:*                  LISTEN
查看udp端口
[root@chao ~]# netstat -au
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
udp        0      0 chao:domain             0.0.0.0:*
udp        0      0 0.0.0.0:bootps          0.0.0.0:*
udp        0      0 localhost:323           0.0.0.0:*
udp6       0      0 localhost:323           [::]:*

traceroute查看路由信息

[root@chao ~]# traceroute to www.baidu.com (103.235.46.39), 30 hops max, 60 byte packets
 1  gateway (172.16.1.254)  0.132 ms  0.062 ms  0.086 ms
 2  * * *
 3  * * *
 4  * * *
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  * * *
10  * * *
11  * * *
12  * * *
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *

telnet测试远程端口

[root@chao ~]# telnet 172.16.1.16 80

wget下载网络文件

[root@chao ~]# wget https://mirror.bit.edu.cn/apache/httpd/httpd-2.4.43.tar.gz

5a53659b403f08e707a7798c2775b605.png

ecdac48c41ad372fa61be9282316c4f3.png

官方站点:www.linuxprobe.com

 Linux命令大全:www.linuxcool.com

Linux系统下载站:www.linuxdown.com

ee61ed2117d0ada1f4dd24eb00c95865.png

刘遄老师QQ:5604922

Linux技术交流群:193666693

(新群,火热加群中……)

书籍在线学习(电脑阅读效果佳)

http://www.linuxprobe.com/chapter-00.html

    想要学习Linux系统的读者可以点击按钮来了解书籍《Linux就该这么学》,同时也非常适合专业的运维人员阅读,成为辅助您工作的高价值工具书!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值