Linux系统常用网络管理命令
2023-09-27 14:29:14 时间
随着服务器的增多,网络环境越来越复杂,linux网络管理越来越显的重要,接下来我们介绍一下linux网络管理命令来提高运维效率。 |
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
相关文章
- Linux常用命令(第二版) --系统开关机命令
- Linux:Ubuntu系统的ufw防火墙配置命令有哪些
- Linux-命令:查看已挂载数据盘/硬盘【 df -h】【“disk free”的缩写,用于显示Linux系统中各文件系统的硬盘使用情况,包括文件系统所在硬盘分区的总容量、已使用的容量、剩余容量等】
- Linux:系统进程---->查看命令【ps:静态查看进程】【top:动态查看进程】
- Java服务化系统线上应急和技术攻关,你必须掌握的Linux命令
- Linux系统中文显示
- 十个Linux系统下的passwd实用命令示例
- 企业日志分析之Linux系统message收集展示
- Linux系统下df命令的11个实例分享
- Linux入门——基础系统设置命令
- Linux查看系统信息的一些命令及查看已安装软件包的命令
- linux 查看系统计划任务相关的命令
- Linux系统基础知识整理(一)
- Linux、Windows修改网卡MAC
- Linux系统下基本命令
- Linux系统性能监控之6个vmstat和6个iostat命令
- linux系统时间调整命令
- linux OS与SQL修改时区,系统时间
- Linux系统(五)负载均衡LVS集群之DR模式
- Linux命令系统zsh
- 查看linux系统版本命令
- LINUX系统中如何使用find命令进行查找并操作
- 《Linux From Scratch》第三部分:构建LFS系统 第六章:安装基本的系统软件- 6.1. 简介
- cachestat、cachetop、pcstat-linux系统缓存命中率分析工具
- 6个关于dd命令备份Linux系统的例子
- 一篇文章让你学透Linux系统中的more命令
- 忠告初学者学习Linux系统的8点建议
- 查看Linux系统架构类型的5条常用命令
- Linux_系统时间管理