Red Hat Enterprise Linux (RHEL) is a rock solid commercial grade Linux operating system. If you're interested in learning RHEL from a system admins perspective then this course is for you!
The "Red Hat Enterprise Linux Technical Overview" course walks you through many of the basic system admin tasks and concepts required to administer RHEL effectively.
This course will provide you with insights to:
- Working with the Terminal
- Understanding the Kernel and User Spaces
- Graphical User Interface
- File management and the File System Hierarchy
- Editing Files using Vim
- Organizing Users and Groups
- File Permissions
- Managing Software
- Configuring Networking
- Controlling System Startup Processes
- Introduction to Containers
- Overview of Cockpit
Hey guys! right now, we are going to talk about Networking and networking is handled by a service called network manager and it's quite a cool service.
You can interface with it by using the graphical user interface or more commonly its command line client which is called nmcli. Now, network manager manages your connections using profiles.
To show the profiles that we have, we can make use of the command nmcli con show. Now, something that I really like about using nmcli is that you can tab complete the heck out of it. So, if you don't know how to use it, you can simply say nmcli and then I don't know what comes after that. So, I'm going to hit tab twice and it says well, these are the sub commands.
Now, gave you a bit of a clue. We can make use of the command nmcli con show.
Con is the abbreviated form for connection.
So, let's go find out what connections we have.
So, I'm going to say co tab. Okay! what comes next?
I don't know. Let's going to hit tab again and you can see right now that we have a number of sub commands that are applicable to connections. So, we're going to do a connection show and like I said network manager makes use of profiles.
We have a profile right now called wired connection 1. Our profiles have got a UUID associated with them.
Just be, just in case someone has created a profile with the name that is already in use. So, the UUID will ensure that it's even more so unique because the UUID stands for Universally Unique Identifier and what you can see over here is that this is an ethernet based profile and it uses a device that is present in my system called enp1s0. So, generally when you have a device file, a networking device file that begins with en that is an ethernet based network adapter. So, what are we going to do right now is that we want to reveal the properties even more so detailed properties of that particular profile.
So, how we do that is by saying nmcli connection show and then the name of the profile. If it has spaces, you can tab completed. It would put a backslash in front of every space or what you could do is that you can encapsulate it either using single or double quotes. So, what are you looking at right now, is the output of nmcli con show against a profile and you can see that we have a number of attributes and property combinations on the left hand side, over here on the right hand side, you can see the values associated with those property and attribute combinations. So, things like the connection id, Wired Connection 1.
So I'm going to scroll a little bit further down. I'm going to use the spacebar to page down. You can see that we have the ipv4.method which is set to manual. So, we're configuring tcp/ip in this particular case and using a static configuration. We have ipv4.dns.
You can see the dns server, the dns search order that we are making use of.
And then at the bottom over here, we have the IP addresses themselves as along with the gateways that we are making use of.
So, what I'm going to do right now is that, I'm going to add a brand new connection profile and we can add a brand new connection profile for the network interface that we have. Another way to display the network interfaces would be to make use of the command nmcli and we could say de for device and again type in de hit tab twice and you could see that it would automatically complete to device.
What comes after that? Don't know, hit tab twice and we want to show the devices that we have. So, we're going to say nmcli device show. So, right, at the top over here we have a device, enp1s0 that we are going to be using right now.
So, the command over here guys, I'm going to say nmcli con and we're going to add a brand new connection profile. So, con add.
So, what comes afterwards? Don't know.
Hit tab twice. Let's go and find out. So, we could go and say a number of these things like, right now, like the connection name. So, we're going to say con-name.
We're going to give the connection name static-connection and now we're going to go along and specify some additional properties. So, guys, I'm going to quickly clear my screen and just to show you that we can continue to tab complete this, obviously a tab twice and you can see all the other properties.
So, at the very least what I need to do is specify things like the connection type, this is an ethernet based connection. Now, if you didn't know that you could say type and then hit tab twice and you can see the different options over here. So, this is going to be an ethernet based connection. Okay, what else?
I'm going to tell it to use an interface and I'm going to say ifname and the interface that we are going to use is enp1s0. Now, at this stage, I could go and specify some additional properties but I'm not going to do that I'm just going to hit enter right now. So, what you can see is that, I do indeed have a new connection that has been added. It's called static-connection. That is the profile and just looking at the output of nmcli con show, you can see that one is sort of colorized in green the other one is not. The one that is colorized in green, is the currently activated profile and if you only wanted to display active profiles, you could say --active like that. Now I've got two profiles.
They are both wanting to make use of the same device and well that wouldn't be possible. Right, I mean two profiles using the same device. So, only one profile can be activated at a time in this particular case and the one that is activated right now is wired connection 1. If you needed to do something like change the properties of a profile, what you could do is, say nmcli con mod to modify other properties. So, what are we all going to modify right now would be a static connection. Now, what about static connection are we going to modify? Hit tab twice and it says, well, they are two hundred and twenty nine possibilities. Do you want to display them all? And that's probably a bad idea.
So, at the very least guys, what I'm going to do is, change properties like; how about an ip address? So, I'm going to say nmcli con mod. We're going to modify a property ipv4 and an attribute called addresses and the value that I'm going to give it, is 10.0.0.0/24 bit subnet mask.
So, let's going to hit enter over there. So, that property change has been influenced right now. Let's going to add a gateway. So, the command is nmcli con mod and we're going to do it for a static connection ipv4.gateway and now we're going to set the gateway to be 10.0.0.254 and if I wanted to go along and set up a DNS server, I could do so easily by saying nmcli con mod and then the name of the profile, then the attributes and property combination. So, in this case it's ipv4.dns and I'm going to use my gateway as my dns server. Done, that easy.
So, let's going to show the results of that.
So, the command right now is going to be nmcli con show and then the name of profile and I'm just going to call out some of the changes that we had made. So, first of all this is making use of an interface called enp1s0. It is set to automatically be initialized whenever network manager starts up. Let's go any page down. The ipv4 method over here set to auto. We're going to change that very shortly to manual. You can see the DNS server that we are making use of is 10.0.0.254.
Scrolling a little bit further down, you can see that we have ipv4 addresses. That's the IP address that we had set along with a gateway right now.
So, one thing that we haven't done is activated this profile. So, if you have a look at again at the output of nmcli con show, you'll see that static connection is not the active profile. Now, I could easily go and do that right now.
I could go and bring it up by saying nmcli con up and in the name of the profile.
However, that would disconnect me from the server because I am SSHed into server.
So, instead what I'm going to do is that I'm going to show, you how that command would work against the profile that is currently running. So, what I'm now going to do is use nmcli con and we're going to delete a profile.
So, again tab completed and we're going to delete static profile or the static-connection and what I'm going to do instead right now, is that the IP address that I'd previously allocated, that I'd said to be used for that profile. I'm going to give it to the current profile.
So, right now I'm going to say nmcli con mod. We're going to modify wired connection 1. What we are going to modify about it, is ipv4.addresses and we're going to set the additional IP address to 10.0.0.1/24 bit subnet mask. Now, should I hit enter at this stage? I'm going to be over writing the current IP address. So, instead of what I'm going to do to add an IP address, I'm going to say + and then the property and attribute combination along with the with the value. And there we go. So, now if you have a look at the output of nmcli con show against wired connection, you will see that there are two values for an IP address. You can see over here that ipv4 addresses and you can see we have a comma-separated list over here and we have two addresses right now. 172.25.250.10 and 10.0.0.1 both with 24 bit subnet masks. So, let's go do that one more time.
For ipv4.dns, we want to set multiple dns servers. So, look at the dns server that is currently set. it's 172.25.250.254.
So, what I'm now going to do is say nmcli con mod. We're going to modify wired connection1 and we're going to change ipv4.dns and are we going to use 22.214.171.124.
So, let's going to hit enter right now. Now, at this stage guys, what I've done is that, I've overridden the current dns configuration.
So, if you have a look at the output of nmcli con show, and we go down to your ipv4.dns, you can see that I no longer have the 172 IP address. So, let's go and put that back. So, what I should have done in that case is that I should have said +ipv4.dns and then specify the dns servers that I want to make use of.
So, at this stage I'm going to go and add 172.25.250.254 to the current list and there we go.
That should do it and if you have to look at the properties associated with that profile, you can see right now that we have 126.96.36.199 and 172.25.250.254.
Now, like I said the changes that I'd made are not yet put into place and if you have a look at the output of the command ip, a for address, s for show, and we're going to show the ip address that is currently associated with the interface that we have. So, it's enp1s0.
You can see that if we only have one ip address. We don't have the 10.0.0.1 ip address. Because again, we haven't sort of re-up that profile. Similarly, if you go and look at where our dns server settings are stored, it's inside of a file called /etc/resolv.conf. It's got no sort of record of 188.8.131.52 being used in that case.
So, what we are now going to do is run nmcli con up for wired connection. So, we're going to re-up the profile. We're going to put into play the changes that we had made. So, let's going to have a look at the ip addresses that are associated with the interface and you can see that now, we have the 10.0.0.1 ip address. Similarly, you should find that /etc/resolv.conf has been changed. So, now we have more than one dns server. In fact, we have 184.108.40.206 as the first dns server that is being utilized over here.
So guys, that is a very basic overview of what network manager is and how it works and how we can interface with it. It's easy to use and one of my favorite features is the tab completion that is supported.
Jeremy is a Content Lead Architect and DevOps SME here at Cloud Academy where he specializes in developing DevOps technical training documentation.
He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 25+ years. In recent times, Jeremy has been focused on DevOps, Cloud (AWS, GCP, Azure), Security, Kubernetes, and Machine Learning.
Jeremy holds professional certifications for AWS, GCP, and Kubernetes.