ubuntu 修改网卡设置

修改网卡自动协商模式


http://bbs.cfan.com.cn/thread-634149-1-1.html

Fwd: Ubuntu中使用mii-tool快速设置网卡速率 

 关闭 [复制链接]

在ubuntu中,mii-tool 是属于net-tools包。
命令格式:mii-tool [vVrRFwl] media [interface]
-v, --verbose more verbose output 显示网络接口的信息;
-R, --reset reset MII to poweron state 重设MII到开启状态;
-r, --restart restart autonegotiation 重启自动协商模式;
-w, --watch monitor for link status changes 查看网络接口连接的状态变化;
-l, --log with -w, write events to syslog 写入事件到系统日志;
-A, --advertise=media,... advertise only specified media 指令特定的网络接口;
-F, --force=media force specified media technology 更改网络接口速率方式;
media:
100baseTx-FD、100baseTx-HD、10baseT-FD、10baseT-HD
Interface代表所选网卡默认为eth0
实例:
设置网卡工作在10M半双工模式下,输入命令:
#mii-tool -F 10baseT-HD eth0
恢复网卡的自适应工作模式,输入命令:#mii-tool -r eth0

linux网卡模式设置mii-tool和ethtool 

mii-tool 更改网络接口协商的方法;

  # mii-tool --help

  usage: mii-tool [-VvRrwl] [-A media,... | -F media] [interface ...]

  -v, --verbose more verbose output 注:显示网络接口的信息;

  -R, --reset reset MII to poweron state 注:重设MII到开启状态;

  -r, --restart restart autonegotiation 注:重启自动协商模式;

  -w, --watch monitor for link status changes 注:查看网络接口连接的状态变化;

  -l, --log with -w, write events to syslog 注:写入事件到系统日志;

  -A, --advertise=media,... advertise only specified media 注:指令特定的网络接口;

  -F, --force=media force specified media technology 注:更改网络接口协商方式;

  media: 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD,

  (to advertise both HD and FD) 100baseTx, 10baseT

  * 实例一:查看网络接口的协商状态;

  [root@localhost ~]# mii-tool -v eth0

  eth0: negotiated 100baseTx-FD, link ok

  product info: vendor 00:00:00, model 0 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

  link partner: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD flow-control

  注:上面的例子,我们可以看得到是自动协商。注意红字的部份;

  * 实例二:更改网络接口协商方式;

  更改网络接口的协商方式,我们要用到-F选项,后面可以接 100baseT4, 100baseTx-FD, 100baseTx-HD, 10baseT-FD, 10baseT-HD等参数;

  如果我们想把网络接口eth0改为 1000Mb/s全双工的模式应该怎么办呢?

  [root@localhost ~]# mii-tool -F  100baseTx-FD

  [root@localhost ~]#mii-tool -v eth0

  eth0: 100 Mbit, full duplex, link ok

  product info: vendor 00:00:00, model 0 rev 0

  basic mode:   100 Mbit, full duplex

  basic status: link ok

  capabilities: 100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD

  advertising:  100baseTx-FD 100baseTx-HD 10baseT-FD 10baseT-HD

  注:是不是已经改过来了?当然,我们也一样用ethtool 工具来更改,比如执行下面的命令;

  [root@localhost ~]# ethtool -s eth0 speed 100 duplex full

  02、ethtool 工具关于网络协商功能介绍;

  ethtool - Display or change ethernet card settings(ethtool 是用来显示和更改网卡设置的工具);这个工具比较复杂,功能也特别多。由于洋文比较难懂。所以我们还是把网络设备协商方式的设置方法说一说。

  2.1 ethtool 显示网络端口设置功能;

  这个功能比较好办。就是ethtool 后面直接接网絽接口就行;比如下面的例子;

  [root@localhost ~]# ethtool eth0

  Settings for eth0:

  Supported ports: [ TP MII ]

  Supported link modes: 10baseT/Half 10baseT/Full

  100baseT/Half 100baseT/Full

  Supports auto-negotiation: Yes

  Advertised link modes: 10baseT/Half 10baseT/Full

  100baseT/Half 100baseT/Full

  Advertised auto-negotiation: No 注:自动协商关闭

  Speed: 100Mb/s 注:速度 100Mb

  Duplex: Full 注:全双工

  Port: MII

  PHYAD: 32

  Transceiver: internal

  Auto-negotiation: off

  Supports Wake-on: pumbg

  Wake-on: d

  Current message level: 0x00000007 (7)

  Link detected: yes 注:eth0已经激活;

  2.2 ethtool 设置网卡的协商模式;

  在ethtool的-h帮助中我们查看到有这样的帮助信息;

  ethtool -s DEVNAME

  [ speed 10|100|1000 ]

  [ duplex half|full ]

  [ port tp|aui|bnc|mii|fibre ]

  [ autoneg on|off ]

  * 实例一: 把网卡eth0 速度改为10Mb/s,采用半双工;

  [root@cuc03 beinan]# ethtool -s eth1 speed 10 duplex half

  [root@cuc03 beinan]# ethtool eth1

  Settings for eth1:

  Supported ports: [ TP MII ]

  Supported link modes:   10baseT/Half 10baseT/Full

  100baseT/Half 100baseT/Full

  Supports auto-negotiation: Yes

  Advertised link modes:  10baseT/Half 10baseT/Full

  100baseT/Half 100baseT/Full

  Advertised auto-negotiation: No

  Speed: 10Mb/s 注:速度 10M/s

  Duplex: Half  注:半双工

  Port: MII

  PHYAD: 32

  Transceiver: internal

  Auto-negotiation: off

  Supports Wake-on: pumbg

  Wake-on: d

  Current message level: 0x00000007 (7)

  Link detected: no 注:eth1没有激活;

  * 实例二: 把网卡eth0 速度改为100Mb/s,采用全双工;

  [root@cuc03 beinan]# ethtool -s eth1 speed 100 duplex full

  [root@cuc03 beinan]# ethtool eth1

  Settings for eth1:

  Supported ports: [ TP MII ]

  Supported link modes:   10baseT/Half 10baseT/Full

  100baseT/Half 100baseT/Full

  Supports auto-negotiation: Yes

  Advertised link modes:  10baseT/Half 10baseT/Full

  100baseT/Half 100baseT/Full

  Advertised auto-negotiation: No

  Speed: 100Mb/s  注:速度 100M/s

  Duplex: Full 注:全双工

  Port: MII

  PHYAD: 32

  Transceiver: internal

  Auto-negotiation: off

  Supports Wake-on: pumbg

  Wake-on: d

  Current message level: 0x00000007 (7)

  Link detected: no 注:eth1网卡没有激活;



  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ubuntu 是一个流行的 Linux 发行版,配置网卡(网络接口)通常是安装和使用过程中的一项重要任务。以下是基本步骤: 1. **查看网络设备**: 打开终端(Terminal),运行 `ifconfig` 或者 `ip addr` 命令,能看到系统中已有的网络接口和它们的状态。 2. **确定网卡名称**: 找到你的以太网卡(如 eth0, enpXXs0f0 等),或者无线网卡(如 wlan0 或 wlpXX)。有时,无线网卡可能被自动命名为 `wlan0`,但实际名字可能会根据硬件和安装有所不同。 3. **启用网卡**: 对于未启用的网卡,可以使用 `sudo ifup <interface>` 命令,将 `<interface>` 替换为你的网卡名。 4. **配置静态 IP**: 如果需要静态IP,编辑 `/etc/network/interfaces` 文件,添加或修改对应接口的配置。例如: ``` auto <interface> iface <interface> inet static address <IP_address> netmask <netmask> gateway <gateway> ``` 5. **使用DHCP自动获取IP**: 如果你希望网卡从 DHCP 服务器获取动态 IP,只需确保 `iface` 部分没有指定静态 IP,重启网络服务即可。 6. **配置无线网络**: 对于无线网络,通常需要在 `/etc/wpa_supplicant/wpa_supplicant.conf` 文件中设置 SSID 和密码,然后运行 `sudo wpa_cli reconfigure`。 7. **重启网络服务**: 使用 `sudo service networking restart` 或 `sudo systemctl restart networking.service` 重启网络服务,使更改生效。 8. **检查连接**: 最后,你可以用 `ping` 或 `nslookup` 等命令测试网络连接。 如果你遇到具体问题,比如无法连接、IP地址冲突等,请提供更多的错误信息以便进一步诊断。如果有其他问题,请告诉我,我会帮你解答。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值