Saturday, December 10, 2011

FreeBSD Set Speed Duplex For My Network Card ( NIC )

How do I set / change the speed ( duplex settings ) on my FreeBSD network card? I'd like to change default 10Mbps to 100Mbps or vice versa. Linux user can use ethtool to set an Ethernet card speed and duplex, can I use the same command on FreeBSD?



A. ethtool is not required on FreeBSD. By default, the NIC auto-negotiates the speed and duplex of the connection. Make sure port speed set correctly on your switch. You need use the ifconfig command to configure the speed and duplex settings on the adapter. You also need to update your /etc/rc.conf file to set speed and duplex configuration.

Task: View Current Speed and Duplex Settings

Simply, use ifconfig command, enter:

# ifconfig em0

# ifconfig interface-name

# ifconfig | grep media


Output:

em0: flags=8843 mtu 1500
        options=b
        inet 10.10.1.2 netmask 0xffffffc0 broadcast 10.10.1.29
        ether 00:30:48:93:1e:9a
        media: Ethernet 10baseT/UTP 
        status: active

ifconfig command to change speed and duplex settings

General syntax is as follows to set 10Mbps full-duplex:

ifconfig <interface-name> <IP_address> media 10baseT mediaopt full-duplex
or
ifconfig <interface-name> <IP_address> media 10baseTX mediaopt full-duplex

Set 100Mbps full-duplex, enter:

ifconfig <interface-name> <IP_address> media 100baseT mediaopt full-duplex
or
ifconfig <interface-name> <IP_address> media 100baseTX mediaopt full-duplex

Set 1000Mbps full-duplex, enter:

ifconfig <interface-name> <IP_address> media 1000baseT mediaopt full-duplex
or
ifconfig <interface-name> <IP_address> media 1000baseTX mediaopt full-duplex

For example, set interface em0 with IP 10.10.1.2 to 100Mbps full duplex, enter:

# ifconfig em0 10.10.1.2 media 100baseTX mediaopt full-duplex

If the interface is currently forced to 100 full duplex, in order to change to half duplex you must type the following command:

# ifconfig em0 10.10.1.2 media 100baseTX -mediaopt full-duplex

The -mediaopt option disable the specified media options (full-duplex) on the interface i.e. go back to half duplex.

Make speed and duplex settings permanent

To make configuration changes persistence, update /etc/rc.conf file. Open config file using text editor, enter:

# vi /etc/rc.conf

Find line that read as follows:

ifconfig_interfacename="...."

To set em0 interface to 10Mbps full, enter:

ifconfig_em0="inet x.x.x.x netmask y.y.y.y media 10baseT mediaopt full-duplex"
or
ifconfig_em0="inet x.x.x.x netmask y.y.y.y media 10baseT/UTP mediaopt full-duplex"

To set em0 interface to 100Mbps full, enter:

ifconfig_em0="inet x.x.x.x netmask y.y.y.y media 100baseT mediaopt full-duplex"
or
ifconfig_em0="inet x.x.x.x netmask y.y.y.y media 100baseTX mediaopt full-duplex"

To set em0 interface to 1000Mbps full, enter:

ifconfig_em0="inet x.x.x.x netmask y.y.y.y media 1000baseT mediaopt full-duplex"
or
ifconfig_em0="inet x.x.x.x netmask y.y.y.y media 1000baseTX mediaopt full-duplex"

Make sure you replace x.x.x.x and y.y.y.y with actual IP and netmask address. Here is entry from my own personal FreeBSD workstation:

ifconfig_em0="inet 10.10.1.2 netmask 255.255.255.0 media 100baseT/UTP mediaopt full-duplex"

Save and close the file. Restart the networking:

# /etc/rc.d/netif restart


Note: There are five physical layer standards for gigabit Ethernet using:
- optical fiber (1000BASE-X)
- twisted pair cable (1000BASE-T) (Cat‑5, Cat‑5e, Cat‑6, or Cat‑7)
- twisted pair cable (1000BASE-TX) (Cat‑6, Cat‑7)
- balanced copper cable (1000BASE-CX).

Reference:
http://en.wikipedia.org/wiki/Gigabit_Ethernet
http://www.cyberciti.biz/faq/howto-configure-freebsd-full-half-duplex-speed/

1 comment:

duplex filter said...

This is a really good read for me. Must agree that you are one of the coolest bloggers I ever saw. Thanks for posting this informative article.