miitoolveth0
A. 如何查看linux系統的網路介面
方法/步驟
1、進入linux,使用「 cat /etc/services 」命令,可以查看所有服務默認的埠列表信息。
B. linux如何看網路帶寬
使用命令:mii-tool -v
mii:是Linux下專門設置網卡工作模式的命令,詳細參數如下
1. 查看網卡的工作模式,輸入命令:
#mii-tool -v
eth0: negotiated 100baseTx-FD, link ok
proct info: vendor 00:aa:00, model 56 rev 0
basic mode: autonegotiation enabled
basic status: autonegotiation complete, link ok
capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
從以上信息中可以看出,這塊網卡工作在100M全雙工自適應模式下,「100BaseTx-FD」意為100M Full Duplex。
2. 更改網卡的工作模式,輸入命令:
#mii-tool -F media [interface]
media可選的模式有100baseTx-FD、100baseTx-HD、10baseT-FD、10baseT-HD等。 Interface代表所選擇的網卡,如eth0、eth1等,默認為eth0。
例如,設置網卡工作在10M半雙工模式下,輸入命令:
#mii-tool -F 10baseT-HD eth0
3. 恢復網卡的自適應工作模式,輸入命令:
#mii-tool -r eth0
更詳細的使用方法可以用mii-tool -h來獲得。
C. linux多網卡機上如何通過工具查看各網卡是否接入網路
一、通過mii-tool指令
[root@linuxzgf ~]# mii-tool
//mii-tool主要是用於配置網卡工作模式的指令,同時也可以進行查詢、監控等工作!
二、ethtool
[root@linuxzgf ~]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: umbg
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes
從上面 Link detected 可以看出eth0 處於連接狀態
三.[root@linuxzgf ~]# /etc/init.d/network status
配置設備:
lo eth0 eth0.10 eth0.2 eth0.3 eth0.4 eth0.5 eth0.7 eth0.8 eth1
當前的活躍設備:
lo eth0 eth0.10
[四、ifconfig -a
[root@linuxzgf ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:E0:81:80:D8:96
inet6 addr: fe80::2e0:81ff:fe80:d896/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:626032 errors:0 dropped:0 overruns:0 frame:0
TX packets:415035 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:123631002 (117.9 MiB) TX bytes:297575498 (283.7 MiB)
Base address:0x2000 Memory:df300000-df320000
eth1 Link encap:Ethernet HWaddr 00:E0:81:80:D8:97
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Base address:0x2020 Memory:df320000-df340000
五、lspci也可以看到網卡的信息
D. linux下怎麼判斷網卡異常網卡狀態
ip link 命令 或者 通過mii-tool指令
[root@localhost
root]# mii-tool
eth0:
negotiated 100baseTx-FD, link ok
eth1:
no link
或
[root@localhost
root]# mii-tool -v
eth0:
negotiated 100baseTx-FD, link ok
proct
info: vendor 00:50:43, model 2 rev 3
basic
mode: autonegotiation
enabled
basic
status: autonegotiation complete, link ok
capabilities:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
link
partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
eth1:
no link
proct
info: vendor 00:50:43, model 2 rev 3
basic
mode: autonegotiation
enabled
basic
status: no link
capabilities:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD
advertising:
100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control
或
[root@localhost
root]# mii-tool -w
21:20:33
eth0: negotiated 100baseTx-FD, link ok
21:20:33
eth1: no link
//mii-tool主要是用於配置網卡工作模式的指令,同時也可以進行查詢、監控等工作!
2)
[root@localhost /]# /etc/init.d/network status
Configured devices:
lo eth0 eth1
Currently active devices:
lo eth0
等同於
[root@localhost root]# service --status-all
............
............
Configured devices:
lo eth0 eth1
Currently active devices:
lo eth0
............
............
3)ifconfig -a
[root@localhost /]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:09:6B:09:08:FC
inet addr:192.168.10.1 Bcast:192.168.10.255 Mask:255.255.255.0
inet6 addr: fe80::209:6bff:fe09:8fc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:106732953 errors:0 dropped:0 overruns:0 frame:0
TX packets:104379788 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2351331877 (2.1 GiB) TX bytes:391707945 (373.5 MiB)
Base address:0x2500 Memory:fbfe0000-fc000000
eth1 Link encap:Ethernet HWaddr 00:09:6B:09:08:FD
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Base address:0x2540 Memory:fbfc0000-fbfe0000
4)ethtool
ethtool eth0
Settings for eth0:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: yes
ethtool eth1
Settings for eth1:
Supported ports: [ MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Half 1000baseT/Full
Advertised auto-negotiation: Yes
Speed: Unknown! (0)
Duplex: Half
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: no
從上面可以看出eth0 處於連接狀態,eth1沒有連接
二. 查看網卡的配置
一般在linux下查看網路配置可以使用ifconfig命令,可以顯示當前網卡的基本配置信息。
終端輸入ifconfig 會出現一下內容:
eth0
Link encap:Ethernet HWaddr 00:0C:29:0C:4B:0F
inet addr:192.168.37.128 Bcast:192.168.37.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:33 errors:0 dropped:0 overruns:0 frame:0
TX packets:17 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:2823 (2.7 Kb)
TX bytes:2722 (2.6 Kb)
Interrupt:10 Base address:0x1080
他們分別表示:
Eth0:網路介面
link encap:網路類型
HWaddr:網卡物理地址
Inet addr :IP地址
Bcast:廣播地址
Mask:子網掩碼
UP:正在使用的網路介面
RX packets,TX packets接收和傳輸的數據包個數
RX byte,TX byte表示接搜和傳輸的具體數目
Interrupt:終端信息
Base address:內存地址
三. 網卡配置文件
如果希望每次啟動linux時,都能為你的網卡配置正確的網路地址,可以採用下列兩種方法:
1. 每次開機後,使用ifconfig手動重新設置網卡的配置;
2. 在開機流程中,將網路配置的設置保存在某些RC Script中。
第一種方式麻煩,第二種方式涉及到在哪個RC Script中配置網卡是比較適當的?
Linux啟動過程中會執行以下三個RC Script。
1. /etc/rc.d/init.d/rc.sysinit;
2. /etc/rc.d/init.d/rc;
3. /etc/rc.d/init.d/rc.local
為了維護Linux的穩定性,建議不要修改前兩項。但是,用ifconfig配置第三個RC Script的話,導致嚴重的問題:由於最後執行這個程序,在其執行之前,可能已經執行了數十項網路服務。因此,會造成一堆網路服務因為網卡尚未啟動而無法順利的啟動。
四、網卡配置文件
解決上述問題的方法:每一個網路介質都對應一個配置文件,超級用戶可以通過這些配置文件來配置網卡。
網卡配置文件存放在 /etc/sysconfig/network-scripts/目錄中;
/etc/sysconfig/network-scripts/ifcfg-interface-name
設置文件ifcfg-interface-name包含了初始化介面所需的大部分周詳信息。其中interface-name將根據網卡的類型和排序而不
同,一般其名字為eth0、eth1、ppp0等,其中eth表示以太(eth0)類型網卡,0表示第一塊網卡,1表示第二塊網卡,而ppp0則表示第一 個point-to-poirt protocol網路介面。在ifcfg文件中定義的各項目取決於介面類型。
下面的值較問常見:
》DEVICE=name ,其中,name是物理設備名。
》IPADDR=addr,其中,addr是IP地址。
》NETMASK=mask,其中,mask是網路掩碼值。
》NETWORK=addr,其中addr是網路地址。
》BROADCAST=addr,其中,addr是廣播地址。
》GATEWAY=addr,其中addr是網關地址。
》ONBOOT=answer,其中,answer是yes(引導時激活設備)或no(引導時不激活設備)
》USERCTL=answer,其中,answer是yes(非root用戶能控制該設備)或no
》BOOTPROTO=proto,其中,proto取下列值之一:none,引導時不使用協議;static靜態分配地址;bootp,使用BOOTP協議,或dhcp,使用DHCP協議。
(2)根據上述各參數的意義,設定linpcl.lintec.e.cn機器的設置文件如下:
[root@linpcl root]#cat /etc/sysconfig/networking/devices/ifcfg-rth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.2
NETMASK=255.255.255.0
GATEWAY=192.168.0.1