常用linux 命令,linux命令
一 網路參數設定命令
1.ifconfig :查詢、設定網卡與IP網段等相關參數
1.1 man手冊定義
DESCRIPTION Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface.
簡譯: ifconfig 習慣用於配置kernel-resident 網路介面,一般在啟動時設定必要的介面。也用於debug和系統調試。
如果沒有參數 會列出當前啟用(up status)的網路介面
如果接一個網路介面參數(ifconfig eth0),會輸出該介面的配置
如果後面參數是-a, 會輸出所有的網路介面(up 和down staus的網路介面)
1.2 命令輸出簡述
[root@test_1 net]# ifconfigeth0 Link encap:Ethernet HWaddr 84:2B:2B:94:F7:7D inet addr:192.168.2.241 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::862b:2bff:fe94:f77d/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1546524 errors:0 dropped:0 overruns:0 frame:0 TX packets:1652650 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:754067360 (719.1 MiB) TX bytes:1474728958 (1.3 GiB) Interrupt:18 eth0:1 Link encap:Ethernet HWaddr 84:2B:2B:94:F7:7D inet addr:192.168.2.242 Bcast:192.168.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:18 eth0:2 Link encap:Ethernet HWaddr 84:2B:2B:94:F7:7D inet addr:192.168.2.243 Bcast:192.168.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:18 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:594 errors:0 dropped:0 overruns:0 frame:0 TX packets:594 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:51885 (50.6 KiB) TX bytes:51885 (50.6 KiB)
。eth0:網卡的代號,也有lo這個loopback。
· HWaddr:網卡的硬體地址,習慣稱為MAC。
· inet addr:IPv4的IP地址,後續的Bcase、Mask分別代表的是Broadcast與Netmask。
· inet6 addr:是IPv6的版本的IP,我們沒有使用,所以略過。
· RX:那一行代表的是網路由啟動到目前為止的資料包接收情況,packets代表資料包數、errors代表資料包發生錯誤的數量、dropped代表資料包由於有問題而遭丟棄的數量等。
· TX:與RX相反,為網路由啟動到目前為止的傳送情況。
· collisions:代表資料包碰撞的情況,如果發生太多次,表示你的網路狀況不太好。
· txqueuelen:代表用來傳輸資料的緩衝區的儲存長度。
· RX Bytes、TX Bytes:總傳送、接收的位元組總量。
· Interrupt、Memory:網卡硬體的資料,IRQ岔斷與記憶體位址。
通過觀察上述的資料,大致上可以瞭解到你的網路情況,尤其是RX、TX內的error數量,以及是否發生嚴重的collision情況,都是需要注意的。