Fork me on GitHub
Suzf  Blog

Linux change the speed and duplex settings of an Ethernet card

Q. How do I change the speed, duplex on for my Ethernet card?

A. Under Linux use mii-tool or ethtool package which allows a Linux sys admin to modify/change and view the negotiated speed of network interface card (NIC) i.e. it is useful for forcing specific Ethernet speed and duplex settings.

Depending on which type of Ethernet card is installed on the system you need to use either mii-tool or ethtool. I recommend installing both and use one of the tool, which will work with your card.

Task: Install mii-tool and ethtool tools

If you are using Debian Linux you can install both of these package with following command:# apt-get install ethtool net-toolsIf you are using Red Hat Enterprise Linux you can install both of these package with following command:# up2date ethtool net-toolsIf you are using Fedora Core Linux you can install both of these package with following command:# yum install ethtool net-tools

Task: Get speed and other information for eth0

Type following command as root user:
# ethtool eth0Output:

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: Yes
     Speed: 100Mb/s
     Duplex: Full
     Port: MII
     PHYAD: 32
     Transceiver: internal
     Auto-negotiation: on
     Supports Wake-on: pumbg
     Wake-on: d
     Current message level: 0x00000007 (7)
     Link detected: yes

Or use mii-tool command as follows:# mii-tool eth0Output:

eth0: negotiated 100baseTx-FD flow-control, link ok

Task: Change the speed and duplex settings

Setup eth0 negotiated speed with mii-tool
Disable autonegotiation, and force the MII to either 100baseTx-FD, 100baseTx-HD, 10baseT-FD, or 10baseT-HD:# mii-tool -F 100baseTx-HD
# mii-tool -F 10baseT-HD
Setup eth0 negotiated speed with ethtool# ethtool -s eth0 speed 100 duplex full
# ethtool -s eth0 speed 10 duplex half
To make these settings permanent you need to create a shell script and call from /etc/rc.local (Red Hat) or if you are using Debian create a script into the directory /etc/init.d/ directory and run update-rc.d command to update the script.

Read man page of mii-tool and ethtool for more information.

Author: nixCraft

Link: Linux change the speed and duplex settings of an Ethernet card

 

How-to debug rsyslog

有时您可能会想,是否您创建的配置真的被使用。至少它的一部分没有生效,这真的可以在很多情况下发生。目前,配置格式发生了很大改变。这迫使想要使用新格式的用户使用旧的和新的配置风格的混合模式。这是可以发生很多混乱的地方,这导致不能正确设置配置变量。实际上,您只需要在配置中创建一些一致的。大多数输出​​模块已经更新。如果要使用新格式,则不能同时使用一些旧的配置指令和一些新的配置指令。旧的将被忽略。相反,将使用默认值。一个很常见的情况是队列,这是我将用于展示的例子

# grep "Debug Rsyslog" -A 2 /etc/rsyslog.conf
# Debug Rsyslog
$DebugFile /var/log/rsyslog-debug.log
$DebugLevel 2

之后重启 Rsyslog

# head /var/log/rsyslog-debug.log 

7201.157636478:7fda87eb9780: debug level 2 set via config file
7201.157787141:7fda87eb9780: This is rsyslog version 7.4.7
7201.157882255:7fda87eb9780: cnf:global:cfsysline: $ModLoad imuxsock # provides support for local system logging (e.g. via logger command)
7201.157990846:7fda87eb9780: Requested to load module 'imuxsock'
7201.158081765:7fda87eb9780: loading module '/usr/lib64/rsyslog/imuxsock.so'
7201.229115267:7fda87eb9780: imuxsock version 7.4.7 initializing
7201.229297485:7fda87eb9780: rsyslog/glbl: using '127.0.0.1' as localhost IP
7201.229537950:7fda87eb9780: module imuxsock of type 0 being loaded (keepType=0).
7201.229673687:7fda87eb9780: module config name is 'imuxsock'

Reference

[0] http://www.rsyslog.com/how-to-use-debug-on-demand/

[1] http://www.rsyslog.com/how-to-create-debug-information-with-strace/

[2] http://www.rsyslog.com/how-to-check-if-config-variables-are-used/