Setting Network Card Duplex Settings

Note: This should be read completely before you try this, as it could cause you to lose connectivity to the server if your network doesn't support it!

Many of the asterisk servers you may install/deploy are going to be setup in someone else's network, who likely doesn't have a linux engineer, and you may not be one, so this is for you. Even experienced linux engineers often miss the little things, and this is one of them!

On any network switch, you have settings for "Full Duplex"/"Half Duplex" 10Mb/100Mb/100Mb etc.. Most of the networks that are around today, are 100Mb networks. Many of us know how to set this up on a windows PC, but have you ever wondered how you do this in linux? Or have you just hoped that using "Auto-Detect" always works... (ps.. not recommended)
Have you ever had "wierd" sip timeouts, or network disconnects to a sip provider that you just can't trace?? THIS MAY BE THE REASON! (the network card is flapping between 10Mb and 100MB or Full and Half duplex, causing packet loss). By forcing the NIC's to be the same as the switch, you eliminate this issue. It may not solve your problem, but it definitely can't hurt, and is recommended.

In order to ensure your linux server and the switch are always talking at the same speeds, I recommend that you have the onsite network engineer setup the switch port that you are plugging into to be forced to 100MB FULL DUPLEX, and the use the following tool to set this up on your network interface(s) on the server. Note: I use the following tool on Redhat/Centos (so pbxinaflash and trixbox should both be able to do this for **most** network cards. If you have an abnormal linux driver for your network card, you should know what you are doing anyway).

The tool I recommend using (because it is soo easy) is ethtool, and is likely already installed on your PBX as it is used by the ifup utilities. (If not, try "yum install ethtool" or visit - just know what you are doing..)

I take and run the following on any new machine I setup:
ethtool eth0 | grep -e eth -e Speed -e Duplex
which would show you:
Settings for eth0:
Speed: 100Mb/s
Duplex: Half
(You should run "ethtool eth0" once to see the full output!)
As you can see, the duplex reported as Half.. So I then run:
ethtool -s eth0 speed 100 duplex full autoneg off
This sets the duplex settings on the NIC.

Note If you are doing this on a remote server, it may timeout your SSH session for a moment, or if your switch port doesn't support Full-Duplex, you may not be able to re-connect, so do your homework, or have someone locally who can restart the network services or restart the machine!!!. Just doing this will only keep the setting for the current session.

Assuming it worked, you should then be able rerun the first command and you would see:
Settings for eth0:
Speed: 100Mb/s
Duplex: Full

Now. Assuming this was true, you need to make sure this gets setup after a server reboot as well.
Here's how:
Add the following at the end of /etc/rc.d/rc.local
ethtool -s eth0 speed 100 duplex full autoneg off
Add the following to your /etc/sysconfig/network-settings/ifcfg-eth0
ETHTOOL_OPTS="speed 100 duplex full autoneg off"

I hope this helps some of you properly setup a linux server on a corporate network, and for those lucky ones, I hope this helps you resolve odd connectivity issues with your sip provider (as it did for me on the first asterisk server I installed way back when, where I forgot to set this - we lost an occasional sip trunk for about 10 seconds, randomly - I found errors on the switch port, and remembered I forgot to set the duplex settings.. now no more switch port errors, and the sip trunk stopped randomly dropping).

-Richard Teachout

Taxonomy upgrade extras: