ifconfig dhcpYour computer connects to a network using a specific protocol or “language” to speak to other computers. The network protocol sets the rules for communication. The Internet’s protocol is TCP/IP, so most network administrators use it for internal computer communication for a company network. You can configure and view some of the network administrator’s settings using the “ifconfig” command line application in Linux.

Get some TCP/IP training and understand the Ifconfig utility

What is DHCP?

Dynamic host configuration protocol (DHCP) is the “language” for configuring IP addresses for computers on your network. Previously, IT administrators would manually set IP addresses for each computer on the network. This became an issue for network administrators who had to manage hundreds or thousands of computers on a network. Network administrators had to keep track of IP addresses, then retire old addresses when people left the company, and then apply unused IP addresses to a computer.

The problem is if you accidentally assign the same IP address to more than one computer, one computer will kick off the other. You have a network collision. The reason is because the computer’s IP address is its address. The IP address is how one computer can send you a message. This includes email, network files and Internet communication. If you have two computers with the same IP address, the network routers don’t know where to send the data, so a network collision occurs.

Learn how to build your own home network at Udemy.com

DHCP helps administrators manage IP addresses. Instead of manually setting IP addresses for each computer, the administrator sets up a server on the network (it can also be a router that is set up for DHCP) and lets the DHCP server handle IP management and assignment. When you turn on your computer, the computer looks up the DHCP server and this server assigns an IP address along with other information such as default gateway and DNS servers.

Using the Ifconfig Utility in the Command Line

The Ifconfig utility is a small program you can use from the Linux command line. Just typing the “ifconfig” command into the command line displays fairly straightforward results. The command list your network interface cards along with several settings including the IP address for both IPv4 and IPv6 and several network statistics.

Type “ifconfig –v” Some adapters are virtual and some computers come with more than one network card. You probably only think of your computer with one network card, but it’s possible to have several including virtual ones that work with specific programs.

There are now two versions of the popular IP protocol. The old IPv4 is the old address format that has 4 segments where each range from 0 to 255 (although 0 and 255 are generally reserved for other hardware).

Understand how to set up IP addresses and subnets

IPv6 is the newer IP address range that was invented because IP addresses were running out since the Internet is filled with trillions of web pages.  The IPv6 address is hexadecimal numbers, so you have 0 to 9 and A to F, which is a base 16 number set.

You’ll also notice the subnet mask. The subnet mask is a way to segment your network. The default for a home computer is Other subnet masks are used to segment larger networks using the masks and routers.

Type “cat /etc/resolv.conf” into the command line. This command also shows all IP configurations for your adapter. This is useful when you think you might have IP configuration issues or you need to check the DNS settings for your network. DNS servers are the machines that keep records of friendly domain URLs and their associated IP addresses. When you type a URL into your browser, the computer first does a lookup from a DNS server to get the associated IP address and then uses that address to find the server and website. Just like a web server, your computer has an IP address that is unique to your computer on the network. Web servers also have a unique IP address.

You use this “cat /etc/resolv.conf” view to identify your DNS servers. You can then use the “ping” command to ensure that your DNS servers are functioning. If they are not functioning properly, you might not be able to browse the Internet.

If you think any settings are not working, your administrator can reroute your traffic and change the default gateway and DNS servers. When this happens, you need to requery the DHCP server. You can do this by typing “sudo dhclient -r” and then “sudo dhclient” in the command line. What this does is query the DHCP server and reassign you a new IP address, subnet mask and DNS servers. Usually, when you issue this command, the same settings are used, but this command sometimes fixes issues if your network administrator has changed settings on the network.

The ifconfig command is great when you need to troubleshoot your computer’s network connection. It’s also useful in your home when you have your computer connected to a home router or even a DSL or cable modem. Your cable or DSL company uses TCP/IP to connect you to the Internet, so you can use the command line utility to troubleshoot connections to the Internet as well.

The ifconfig utility is just one of several utilities available in the command line, but to understand the data returned by these tools, you must be able to understand TCP/IP and network communications.

Get to know TCP/IP and common protocols on the Internet

Command Line students also learn

Empower your team. Lead the industry.

Get a subscription to a library of online courses and digital learning tools for your organization with Udemy for Business.

Request a demo