Slow Internet on Ubuntu when using a switch
Switches, Routers, Wires and speed
As usual internet was fast on ubuntu as it used to be till I needed to plug more PCs into the adsl route lying nearby. After connecting all computers and the adsl router to a switch I noticed that on one of the PC (Ubuntu 8.04) internet became really slow. Rest of the 2 PCs one on Ubuntu 8.10 and another on Ubuntu 8.04 had internet working fine. This slow internet PC was also the oldest of the 3 . After checking everything it was clear that the problem was related to ethernet.
The problem arises, when the switch/router or any hardware is not able to handle fast speeds and duplex mode transfers. To fix this, the ethtool command can be used to alter the settings of the network interface to lower optimum values that the network infrastructure can handle.
In this case setting the ethernet speed to 10mpbs and turning off auto negotiation was found to be the solution.
sudo ethtool -s eth0 duplex full speed 10 autoneg off
You can also try setting duplex to half.
Apart from this the internet connection may be slow due to many reasons like hardware problem , same IP given to 2 machines , IPv6 issues etc.
You can first check if the issue is really related to the switch/ethernet cables by pinging your router. In most cases the router ping time should be less than 1ms
$ ping 192.168.1.1 PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data. 64 bytes from 192.168.1.1: icmp_req=1 ttl=254 time=0.679 ms 64 bytes from 192.168.1.1: icmp_req=2 ttl=254 time=0.775 ms
If the ping time is something very high compared to that value, then its definitely a issue with the network hardware or configuration.
If the above ethtool command fails to solve the speed issue, then there might be a problem with the ethernet wires or the switch itself. So you have to try replacing them and check.
If the above command solves the problem and you want to run it everytime the system starts, then add it to the " /etc/rc.local" file so that it gets executed on every boot.
#!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. ethtool -s eth0 duplex full speed 10 autoneg off exit 0
This problem is not specific to just ubuntu. It can occur on any system like windows, if the network components are not able to handle large speeds.
Also note that applying the above command has a drawback, that it will restrict the file transfer speed between local network peers to 10mps. So even if your router and switch can support upto 100mpbs the file transfer speed gets limited.