无论你是要下载文件、诊断网络问题、管理网络接口,还是查看网络的统计数据,都有终端命令可以来完成,本篇文章重点为大家讲解一下RHEL7中常用的网络命令。
目前创新互联建站已为上1000+的企业提供了网站建设、域名、网站空间、成都网站托管、企业网站设计、阳信网站维护等服务,公司将坚持客户导向、应用为本的策略,正道将秉承"和谐、参与、激情"的文化,与客户和合作伙伴齐心协力一起成长,共同发展。
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 ~]#
[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 [::]:*
[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 * * *
[root@chao ~]# telnet 172.16.1.16 80
[root@chao ~]# wget https://mirror.bit.edu.cn/apache/httpd/httpd-2.4.43.tar.gz
新闻名称:RHEL7中常用的网络命令
链接地址:http://www.36103.cn/qtweb/news35/19785.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联