Linux系統(tǒng)常用網(wǎng)絡(luò)管理命令

隨著服務(wù)器的增多,網(wǎng)絡(luò)環(huán)境越來越復(fù)雜,linux網(wǎng)絡(luò)管理越來越顯的重要,接下來我們介紹一下linux網(wǎng)絡(luò)管理命令來提高運(yùn)維效率。

ping檢查網(wǎng)絡(luò)連通性

ping 常常用來測試與目的主機(jī)的連通性。

可以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

配置網(wǎng)絡(luò)

設(shè)置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

查看網(wǎng)絡(luò)狀態(tài)

查看所有端口

[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測試遠(yuǎn)程端口

[root@chao ~]# telnet 172.16.1.16 80

wget下載網(wǎng)絡(luò)文件

[root@chao ~]# wget https://mirror.bit.edu.cn/apache/httpd/httpd-2.4.43.tar.gz

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 本文整理了在實(shí)踐過程中使用的Linux網(wǎng)絡(luò)工具,這些工具提供的功能非常強(qiáng)大,我們平時(shí)使用的只是冰山一角,比如lso...
    老夫劉某閱讀 3,821評(píng)論 0 7
  • ### 1、拒絕所有主機(jī)ping當(dāng)前的主機(jī)。 ```shell #查看當(dāng)前系統(tǒng)iptables規(guī)則 [root@c...
    SkyCastleWQ閱讀 223評(píng)論 0 0
  • OpenFlow 命令創(chuàng)建一個(gè)OVS交換機(jī) ovs-vsctl add-br ovs-switch創(chuàng)建一個(gè)端口 p...
    pigness閱讀 880評(píng)論 0 0
  • 詳述iptables五鏈 防火墻程序是工作在內(nèi)核的TCP/IP的網(wǎng)絡(luò)協(xié)議棧的框架之上,通過網(wǎng)絡(luò)過濾可以實(shí)現(xiàn)入侵檢測...
    Net夜風(fēng)閱讀 1,020評(píng)論 1 1
  • Linux系統(tǒng)的ping命令是常用的網(wǎng)絡(luò)命令,它通常用來測試與目標(biāo)主機(jī)的連通性,我們經(jīng)常會(huì)說“ping一...
    似夢(mèng)千尋閱讀 972評(píng)論 0 0

友情鏈接更多精彩內(nèi)容