mii-tool(这是Linux下专门设置网卡工作模式的命令)
MII的全称是Media Independent Interface,字面意思上就是媒体无关的接口,因此它是独立于具体设备的,标准化的东西都是独立于具体设备的。不过很多以太网卡设备并不支持这些参数的配置,因此当你执行mii-tool的时候,会得到Operation not supported的提示,要不就是没有使用超级用户身份,还有就是若接口编号设置超过eth7时,直接使用mii-tool 不加参数,会出现NO MII xxxxxxxxxx interface 之类的提示,是因为超过了默认值,使用帮助信息可以了解。

1. 查看网卡的工作模式,输入命令:

mii-tool -v eth0

[root@localhost ~]# mii-tool -v eth0
eth0: no autonegotiation, 100baseTx-FD, link ok
  product info: vendor 00:50:43, model 2 rev 4
  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半双工模式下,输入命令:
[root@localhost ~]# mii-tool -F 10baseT-HD eth0
[root@localhost ~]# mii-tool eth0
eth0: 10 Mbit, half duplex, link ok

3. 恢复网卡的自适应工作模式,输入命令:

mii-tool -r eth0

[root@localhost ~]# mii-tool -r eth0
restarting autonegotiation...
[root@localhost ~]# mii-tool eth0
eth0: no autonegotiation, 100baseTx-FD, link ok
更详细的使用方法可以用mii-tool -h来获得。
注:
mii-tool不支持1000M以上的网卡
正常对于100M以下的网卡都可以用这俩个命令来查看,但是对于100M以上网卡的,mii-tool就会出现问题
[root@localhost ~]# mii-tool -v eth0
eth0: no autonegotiation, 100baseTx-FD, link ok
  product info: vendor 00:50:43, model 2 rev 4
  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网卡,实际上是1000M的接口
[root@localhost ~]# ethtool eth0
Settings for eth0:
        Supported ports: [ TP ]
        Supported link modes:   10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Supported pause frame use: No
        Supports auto-negotiation: Yes
        Advertised link modes:  10baseT/Half 10baseT/Full
                                100baseT/Half 100baseT/Full
                                1000baseT/Full
        Advertised pause frame use: No
        Advertised auto-negotiation: Yes
        Speed: 1000Mb/s
        Duplex: Full
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        MDI-X: Unknown
        Supports Wake-on: umbg
        Wake-on: d
        Current message level: 0x00000007 (7)
                               drv probe link
        Link detected: yes
#这里却正确的显示1000M网卡