LPI 101-500 – 109.2: Persistent network configuration
- nmcli
So we are now on the subject of persistent network configuration. I have now switched to my live system here, so I’m no longer using the virtual system for this lesson. This is because I wanted to show something with a WiFi connection that does not work with my virtual system. Because an Ethernet interface is virtualized here and not a WiFi interface, I have not yet figured out how to change that and whether you can do it at all. Accordingly, I am now on my live system with a different video recording tool with which I now have no opportunity to pause or rewind if I make a mistake or anything else. So I hope I can get through the lesson without a mistake.
Okay, we are finally back on the road in a more practical way. Hopefully the technical foundation were led in the last chapter in a satisfactory way for you. Now it’s time to get started with Linux practice in the area of network configuration. Let’s start with the so called Network Manager. This topic is relatively new to the LPIC One exam because until recently it was not a topic in the LPIC exam. The Network Manager is a demon that manages network connections and their configurations. There are graphical front ends for Gnome, Kde or Xfce that are very easy to use. Since these front ends are not an issue in the exam, we will concentrate on the console.
As always, the command line tool for the Network Manager is the nmcli tool. On my Ubuntu, nmcli is pre installed and also active. We can get an overview of our network interfaces by running Nm Cli without options. And here we see the individual interfaces, including the status and additional information on root configuration and things like that. With the nmcli device command we can only see our interface without much additional information. See here my WiFi device. Here are two Lxc bridges for Linux containers and here is my Ethernet device. And here is my loopback device. If we put a show after the word device, we get very detailed information about the corresponding devices and Cli device show.
And here we see for example the type, the hardware address, MTU connection, Ssid. We see the IP address, the gateway, the route, the DNS and so on and so on. Another interesting command is nmcli connection. This shows the corresponding connection including status and Uuid. So status is the green color. Here we are connected at the moment with our WiFi and our two network bridges from Alex are also connected. The radio option checks my WiFi connection nmcla radio and you can see here everything is activated with Nmcla Cli. You can also search for WiFi networks and display them here.
It makes sense to check the surroundings again beforehand with nmcli device WiFi rescan and we can display the result with nmcli device WiFi list. And I think it doesn’t look bad for a terminal program. How can we now disconnect the WiFi connection from a router. There are two different options here. First of all the following command nm cli connection down. And here, this is my active connection. You can see it here it is in use. This one and sorry about that. I see my life system is in German language of course. And now I have the confirmation in German. In English it means the connection was successfully deactivated with nmcli connection. We can of course check that again.
And here, this was my active connection. Now it is inactive. If we want to reestablish the connection, we simply use the following command nm cli connection up and then the Ssid. And here again, sorry for the German language. In English it means connection was established successfully. Another way to disconnect is as follows nmcli device disconnect and then the device it is Wlo one. And here the confirmation. The device Wl one was deactivated successfully. To reestablish the connection we select nmcli device connect and then Wlo one and we get the confirmation that the connection was established successfully. So the device was activated successfully.
We can check that again with nmcli connection and we see that our connection is back here.This one, it is green, it is active. So everything works fine. At this point we take a quick look at the corresponding WiFi configuration file. The Network Manager has its own configuration file for each connection. These are located in Etsy network manager and then System connections. And here we can see all the connections. And this one here is our active WiFi connection. So by the way, the file can only be opened with root rights because here, for example, the WiFi password can also be seen in plain text, which of course I have made unrecognizable in this video suit.
And we have various information here that we receive and of course settings that we can make change. You see here the ID, the Uuid type interface name. We have here our key and IP Four. The method is auto. IP Six method is auto. So usually we don’t have to make any changes in this file, but we use ncli with the edit option to do some changes. So let’s try that out. ncli connection edit and then this one. And we are now in the Injective module with the Network Manager and can now use help to see which commands are available. So help. And here you see our commands or possible commands. So let’s play through the scenario that we want to set a manual IP Four address.
By the way, tab completion works wonderfully. Here we can see above that the go to command ensures that we switch to a certain setting. We would like to edit the IP address now. So I give a Go To IP and then press Tap. Go to IP? And here IP four and IP Six are suggested to me. I then take IP four. Now we are immediately shown which settings we can change with IP four. Sorry about that. It’s in German. We have the following commands method DNS, DNS search, DNS option here addresses, gateway, route ignore, autodes, Dhcp timeout and so on and so on. So first of all we set the address assignment to Manual.
We do it with set method manual. Then we set the IP address and the gateway set. You see, addresses is for IP addresses addresses. And then for example 192, 168, 178. And let’s use 233 with the subnet mask here set here gateway. And the DNS server is also important as it usually corresponds to the gateway in the private area. So set DNS. Okay, the settings are now complete. We still have to save it though. Save. So we get the confirmation the connection was successfully edited. With Quit, we leave the interactive mode, and for the settings to take effect, we have to restart the Network Manager once. So pseudo system.
Ctl restart Network Manager we control our settings nmcli and here we see that the IP address now corresponds to the one we just added manually. In the interactive module we have the 233 and the 32s subnet mask. So let’s take another look at the WiFi configuration file. We see that the method here has now changed to Manual and that two entries have been added, namely Address One and DNS. In order to get the IP address again automatically, I could configure the whole thing again in interactive mode, but just to show it, I can of course also set this directory directly in the configuration file.
To do this, I simply remove the two newly added lines and set the method back to Auto. Let me just delete these two lines. And here I changed to auto. I saved this file and now restart the Network Manager again. And we check our IP addresses again nmcli device Show and realize that we no longer use the fixed IP address. We have the 27 now, and we have another subnet mask here. So this way also worked. As you have seen, there are a lot of other settings and functions that can be tested, which you should definitely do at this point. We close the topic Network Manager and move on to the next one, namely if up and if down.
- ifup, ifdown, hostname, hostnamectl
This lesson is about if up and if down if up and if down. If up is used to start network interfaces. If down is used to stop network interfaces, it is important for both commands that the network interfaces are already configured and that functionality is available. If you would like to look at the man page or test or if down, you will find that the programs are not installed. In my case there is a good reason, namely that if up and if down do not work if the interfaces have been configured with a network manager we talked about the network manager in the last lesson and that means we can’t even download and test them. Now. Of course we could, but here we would have to reconfigure too much for it to work, so that it would no longer be in proportion.
This is why, for once there is only theory and no practice for these two commands. There is actually not that much to explain. Here on Systems without Network Manager there is a file with the name etsy network interfaces. The corresponding interfaces are configured here. So for example the ethernet or WiFi interface. I have found an example of how such a file can look. Let me switch to my browser here. So I find this file here on Cybercitybiz and here you can see such a file. The file is usually much shorter. We see here that the interface at zero zero here is being configured, or certain settings are being made.
So it looks very similar to the configuration of the network manager. If a network interface has been configured with the help of the file etsy network interfaces so as zero here, then we can switch this interface off with if down and on again with if up. There is really nothing more to say about that. Another possibility to switch network interfaces on and off and to configure them is the system D network daemon. However, this is not part of the examination, which is why I will not go into it in more detail. Still, it’s certainly not bad to have at least heard it. This concludes the subsection network interface and let’s take a look at the computer name.
How can I find out the computer name again? There are several ways to get there. First of all there is the host name command host name. So only the computer name is displayed here in my case manual virtual box. We can also display the etsy hostname file, which also contains nothing but the host name of the local computer cat at the host name and here the same result manual virtualbox. The third option is the Hostname ctl program. Hostname ctl also shows the hostname, but also other information such as the operating system, the kernel version or the architecture. Hostname ctl you see the hostname icon name, chassis machine ID, boot ID, operating system, kernel version and architecture. With hostname ctl one could also change most of the values shown here.
Hostname ctl help will help us here. So here we have some commands set hostname, set system, hostname set location name, and so on. So to change the host name, we should use hostname ctl, set hostname and then for example, computer, and we will check it. And that worked. My new hostname is nonrecomputer. Of course, we could also change the value directly in the etsy host name file to change the hostname. So let’s do this pseudovi etsy hostname and then virtualbox New for example, hostname ctl and you see here static hostname manual. Virtualbox new is on your host name. You see, we have here the old host name manual computer. Normally it changes when you simply close and open the terminal.
And now you see here manufacturer box new. So let me switch back hostname ctl and here is my old hostname. In the past, it was possible to change the hostname with a command hostname. Then it was something like that. pseudo hostname and then a new hostname. For example, manual mb for notebook. But see here, hostname manual mb seem to work. Hostname ctl and here you see the old one is active. So it doesn’t work very well. Let’s check the etsy hostname file. And here is the virtualbox name. So I would not recommend to use this command anymore. But in the past it worked well, I don’t know why it why it doesn’t work anymore. But you have you could see that this is also a possibility. But in my case, it really doesn’t work. You.
- etc/hosts, /etc/resolv.conf, /etc/nsswitch.conf
In addition to the Etsy host name file, there is also a file called Etsy Hosts. We must not confuse them because they are two completely different files that have nothing to do with each other. Kept Etsy hosts in the Cat FC hosts file. We find mappings between IP addresses and so called FQDNs. FQDN stands for a full qualified domain name. So it is the computer name or an Internet address. The Etsy host file is the predecessor of DNS. DNS means domain name system. DNS is a directory system that assigns names to IP addresses. If there was no DNS, we would have to type in Google’s IP address into the browser instead of Google. com. However, since DNS is no longer operated via the Etsy Hosts file today, this actually only has the purpose of linking localhost with the loop back address.
Localhost is our local computer in this case. So in my case, manual NB and a loop back address is a channel with only one endpoint. Sender and receiver are, so to speak, identical. If we install a web server on our local computer and host a website there, we could reach it via the browser with the address Http and then Local Host or with the IP address or with Http and then the IP address one hundred and twenty seven zero one. So we send and receive via the same address via our loopback address, but only by the way. So you see here one hundred and twenty seven zero zero one locals the same name. In the case of private computers, DNS is regulated outside on external service that are freely accessible.
Large companies naturally have their own local DNS service. However, this is only a topic in the IPIC two exam. How is access to these external DNS service regulated via the Atcresolve. com file? So let’s take a look at that file. Etsyresolve conf the entry name server shows which DNS server is used. In my case, this is the IP address. One hundred and twenty seven zero zero fifty three. Usually, there is also an entry domain that tells the local computer which domain it is in. The search entry ensures that computers with different domains can find and reach each other under the host name. And I think there is not much more to say here about that. The last file in this chapter is at cnsswitch conf. In this case, NS stands for Name Service.
So. Name? Service. Switch. Let’s take a look at this file@cnsswitch. com. In the first line we find, for example, password. Then we find the sources that are used for password. The order does not matter here. First it says files. That means that NS switch will use files in relation to password. In that case, it would be the Etsy password file. The second data source is system D in this case. And if we were now in a server network in which there is a server that takes on the task of authorization across servers. So for example, via ldap, then we would have to enter in the Nswitch. com file. That password should first use ldap and not files. Further keywords would be DNS, NIS plus or DB for database.