linux系统 网卡配置命令

更改网卡MAC地址:
ifconfig eth0 hw ether xx:xx:xx:xx:xx:xx
  eth0,eth1,eth2,代表网卡一,网卡二,网卡三
  hw 代表hardware 硬件意思
  ether 代表ethernet 以太网的意思
设置后他自己保存,重启后还是新地址

ip link set eth0 address xx:xx:xx:xx:xx:xx

IP命令同样可以修改,只不过难于记住

更改网卡IP地址:
ifconfig eth1 192.168.1.10 netmask 255.255.255.0   //设置网卡子网及ip
也可以通过SETPU中的网络配置来更改。看你自己喜欢了 更改网卡的工作模式
第一个命令
1:查看网卡的工作模式,输入命令:
mii-tool -v
eth0: negotiated 100baseTx-FD,link ok
product info:Vendor 00:05:be,model 8 rev 0
basic status: autonegotiation complete,link ok
basic mode:autonegotiation enabled.
Capabilities: ..............
   从以上 信息中可以看出,这块网卡工作在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

第二个命令
ethtool :命令可以设置千兆网卡,所以,一般用他就OK了
[root@google ~]# 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: 1000Mb/s                   ( 当前速度 1000Mb
        Duplex: Full                      ( 全双工
        Port: Twisted Pair
        PHYAD: 0
        Transceiver: internal
        Auto-negotiation: on
        Supports Wake-on: pumbg
        Wake-on: g
        Current message level: 0x00000033 (51)
        Link detected: yes                ( eth0已经激活

要设置网卡工作模式命令为:
ethtool -s   eth*  [speed 10|100|1000]   [duplex half|full]

比如要设置网卡为10M半双工命令为:
ethtool -s eth0 speed 10 duplex half
设置完后用  ethtool eth*  来查看就OK了
如果要保存设置值,就把命令写入 /etc/rc.d/rc.local里面
















本文出自 “eo” 博客,谢绝转载!

你可能感兴趣的:(linux,配置,职场,网卡,休闲)