Most Linux distros today will automatically configure your network as soon as you boot. Indeed, most will set up networking for you as you install. However, there is a (very small) chance something conks out and you end up having to do things by hand, or you may need some sort of special configuration.
If you’re having trouble connecting to your home or office network, the first thing to check is your hardware.
Although support for wireless cards is pretty universal in GNU/Linux nowadays, support for wired network cards is even more universal. If you are not getting a WiFi connection right of the bat and your computer has an RJ45 network port, i.e. one of these:
Use it! The main thing for now is to be able to connect to the net so that solving your problem is easier.
Wait a few seconds after plugging the network cable in and then try pinging an internal IP address, e.g. your router. If that works, try an external IP, for example 22.214.171.124, and then an external web address, such as google.com.
Still no network? Network cables break. Often. Change the cable, make sure it is firmly plugged in and run through the ping routine described in the paragraph above again.
Modules and Cards
If you still don’t have a working connection to the net, check your network card is recognised. It would be rare if it wasn’t, but use
lspci all the same. My machine gives me:
# lspci -k | grep -A 2 -i net 03:00.0 Network controller: Intel Corporation Centrino Wireless-N 1000 [Condor Peak] Subsystem: Intel Corporation Centrino Wireless-N 1000 BGN Kernel driver in use: iwlwifi -- 05:00.0 Ethernet controller: Qualcomm Atheros AR8151 v2.0 Gigabit Ethernet (rev c0) Subsystem: ASUSTeK Computer Inc. Device 1851 Kernel driver in use: atl1c
This shows the drivers are loaded,
atl1c for the wired Ethernet and
iwlwifi for the WiFi.
If your network cards don’t show up, or do show up, but there are no drivers loaded for them, there’s your problem. Do some research into your hardware. Again
lspci can be helpful here — even if it does not identify your card as a network card, it can tell your the manufacturer and the name of the internal chipset so you can look it up on the Internet. Look for the module for your distro online, compile it and load it in by hand with
# insmod [module_name]
and run through the lspci and ping routines again to see if things have improved at all.
All your drivers are loaded but still can’t connect? Check the network subsystem and see if it is up. In modern Linux distros, the network subsystem is managed via systemd.
To check if it is up, you can run this as a regular user:
$ systemctl status NetworkManager # systemctl status NetworkManager • NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled) Active: inactive (dead)
That, by the way, is what a network subsystem looks like when it is down — see where it says
Active: inactive (dead)? That’s your problem right there.
To get the network up (or restart it), try this as root:
# systemctl restart NetworkManager
And then check the status again:
$ systemctl status NetworkManager • NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; enabled; vendor preset: disabled) Active: active (running) since Tue 2015-10-13 14:43:15 CEST; 1min 6s ago Main PID: 2382 (NetworkManager) CGroup: /system.slice/NetworkManager.service 1335 /sbin/dhclient -d -q -sf /usr/lib/nm-dhcp-helper -pf /var/run/dhclient-enp5s0.pid -lf /var/lib/NetworkManager/dhclient-ff9bcd90-6213-4084-900d-ce27dcfaab82-enp5s0.lease -cf /var/lib/NetworkManager/dhclien... 2382 /usr/sbin/NetworkManager --no-daemon
Active: active (running) line.
See if you have network connectivity by running through the ping routine suggested above again.
To summarise, follow the list of tasks below to solve most connectivity problems like a pro:
- Connect a cable to the RJ45 port on your computer.
- Try pinging an external machine.
- Check the cable!
- Try pinging an external machine again.
- Check the availability of a driver for your hardware with
- Find and load a driver by hand with
- Ping that thing!
- Check network subsystem with
systemctl status NetworkManager.
- Restart network subsystem with
systemctl restart NetworkManager.
- Ping, ping, ping!
In part 2 we delve into the intricacies of configuring a makeshift wired connection by hand with and without DHCP, using the new set of GNU/Linux networking tools. Especially useful, when despite doing all of the above, you still can’t get online.
In part 3 we turn our sights onto WiFi connections. You learn how to troubleshoot and set up step by step a wireless connection manually, which in itself is a whole new kettle of fish.