From the course: Practical Linux for Network Engineers: Part 1

DHCP client

- [Instructor] Now in Linux, rather than using a single configuration file, like we have in Cisco IOS, so something like this. Linux uses multiple files for storing configurations. So as an example, the et cee, or et cetera, or E-T-C network interfaces file, contains details of interfaces on the Ubuntu computer. Cat allows me to print out the contents of a file. So I can see this sample network configuration which was added by the GNS three developers we're told that we need to un-comment lines to get it to work. So I'm gonna use Nano which is a basic text editor similar to Notepad to edit et cee network interfaces. And all I'm gonna do is un-comment these two lines. This line means that the first ethernet interface, in other words ethernet zero is gonna be enabled, and we going to allocate IP addresses to this interface using DHCP. I'm gonna press Control + X to exit out of Nano. And I'm gonna save the file. And I'm gonna overwrite the current file. So cat, et cee, network, interfaces. And what I'm doing here is I'm constantly pressing tab, so similar to a Cisco router, if you type a few characters and press tab, it will auto complete. So if I type cat E-T, press tab, notice it auto completes? N-E-T tab, auto completes. If I use I, single tab does nothing. Tab tab gives me the various options. So press tab twice to see multiple options. Type in, tab now, auto completes, I can see the configuration file, and notice these two lines are un-commented. Now this specific docker container doesn't support this command. Notice the service is unrecognized. On other Linux implementations, there will be commands such as service networking restart or others that allow you to restart the networking service, which means that it'll automatically re-read this file and change its configuration based on this file. That doesn't work on this docker container, so I'm gonna stop it and I'm gonna start it up again. And then I'll open up a console to the docker container. So I'll close the old console. Here's the new one. And notice it's obtained an IP address through DHCP. So ifconfig now shows us that this PC has an IP address of 10.1.1.2 and I can ping the Cisco router from the Ubuntu docker container. What I'll do is stop this container. Go on to the Cisco router and do debug IP DHCP server and let's do packets. And I'll start up the docker container again and open up a console. Notice we see a lot of options on the Cisco router now? So here's where we run the debug. The docker container or Ubuntu PC if you prefer has obtained this IP address through DHCP. Router received a DHCP discover from the client. So discover was received on gigabit zero, zero. The router's creating an ARP entry for this client. Again ifconfig shows us the MAC address of the docker container or Ubuntu PC which you can see is the same as this. So the Ubuntu container obtained an IP address through DHCP, the router essentially offered the IP address to the client. Bootp reply sent to the client. Here's the DHCP request from the client requesting the IP address offered, and here's an acknowledgement back from the router to the client. So on the router, show IP DHCP binding. We can see that this IP address is allocated to this docker container, in other words this one here. Notice previously this IP address was allocated to this docker container. The MAC address of the docker container changed because we turn it off and then turn it on, and in that scenario the MAC address was change.

Contents