I've already set up ADSL and used it already for a system update, so I'm sure the set up is ok but pacman suddenly stopped working and when I checked ping wasn't working too. How can I find out what went wrong and how can I fix it?
IP Network Troubleshooting
There are a few standard things you can look for when you are experiencing network connectivity issues. These are listed here from a top-down, or least fundamental to most fundamental issues.
All the example
ip commands shown here use a Linux-specific tool called iproute2. Many of the tasks can likely be done with
route, but the syntax depends on the system. You can start looking for the correct command for your system on the Rosetta Stone for Unix (thanks @Gilles).
Is access down to one site and not others?
If you've just noticed a website or service is down, try others before concluding that you are the one experiencing problems, and not the website you are trying to visit.
Is DNS not working?
DNS resolves domain names to ip addresses. If it isn't working, you may be able to access services by ip address but not domain names. To test for this, use
ping -c 2 188.8.131.52
184.108.40.206 is the IP address of a Google server on the internet that should always be up; it can be replaced by any IP address known to be on the target network. This command sends two ICMP echo packet to a specific IP address; it doesn't rely on DNS to work. If the command works, replace the IP address with a domain name known to be working on the target network, like
ping -c 2 yahoo.com; if this doesn't work, the problem is likely to be DNS. As a quick fix, you can try opening
/etc/resolv.conf and adding
nameserver 220.127.116.11 after the last line (note, you may need root privileges to edit the file). That address happens to be a DNS server, and adding it to resolv.conf will tell your system to use it. If that doesn't work, you should submit another question with more details.
Is there a route to the network?
To reach a network, your system has to know how to route to it. To see the routes your system knows about, we need a couple of commands.
ip rule show
This command lists any routing rules that are setup on your system. If you see only three entries (lines) and they end in 'local', 'main', and 'default', then you have only the standard rules setup. If there are any other entries, note them; in particular, the last word of the line – they are names of routing tables.
ip route show
This command shows routes setup on the main table. There should usually be an entry that directs traffic to the target network. For internet connections, it is a route that looks like
default [via address] dev [dev]... where you may or may not have the 'via' part, and '[dev]' may be something like 'eth0' or 'wlan0' that represents which network interface the network is on.
Previously I said that there should usually be an entry there. If you had other tables setup and a rule pointing to them to look at the entries in other tables by using the following, replacing
[table name] with one of the names you noted in the previous (ip rule) step.
ip route show table [table name]
If you do not have a route to the target network, you need to add one (or modify your network setup so it automatically adds the correct one for you). If you don't know how, ask a more specific question here, armed with this knowledge.
Is the network interface up?
To be able to use a network interface it has to be up and it should have an address. You can find if it is up by using:
ip link show
This lists the network interfaces on your system. You should see at least two, one called "lo" and another entry for each network interface on your system. If you have a wired and a wireless interface, you might see 'lo', 'eth0', and 'wlan0' or 'lo', 'eth0', and 'eth1' whatever they are – that first bit after the entry index is the name of the network interface. For each of the interface entries, you should also see either 'state UP', 'state DOWN', or 'state UNKNOWN'. If the network interface that is connected to the target network is not present, it can be that the hardware driver isn't loaded or working (for actual network cards) or for PPP connections, that there is no connection established. If it says the link is down or unknown, the interface needs to be brought up. This is usually done by your system's networking setup – if it's not up, you can ask a more specific question here with this in mind. It can be done manually by the following command, replacing
[dev] with the interface name (you may need root privileges).
ip link set dev [dev] up
Does the network interface have an address?
In addition to having the interface up, it needs to have an IP address. You can find the addresses of your interfaces by running the following command.
ip address show
You'll see an entry for each of your interfaces with all the addresses it has. Most entries will have a link address, the important part is the IP address. There should be a line labeled 'inet' with an address for the network interface connected to the target network. It should be added automatically by your networking setup; if it wasn't, a dhcp client may not be running, or the ppp daemon may not have added it – you should ask a more specific question here with this in mind. One can be added manually (but depending on the network may not work) by the following command, replacing
[ip address] with an ip address appropriate for the network (which may be unknown if the network supplies IP addresses via DHCP or PPP) and replacing
[dev] with the interface name.
ip address add [ip address] dev [dev]