自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

在Linux上檢查網(wǎng)絡(luò)連接的更多方法

系統(tǒng) Linux 系統(tǒng)運(yùn)維
有幾個(gè)命令可以幫助你在 Linux 系統(tǒng)上看到網(wǎng)絡(luò)狀況,這些包括 ip、ethtool、traceroute、tcptraceroute 和 tcpdump。ifconfig 和 netstat 命令當(dāng)然非常有用,但還有很多其它命令能幫你查看 Linux 系統(tǒng)上的網(wǎng)絡(luò)狀況。本文探索了一些檢查網(wǎng)絡(luò)連接的非常簡(jiǎn)便的命令。

[[220301]]

有幾個(gè)命令可以幫助你在 Linux 系統(tǒng)上看到網(wǎng)絡(luò)狀況,這些包括 ip、ethtool、traceroute、tcptraceroute 和 tcpdump。

ifconfignetstat 命令當(dāng)然非常有用,但還有很多其它命令能幫你查看 Linux 系統(tǒng)上的網(wǎng)絡(luò)狀況。本文探索了一些檢查網(wǎng)絡(luò)連接的非常簡(jiǎn)便的命令。 

ip 命令

ip 命令顯示了許多與你使用 ifconfig 命令時(shí)的一樣信息。其中一些信息以不同的格式呈現(xiàn),比如顯示 192.168.0.6/24,而不是 inet addr:192.168.0.6 Bcast:192.168.0.255,盡管 ifconfig 更適合數(shù)據(jù)包計(jì)數(shù),但 ip 命令有許多有用的選項(xiàng)。

首先,ip a 命令可以列出所有網(wǎng)絡(luò)接口的信息。

  1. $ ip a
  2. 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
  3. link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
  4. inet 127.0.0.1/8 scope host lo
  5. valid_lft forever preferred_lft forever
  6. inet6 ::1/128 scope host
  7. valid_lft forever preferred_lft forever
  8. 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
  9. link/ether 00:1e:4f:c8:43:fc brd ff:ff:ff:ff:ff:ff
  10. inet 192.168.0.6/24 brd 192.168.0.255 scope global eth0
  11. valid_lft forever preferred_lft forever
  12. inet6 fe80::21e:4fff:fec8:43fc/64 scope link
  13. valid_lft forever preferred_lft forever

如果你只想看到簡(jiǎn)單的網(wǎng)絡(luò)接口列表,你可以用 grep 限制它的輸出。

  1. $ ip a | grep inet
  2. inet 127.0.0.1/8 scope host lo
  3. inet6 ::1/128 scope host
  4. inet 192.168.0.6/24 brd 192.168.0.255 scope global eth0
  5. inet6 fe80::21e:4fff:fec8:43fc/64 scope link

使用如下面的命令,你可以看到你的默認(rèn)路由:

  1. $ ip route show
  2. default via 192.168.0.1 dev eth0
  3. 192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.6

在這個(gè)輸出中,你可以看到通過 eth0 的默認(rèn)網(wǎng)關(guān)是 192.168.0.1,并且本地網(wǎng)絡(luò)是相當(dāng)標(biāo)準(zhǔn)的 192.168.0.0/24

你也可以使用 ip 命令來啟用和禁用網(wǎng)絡(luò)接口。

  1. $ sudo ip link set eth1 up
  2. $ sudo ip link set eth1 down 

ethtool 命令

另一個(gè)檢查網(wǎng)絡(luò)非常有用的工具是 ethtool。這個(gè)命令提供了網(wǎng)絡(luò)接口上的許多描述性的數(shù)據(jù)。

  1. $ ethtool eth0
  2. Settings for eth0:
  3. Supported ports: [ TP ]
  4. Supported link modes: 10baseT/Half 10baseT/Full
  5. 100baseT/Half 100baseT/Full
  6. 1000baseT/Full
  7. Supported pause frame use: No
  8. Supports auto-negotiation: Yes
  9. Advertised link modes: 10baseT/Half 10baseT/Full
  10. 100baseT/Half 100baseT/Full
  11. 1000baseT/Full
  12. Advertised pause frame use: No
  13. Advertised auto-negotiation: Yes
  14. Speed: 100Mb/s
  15. Duplex: Full
  16. Port: Twisted Pair
  17. PHYAD: 1
  18. Transceiver: internal
  19. Auto-negotiation: on
  20. MDI-X: on (auto)
  21. Cannot get wake-on-lan settings: Operation not permitted
  22. Current message level: 0x00000007 (7)
  23. drv probe link
  24. Link detected: yes

你也可以使用 ethtool 命令來檢查以太網(wǎng)驅(qū)動(dòng)程序的設(shè)置。

  1. $ ethtool -i eth0
  2. driver: e1000e
  3. version: 3.2.6-k
  4. firmware-version: 1.4-0
  5. expansion-rom-version:
  6. bus-info: 0000:00:19.0
  7. supports-statistics: yes
  8. supports-test: yes
  9. supports-eeprom-access: yes
  10. supports-register-dump: yes
  11. supports-priv-flags: no

自動(dòng)協(xié)商的詳細(xì)信息可以用這樣的命令來顯示:

  1. $ ethtool -a eth0
  2. Pause parameters for eth0:
  3. Autonegotiate: on
  4. RX: on
  5. TX: on 

traceroute 命令

traceroute 命令用于顯示路由路徑。它通過在一系列數(shù)據(jù)包中設(shè)置數(shù)據(jù)包頭的 TTL(生存時(shí)間)字段來捕獲數(shù)據(jù)包所經(jīng)過的路徑,以及數(shù)據(jù)包從一跳到下一跳需要的時(shí)間。traceroute 的輸出有助于評(píng)估網(wǎng)絡(luò)連接的健康狀況,因?yàn)槟承┞酚煽赡苄枰ㄙM(fèi)更長(zhǎng)的時(shí)間才能到達(dá)最終的目的地。

  1. $ sudo traceroute world.std.com
  2. traceroute to world.std.com (192.74.137.5), 30 hops max, 60 byte packets
  3. 1 192.168.0.1 (192.168.0.1) 3.691 ms 3.678 ms 3.665 ms
  4. 2 10.224.64.1 (10.224.64.1) 26.273 ms 27.354 ms 28.574 ms
  5. 3 10.20.0.33 (10.20.0.33) 28.293 ms 30.625 ms 33.959 ms
  6. 4 10.20.0.226 (10.20.0.226) 36.807 ms 37.868 ms 37.857 ms
  7. 5 204.111.0.132 (204.111.0.132) 38.256 ms 39.091 ms 40.429 ms
  8. 6 ash-b1-link.telia.net (80.239.161.69) 41.612 ms 28.214 ms 29.573 ms
  9. 7 xe-1-3-1.er1.iad10.us.zip.zayo.com (64.125.13.157) 30.429 ms 27.915 ms 29.065 ms
  10. 8 ae6.cr1.dca2.us.zip.zayo.com (64.125.20.117) 31.353 ms 32.413 ms 33.821 ms
  11. 9 ae27.cs1.dca2.us.eth.zayo.com (64.125.30.246) 43.474 ms 44.519 ms 46.037 ms
  12. 10 ae4.cs1.lga5.us.eth.zayo.com (64.125.29.202) 48.107 ms 48.960 ms 50.024 ms
  13. 11 ae8.mpr3.bos2.us.zip.zayo.com (64.125.30.139) 51.626 ms 51.200 ms 39.283 ms
  14. 12 64.124.51.229.t495-rtr.towerstream.com (64.124.51.229) 40.233 ms 41.295 ms 39.651 ms
  15. 13 69.38.149.18 (69.38.149.18) 44.955 ms 46.210 ms 55.673 ms
  16. 14 64.119.137.154 (64.119.137.154) 56.076 ms 56.064 ms 56.052 ms
  17. 15 world.std.com (192.74.137.5) 63.440 ms 63.886 ms 63.870 ms 

tcptraceroute 命令

tcptraceroute 命令與 traceroute 基本上是一樣的,只是它能夠繞過最常見的防火墻的過濾。正如該命令的手冊(cè)頁所述,tcptraceroute 發(fā)送 TCP SYN 數(shù)據(jù)包而不是 UDP 或 ICMP ECHO 數(shù)據(jù)包,所以其不易被阻塞。 

tcpdump 命令

tcpdump 命令允許你捕獲網(wǎng)絡(luò)數(shù)據(jù)包來進(jìn)一步分析。使用 -D 選項(xiàng)列出可用的網(wǎng)絡(luò)接口。

  1. $ tcpdump -D
  2. 1.eth0 [Up, Running]
  3. 2.any (Pseudo-device that captures on all interfaces) [Up, Running]
  4. 3.lo [Up, Running, Loopback]
  5. 4.nflog (Linux netfilter log (NFLOG) interface)
  6. 5.nfqueue (Linux netfilter queue (NFQUEUE) interface)
  7. 6.usbmon1 (USB bus number 1)
  8. 7.usbmon2 (USB bus number 2)
  9. 8.usbmon3 (USB bus number 3)
  10. 9.usbmon4 (USB bus number 4)
  11. 10.usbmon5 (USB bus number 5)
  12. 11.usbmon6 (USB bus number 6)
  13. 12.usbmon7 (USB bus number 7)

-v 選項(xiàng)控制你看到的細(xì)節(jié)程度——越多的 v,越詳細(xì),但超過 3 個(gè) v 不會(huì)有更多意義。

  1. $ sudo tcpdump -vv host 192.168.0.32
  2. tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
  3. 20:26:31.321816 IP (tos 0x10, ttl 64, id 22411, offset 0, flags [DF], proto TCP (6), length 184)
  4. 192.168.0.6.ssh > 192.168.0.32.57294: Flags [P.], cksum 0x8221 (incorrect -> 0x0254), seq 3891093411:3891093555, ack 2388988308, win 329, length 144
  5. 20:26:31.321984 IP (tos 0x10, ttl 64, id 22412, offset 0, flags [DF], proto TCP (6), length 200)
  6. 192.168.0.6.ssh > 192.168.0.32.57294: Flags [P.], cksum 0x8231 (incorrect -> 0x3db0), seq 144:304, ack 1, win 329, length 160
  7. 20:26:31.323791 IP (tos 0x0, ttl 128, id 20259, offset 0, flags [DF], proto TCP (6), length 40)
  8. 192.168.0.32.57294 > 192.168.0.6.ssh: Flags [.], cksum 0x643d (correct), seq 1, ack 304, win 385, length 0
  9. 20:26:31.383954 IP (tos 0x10, ttl 64, id 22413, offset 0, flags [DF], proto TCP (6), length 248)
  10. ...

當(dāng)你運(yùn)行像這樣的命令時(shí),會(huì)看到非常多的輸出。

這個(gè)命令捕獲來自特定主機(jī)和 eth0 上的 11 個(gè)數(shù)據(jù)包。-w 選項(xiàng)標(biāo)識(shí)保存捕獲包的文件。在這個(gè)示例命令中,我們只要求捕獲 11 個(gè)數(shù)據(jù)包。

  1. $ sudo tcpdump -c 11 -i eth0 src 192.168.0.32 -w packets.pcap
  2. tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
  3. 11 packets captured
  4. 11 packets received by filter
  5. 0 packets dropped by kernel 

arp 命令

arp 命令將 IPv4 地址映射到硬件地址。它所提供的信息也可以在一定程度上用于識(shí)別系統(tǒng),因?yàn)榫W(wǎng)絡(luò)適配器可以告訴你使用它們的系統(tǒng)的一些信息。下面的第二個(gè) MAC 地址,以 f8:8e:85 開頭,很容易被識(shí)別出是 Comtrend 路由器。

  1. $ arp -a
  2. ? (192.168.0.12) at b0:c0:90:3f:10:15 [ether] on eth0
  3. ? (192.168.0.1) at f8:8e:85:35:7f:b9 [ether] on eth0

上面的***行顯示了系統(tǒng)本身的網(wǎng)絡(luò)適配器的 MAC 地址。該網(wǎng)絡(luò)適配器似乎已由臺(tái)灣 Chicony 電子公司制造。你可以很容易地在網(wǎng)上查找 MAC 地址關(guān)聯(lián),例如來自 Wireshark 的這個(gè)工具 —— https://www.wireshark.org/tools/oui-lookup.html 。 

責(zé)任編輯:龐桂玉 來源: Linux中國(guó)
相關(guān)推薦

2017-12-04 14:00:41

Linux命令網(wǎng)絡(luò)連接

2012-04-09 11:11:40

2020-06-08 08:00:05

JavaScript網(wǎng)站技術(shù)

2010-04-15 09:16:15

Oracle網(wǎng)絡(luò)

2011-01-24 13:53:15

IP配置Windows網(wǎng)絡(luò)連接

2010-09-15 10:47:24

2011-09-02 16:50:32

2010-12-23 14:42:54

網(wǎng)絡(luò)連接

2009-06-17 09:05:05

Linux隱藏網(wǎng)絡(luò)鏈接命令

2009-06-17 12:01:21

Linux

2022-11-20 16:21:33

Linuxping 命令網(wǎng)絡(luò)連接

2009-03-05 13:44:28

2011-03-11 10:12:17

服務(wù)器網(wǎng)絡(luò)連接

2011-01-24 13:44:16

PING TCPIP Windows網(wǎng)

2009-05-18 17:45:55

網(wǎng)絡(luò)連接網(wǎng)絡(luò)設(shè)備網(wǎng)康科技

2010-03-24 14:05:06

無線網(wǎng)絡(luò)連接不上

2023-05-04 18:45:11

2022-04-12 10:26:55

NetstatLinux 服務(wù)器端口

2011-03-21 14:04:38

2011-09-19 13:08:54

優(yōu)化網(wǎng)絡(luò)連接DNS代理緩存
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)