RHEL7网络管理

ping检查网络连通性
ping 常常用来测试与目的主机的连通性 。
可以ping通
[root@chao ~]# ping 172.16.1.254PING 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 ms64 bytes from 172.16.1.254: icmp_seq=2 ttl=128 time=0.297 ms64 bytes from 172.16.1.254: icmp_seq=3 ttl=128 time=0.135 ms64 bytes from 172.16.1.254: icmp_seq=4 ttl=128 time=0.245 ms64 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 4001msrtt min/avg/max/mdev = 0.135/0.284/0.529/0.133 ms[root@chao ~]# 不可以ping通
[root@chao ~]# ping 172.16.1.250PING 172.16.1.250 (172.16.1.250) 56(84) bytes of data.From 172.16.1.16 icmp_seq=1 Destination Host UnreachableFrom 172.16.1.16 icmp_seq=2 Destination Host UnreachableFrom 172.16.1.16 icmp_seq=3 Destination Host UnreachableFrom 172.16.1.16 icmp_seq=4 Destination Host UnreachableFrom 172.16.1.16 icmp_seq=5 Destination Host UnreachableFrom 172.16.1.16 icmp_seq=6 Destination Host UnreachableFrom 172.16.1.16 icmp_seq=7 Destination Host UnreachableFrom 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 8003mspipe 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 -nKernel IP routing tableDestinationGatewayGenmaskFlags Metric RefUse Iface0.0.0.0172.16.1.2540.0.0.0UG10000 ens33172.16.1.00.0.0.0255.255.255.0U10000 ens33192.168.122.00.0.0.0255.255.255.0U000 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 -4Active Internet connections (servers and established)Proto Recv-Q Send-Q Local AddressForeign AddressStatetcp00 0.0.0.0:sunrpc0.0.0.0:*LISTENtcp00 chao:domain0.0.0.0:*LISTEN查看tcp端口
[root@chao ~]# netstat -atActive Internet connections (servers and established)Proto Recv-Q Send-Q Local AddressForeign AddressStatetcp00 0.0.0.0:sunrpc0.0.0.0:*LISTENtcp00 chao:domain0.0.0.0:*LISTENtcp00 0.0.0.0:ssh0.0.0.0:*LISTENtcp00 localhos:x11-ssh-offset 0.0.0.0:*LISTENtcp036 chao:ssh172.16.1.100:57418ESTABLISHEDtcp600 [::]:sunrpc[::]:*LISTENtcp600 [::]:ssh[::]:*LISTENtcp600 localhos:x11-ssh-offset [::]:*LISTEN查看udp端口
[root@chao ~]# netstat -auActive Internet connections (servers and established)Proto Recv-Q Send-Q Local AddressForeign AddressStateudp00 chao:domain0.0.0.0:*udp00 0.0.0.0:bootps0.0.0.0:*udp00 localhost:3230.0.0.0:*udp600 localhost:323[::]:*traceroute查看路由信息
[root@chao ~]# traceroute to www.baidu.com (103.235.46.39), 30 hops max, 60 byte packets 1gateway (172.16.1.254)0.132 ms0.062 ms0.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 80wget下载网络文件
[root@chao ~]# wget https://mirror.bit.edu.cn/Apache/httpd/httpd-2.4.43.tar.gz

https://www.linuxprobe.com/rhel-network-mgmt.html

【RHEL7网络管理】


    推荐阅读