Linux Network commands ethtool and miI-tool and NM-Tool

Source: Internet
Author: User

Recently, I tested the network stability of the server in terms of FTP and SCP. The network is always interrupted automatically, but the local connection is still running. The ping to the server is normal and some basic commands are used during this period, in order to easily record and expand knowledge, the recorded content is as follows:

1. ethtool

Ethtool is a command used to query and set Nic parameters in Linux.

Summary:  

Ethtool ethx // query basic ethx network port settings

Ethtool-H // display the ethtool Command help (HELP)

Ethtool-I ethx // query ethx network port information

Ethtool-D ethx // query the registration information of the ethx network port

Ethtool-r ethx // reset the ethx network port to the Adaptive Mode

Ethtool-s ethx // query the ethx network port receiving and receiving packet statistics

Ethtool-s ethx [speed 10 | 100 | 1000] /// set the network port rate to 10/100/1000 m

[Duplex half | Full] /// sets the network port half/Full Duplex

[Autoneg on | off] // sets whether the network port is self-negotiated

[Port TP | AuI | BNC | MII] // sets the network port type

[Phyad N] \

[Xcvr internal | exteral] \

[Wol p | u | M | B | A | G | S | D...] \

[Sopass XX: YY: ZZ: AA: BB: CC] \

[Msglvl N]

How does one make ethtool settings permanently stored on network devices?

Solution 1: The ethtool settings can be saved in the/etc/sysconfig/network-scripts/ifcfg-ethx file to activate the options when the device starts next time.

For example, ethtool-s eth0 speed 100 duplex full autoneg off this command sets the eth0 device to full-duplex adaptive, and the speed is MBS.

To set these parameters when eth0 is started, modify the file/etc/sysconfig/network-scripts/ifcfg-eth0 and add the following line: ethtool_opts = "speed 100 duplex full autoneg off"

Solution 2: Write ethtool settings to/etc/rc. d/rc. Local.

Other advanced usage:

Ethtool-A | -- show-Pause devname show pause options
Ethtool-A | -- Pause devname set pause options
[Autoneg on | Off]
[Rx on | Off]
[TX on | Off]
Ethtool-c | -- show-coalesce devname show coalesce options
Ethtool-c | -- coalesce devname set coalesce options
[Adaptive-Rx on | Off]
[Adaptive-TX on | Off]
[RX-usecs N]
[RX-frames N]
[RX-usecs-irq n]
[RX-frames-irq n]
[TX-usecs N]
[TX-frames N]
[TX-usecs-irq n]
[TX-frames-irq n]
[Stats-block-usecs N]
[Pkt-rate-low N]
[RX-usecs-low N]
[RX-frames-low N]
[TX-usecs-low N]
[TX-frames-low N]
[Pkt-rate-high N]
[RX-usecs-high N]
[RX-frames-high N]
[TX-usecs-high N]
[TX-frames-high N]
[Sample-interval N]
Ethtool-G | -- show-ring devname query Rx/TX ring parameters query receiving/sending loop Parameters
Ethtool-G | -- Set-ring devname set Rx/TX ring parameters
[Rx n]
[RX-mini N]
[RX-jumbo N]
[Tx n]
Ethtool-k | -- show-offload devname get protocol offload information get the Protocol uninstall information
Ethtool-k | -- offload devname SET protocol offload setting protocol uninstall
[Rx on | Off]
[TX on | Off]
[SG on | Off]
[Tso on | Off]
[UFO on | Off]
[GSO on | Off]
Ethtool-I | -- driver devname show driver information: displays the driver information of the corresponding device.
Ethtool-d | -- register-dump devname do a register dump register
Ethtool-E | -- EEPROM-dump devname do a EEPROM dump EEPROM
[Raw on | Off]
[Offset N]
[Length N]
Ethtool-E | -- change-EEPROM devname change bytes in device EEPROM change the bytes in the device EEPROM
[Magic N]
[Offset N]
[Value n]
Ethtool-r | -- negotiate devname restart N-WAY negotation restart N-way interaction
Ethtool-p | -- identify devname show visible port identification (e.g. Blinking) display visible port recognition (for example, the corresponding port indicator will be on)
[Time-in-seconds]
Ethtool-T | -- Test devname execute adapter self test execution adapter self test
[Online | offline]
Ethtool-S | -- statistics devname show adapter statistics display the statistics of the adapter
Ethtool-H | -- help devname show this help show help

Query network port location: ethtool-P ethx

This command is mostly used to manage server hosts with multiple network ports. because the number of network ports on the backplane is large, sometimes the physical port corresponding to eth0 or another device number is unknown, we can use this command to query.

Usage:Ethtool-P eth0

Effect:The two indicators of the physical port corresponding to the device ID eth0 will flash

Modify the network port rate: ethtool-S
This command is mostly used to manually set the network rate. Generally, a gigabit Nic supports 10 | 100 | 1000. The unit is Mbps.

Usage:Ethtool-s eth0 speed 1000 duplex full autoneg off

Effect:Set the physical port corresponding to the device number eth0 to 1000 Mbps, full duplex mode, and disable automatic negotiation.

2. miI-Tool

MII-tool (this command specifically sets the NIC working mode in Linux)

The full name of MII is media independent interface, which is literally a media-independent interface. Therefore, it is independent from a specific device. Think carefully about the standard items, which are independent from specific devices. However, many Ethernet Card devices do not support the configuration of these parameters. Therefore, when you execute the MII-tool, you will receive the operation not supported prompt, or you will not use the Super User identity, in addition, if the interface number is set to exceed eth7, If you directly use miI-tool without adding a parameter, a message such as no MII xxxxxxxxxx interface is displayed because the default value is exceeded. You can learn more about the help information.

1. view the NIC working mode and enter the following command:

# MiI-tool-V

Eth0: negotiated 100basetx-fd, link OK

Product 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

From the above information, we can see that this network card works in 100 m full duplex adaptive mode, "basetx-fd" means m full duplex.

2. Change the NIC working mode and enter the following command:

# MiI-tool-F media [interface]

Media optional modes include 100basetx-fd, 100basetx-hd, 10baset-fd, and 10baset-hd.

Interface indicates the selected Nic, such as eth0 and eth1. The default value is eth0.

For example, to set the NIC to work in 10 M half duplex mode, enter the following command:

# MiI-tool-F 10baset-hd eth0

3. Restore the adaptive working mode of the Network Adapter. Enter the following command:

# MiI-tool-r eth0

You can use miI-tool-H for more detailed usage.

Note:

MII-tool does not support NICs larger than MB

Normally, NICS of less than MB can be viewed using these two commands. However, for NICs of more than MB, The MII-tool may have problems.

 

MII-tool-V eth0

Eth0: negotiated 100basetx-fd, link OK

Product 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

# The M Nic is displayed here, which is actually a M interface

 

Ethtool eth0

Settings for eth0:

Supported ports: [TP]

Supported link modes: 10 BaseT/half 10 BaseT/full

100 Baset/half 100 Baset/full

1000 Baset/full

Supports auto-negotiation: Yes

Advertised link modes: 10 BaseT/half 10 BaseT/full

100 Baset/half 100 Baset/full

1000 Baset/full

Advertised auto-negotiation: Yes

Speed: 1000 MB/S

Duplex: full

Port: Twisted Pair

Phyad: 0

Transceiver: Internal

Auto-negotiation: On

Supports wake-on: umbg

Wake-on: d

Current message level: 0x00000007 (7)

Link detected: Yes

# A m Nic is displayed correctly.

Reference: http://linux-ip.net/html/tools-mii-tool.html#ftn.id2911850

3. nm-Tool(NetworkManager tool)

The MII-tool command can also view the connection information of related network interfaces, including the network type, connection status, carrier status, IP address, and other information. It is simpler and clearer than other tools.

Usage:

Root @ loonux:/home/# nm-Tool

State: connected (global)

-Device: ttyusb3 --------------------------------------------------------------
Type: Mobile Broadband (CDMA)
Driver: option1
State: disconnected
Default: No

Capabilities:

-Device: wlan0 ----------------------------------------------------------------
Type: 802.11 WiFi
Driver: ath9k
State: unavailable
Default: No
HW address: 00: 17: C4: EF: F7: FF

Capabilities:

Wireless Properties
WEP encryption: Yes
WPA encryption: Yes
Wpa2 encryption: Yes

Wireless Access Points

-Device: eth0 [Wired connection 1] ---------------------------------------------
Type: wired
Driver: r8168
State: connected
Default: Yes
HW address: 00: E0: 4C: 68: 00: 01

Capabilities:
Carrier detect: Yes
Speed: 100 Mb/s

Wired Properties
Carrier: On

IPv4 settings:
Address: 172.16.18.151
Prefix: 16 (255.255.0.0)
Gateway: 172.16.1.254

DNS: 8.8.8.8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.