Jack Wallen shows you how easy it is to set a static IP in Rocky Linux 9 from the terminal.
Rocky Linux 9 is a brilliant server operating system that comes from the man who created CentOS. This operating system offers plenty of features that well serve enterprise needs. Given that most admins are already familiar with the likes of Red Hat Enterprise Linux and CentOS, they shouldn’t have any problem getting up to speed with Rocky Linux either.
SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)
However, there is one issue that you’ll need to deal with almost immediately: the IP address. Out of the box, Rocky Linux defaults to DHCP for its IP address. Yes, you can configure a static IP address during installation, but that step tends to slip past admins wanting to get the OS up and running quickly. Even I’ve found myself guilty of forgetting to set the IP address to manual in the name of speed.
When that happens, what do you do? You do what all good admins do: Don your best geek hat, and dive into the configuration. Let me show you how it’s done.
What you’ll need to set a static IP address in Rocky Linux
The only things you’ll need for this are a running instance of Rocky Linux 9 and a user with sudo privileges.
I’m going to assume you did not install Rocky Linux with a GUI, as configuring a static IP via the network manager UI is very simple (Wired Settings | IPv4 | Manual). Instead, we’re going to do this from the command line.
Fun times! Let’s get to work.
How to set a static IP address
Log in to your Rocky Linux instance and you should find yourself at the terminal. You mustn’t do this over SSH, because you will wind up unable to reach the server at one point. Because of that, make sure you are physically at the Rocky Linux server terminal.
The first thing you’ll do is locate the name of the network interface to be used, which is done via the command:
ip a
You’ll be looking for a name like enp0s3, which will already have an IP address assigned via DHCP.
For example, mine looks like this:
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 08:00:27:e1:01:43 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.190/24 brd 192.168.1.255 scope global dynamic noprefixroute enp0s3
Now that you know the name of the interface, we’ll be using an ncurses tool, named nmtui, to set the address. Issue the command:
sudo nmtui
In the resulting window (Figure A), select Edit A Connection and hit Enter on your keyboard.
Figure A
In the next window, select the name of the interface you want to edit using your arrow keys, tab to the right pane, select Edit and hit Enter on your keyboard.
In the resulting window (Figure B), tab down to IPv4 CONFIGURATION <Automatic> and hit Enter on your keyboard.
Figure B
A popup will appear where you’ll need to select Manual with your arrow keys and then hit Enter on your keyboard. Tab to <Show> and hit Enter to reveal with static IP address configuration (Figure C).
Figure C
Tab down to each section and configure Address, Gateway, and DNS servers at a minimum. Do note that with the DNS server configuration, you must add one per line — no comma-separated values.
Once you’ve configured those bits, tab down to OK and hit Enter on your keyboard. You then need to back out of the Edit window and go to Activate A Connection. Deactivate the interface and then reactivate it by tabbing to Deactivate (Figure D) and hitting Enter on your keyboard.
Figure D
Once you’ve activated the interface, the new static IP address will take effect and you’re ready to work.
And that’s all there is to set a static IP address on Rocky Linux. If you’re paying attention during the installation process, you can take care of this task before the OS is deployed. But, if you’re like me and you regularly overlook that step, you now have the knowledge to fix that oversight.
Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.
For all the latest Technology News Click Here
For the latest news and updates, follow us on Google News.