最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 正文

linux下查看和配置网卡相关的一些命令和资料

来源:动视网 责编:小OO 时间:2025-10-02 19:25:40
文档

linux下查看和配置网卡相关的一些命令和资料

linux下网卡相关的一些命令和资料下面一些命令和资料可以查阅到当前的网络卡的相关信息。如果命令无法运行则,加上/sbin/作为路径使用dmesg|grepeth0ethtooleth*mii-toolifconfig-a查看是否是你分配的IP。配置文件/etc/sysconfig/network/etc/sysconfig/network-scripts/ifcfg-eth*请问各位兄弟,在Linux中怎么看网卡是全双工工作还是半双工工作?mii-toolLinux:~#mii-toolet
推荐度:
导读linux下网卡相关的一些命令和资料下面一些命令和资料可以查阅到当前的网络卡的相关信息。如果命令无法运行则,加上/sbin/作为路径使用dmesg|grepeth0ethtooleth*mii-toolifconfig-a查看是否是你分配的IP。配置文件/etc/sysconfig/network/etc/sysconfig/network-scripts/ifcfg-eth*请问各位兄弟,在Linux中怎么看网卡是全双工工作还是半双工工作?mii-toolLinux:~#mii-toolet
linux下网卡相关的一些命令和资料

下面一些命令和资料可以查阅到当前的网络卡的相关信息。如果命令无法运行则,加上/sbin/作为路径使用

dmesg |grep eth0

ethtool eth*

mii-tool

ifconfig -a查看是否是你分配的IP。

配置文件

/etc/sysconfig/network

/etc/sysconfig/network-scripts/ifcfg-eth*

请问各位兄弟,在Linux中怎么看网卡是全双工工作还是半双工工作?

mii-tool

Linux:~ # mii-tool

eth0: no link

eth1: no autonegotiation, 100baseTx-HD, link ok

Linux:~ #

Linux:~ # mii-tool -F

mii-tool: option requires an argument — F

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

-V, –version display version information

-v, –verbose more verbose output

-R, –reset reset MII to poweron state

-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

Linux:~ # mii-tool

eth0: no link

eth1: no autonegotiation, 100baseTx-HD, link ok

Linux:~ # mii-tool -F 100baseTx-HD

//切换网卡得状态为半双工状态

Linux:~ # mii-tool

eth0: 100 Mbit, half duplex, no link

eth1: 100 Mbit, half duplex, link ok

通过mii-tool和ethtool工具来调整网卡的速度、双工等,这样能提高网卡的效率;

mii-tool 配置网络设备协商方式的工具

mii-tool 介绍

mii-tool – view, manipulate media-independent interface status (mii-tool 是查看,管理介质的网络接口的状态)

有时网卡需要配置协商方式 ,比如10/100/1000M的网卡半双工、全双工、自动协商的配置 。但大多数的网络设备是不用我们来修改协商,因为大多数网络设置接入的时候,都采用自动协商来解决相互通信的问题。但在有的情况下,需要我们手动来设置网卡的协商方式;

mii-tool 就是能指定网卡的协商方式。

注明:我在使用mii-tool工具修改协商模式时,提示是错误的,因为是在虚 拟机中做的,不过虚拟机中的网卡我查看是支持全双工模式的,可是提示错误SIOCGMIIPHY on ‘eth0′ failed: Operation not supported,问题出在那里也不清楚,用google查了下,发现不少人都是这样的错误,也没说明原因;不过多数人提示可以使用ethtool工具 去修改,我测试了下,还行!还有一种方法是修改/etc/modules.conf配置文件;

#ethtool -s eth0 autoneg off

#ethtool -s eth0 duplex full

在/etc/modules.conf添加内容

alias eth0 bcm5700 line_speed=100 full_duplex=1

options bcm5700 line_speed=100 full_duplex=1

重起!

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

[root@localhost]# mii-tool –help

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

-V, –version display version information

-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

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

ethtool – Display or change ethernet card settings(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: 0×00000007 (7)

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

ethtool 设置网卡的协商模式;

ethtool -s DEVNAME \

[ speed 10|100|1000 ] \

[ duplex half|full ] \

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

[ autoneg on|off ] \

把网卡eth0 速度改为10Mb/s,采用半双工;

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

[root@localhost]# 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: 0×00000007 (7)

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

把网卡eth0 速度改为100Mb/s,采用全双工;

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

[root@localhost]# 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: 0×00000007 (7)

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

文档

linux下查看和配置网卡相关的一些命令和资料

linux下网卡相关的一些命令和资料下面一些命令和资料可以查阅到当前的网络卡的相关信息。如果命令无法运行则,加上/sbin/作为路径使用dmesg|grepeth0ethtooleth*mii-toolifconfig-a查看是否是你分配的IP。配置文件/etc/sysconfig/network/etc/sysconfig/network-scripts/ifcfg-eth*请问各位兄弟,在Linux中怎么看网卡是全双工工作还是半双工工作?mii-toolLinux:~#mii-toolet
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top