1.软文推荐

2.软文推荐

3.软文推荐

无论你是要下载文件、诊断网络问题、管理网络接口,还是查看网络的统计数据,都有终端命令可以来完成,本篇文章重点为大家讲解一下RHEL7中常用的网络命令。

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

本文来源:www.lxlinux.net/5500.html,若引用不当,请联系修改。

相关文章 8

1

枣庄vps主机(山东枣庄vps) 50秒前

目录:1、vps和虚拟主机的区别2、VPS、虚拟机、云主机,这三个到底有什么区别?3、vps和云主机的区别是什么?4、vps,虚拟主机,云主机是...

2

Linux常用命令—pgrep命令 4分钟前

Linux常用命令 pgrep命令 以名称为依据从运行进程队列中查找进程,并显示查找到的进程id,下面良许教程网为大家分享一下Linux常用命令pgr...

3

详解GIit基本使用方法 6分钟前

本篇文章重点为大家分享一下gir中的常用方法和操作,有需要的小伙伴可以参考一下。 创建版本库 $git clone #克隆远程版本库 $gitinit #初始化...

4

湖北十堰机房(湖北十堰机房直销) 7分钟前

目录:1、湖北省十堰市介绍2、谁知道移动宽带的原理,光缆是怎么走的,通过什么设备到户3、湖北省十堰市第二中学的电话是多少?湖北...

5

通过eNSP实现静态NAT转换 8分钟前

eNSP是图形化网络仿真平台,该平台通过对真实网络设备的仿真模拟。网络转换技术也叫做NAT技术,他的作用就是实现私网IP和公网IP 的转换来...

6

404notfound(404notfound的中文翻译) 10分钟前

目录:1、404 not found怎么解决?404页面怎么做2、网页显示“404 not found”是什么意思?怎么解决?3、网页显示404 not found怎么解决4、电脑打开...

7

如何解决SpringBoot跨域问题 13分钟前

当一个请求url的 协议、域名、端口 三者之间任意一个与当前页面url不同即为跨域,前后端分离是目前的趋势, 解决跨域问题也是老生常谈...

8

Linux系统挂载命令mount详细教程 15分钟前

在Linux系统中要想将分区挂载到文件夹下可以使用mount命令,挂载之后将改分区和目录练习起来,以后只要访问文件夹就等于访问改分区。下...