6 Going beyond the LAN

To connect to interfaces outside of a subnet, a computer must also have the default gateway and DNS servers set up. The previous step should have configured the default gateway. To check the default gateway, use the command route -n. The destination 0.0.0.0 refers to destination of all (except those in the same subnet) IP addresses. The gateway of that row shows the IP address of the router that is responsible to route packets outside of the subnet.

If this row is missing, that means the default gateway is not set up. You can manually add a default gateway using a command like route add default gw 192.168.0.254. However, you should rely on DHCP or /etc/network/interfaces to specify the default gateway.

Even with the default gateway set up, you may not be able to reach a remote machine by its domain name like google.com. This is because such a domain name must be resolved to an IP address by a DNS server. Check /etc/resolv.conf to see if the nameserver entries are properly set up. An interface using DHCP should have /etc/resolv.conf automatically populated.

For an interface using a static IP address, you may need to edit resolv.conf manually. Depending on networking policies, you may need to use a name server that is local to the subnet. Most networks allow systems to use name servers that are external to the subnet. Examples of external (Internet) DNS servers are Google’s 8.8.8.8 and 8.8.4.4. With the dnsutils package installed on a Debian system, you can check both connectivity and name resolving via the interface eth0 by ping -I eth0 google.com. If ping replies are coming back, it means the interface is connected to the subnet, the default gateway is set up correctly, and domain resolution is working correctly.