LinuxProbe 发表于 2021-2-13 12:57:21

Linux系统常用网络管理命令


随着服务器的增多,网络环境越来越复杂,linux网络管理越来越显的重要,接下来我们介绍一下linux网络管理命令来提高运维效率。
https://www.linuxprobe.com/wp-content/uploads/2020/05/3-7-300x188.jpgping检查网络连通性
ping 常常用来测试与目的主机的连通性。可以ping通
# 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# 不可以ping通
# 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
# ifconfig ens33:1 172.16.1.114 netmask 255.255.255.0 up更改MAC地址
# ifconfig ens33:1 hw ether 00:0c:29:0b:07:77修改路由表
显示路由表
# route -nKernel IP routing tableDestination   Gateway         Genmask         Flags Metric Ref    Use Iface0.0.0.0         172.16.1.254    0.0.0.0         UG    100    0      0 ens33172.16.1.0      0.0.0.0         255.255.255.0   U   100    0      0 ens33192.168.122.0   0.0.0.0         255.255.255.0   U   0      0      0 virbr0添加路由
# route add -net 172.16.2.0 netmask 255.255.255.0 gw 172.16.1.254删除路由
# route del -net 172.16.2.0 netmask 255.255.255.0 查看网络状态
查看所有端口# netstat -a|head -4Active 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端口# netstat -atActive 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      ESTABLISHEDtcp6       0      0 [::]:sunrpc             [::]:*                  LISTEN   tcp6       0      0 [::]:ssh                [::]:*                  LISTEN   tcp6       0      0 localhos:x11-ssh-offset [::]:*                  LISTEN查看udp端口# netstat -auActive 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查看路由信息
# 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测试远程端口
# telnet 172.16.1.16 80wget下载网络文件
# wget https://mirror.bit.edu.cn/apache/httpd/httpd-2.4.43.tar.gz

wlcbhrss 发表于 2021-2-14 09:34:49

{:6_264:}{:6_264:}{:6_264:}{:6_264:}

thamky 发表于 2021-2-14 10:45:40

感谢楼主分享

xz蓝精灵 发表于 2021-2-15 23:38:25

666

ouhin 发表于 2021-2-16 09:27:41

谢谢分享,换行显得有点奇怪

wlcbhrss 发表于 2021-2-16 19:36:14


谢谢楼主分享{:6_267:}{:6_267:}

wlcbhrss 发表于 2021-2-16 19:36:21


谢谢楼主分享{:6_267:}{:6_267:}

shi351953026 发表于 2021-2-18 08:40:32

排版乱七八糟,不过无所谓
新年快乐

a_jian 发表于 2021-2-19 10:48:11

格式是错了吗

siquxiongdi 发表于 2021-2-19 11:21:13

thamky 发表于 2021-2-14 10:45
感谢楼主分享

谢谢分享

j616060587 发表于 2021-2-19 17:22:06

新年快乐

xz蓝精灵 发表于 2021-2-20 09:10:43

666

a_jian 发表于 2021-2-20 09:16:03

是乱码了吗
页: [1]
查看完整版本: Linux系统常用网络管理命令