# Setting Up Static Routes on a Red Hat Server Using NMCLI
Static routes are an important part of network administration. They provide instructions to servers and other network devices on how and where to route network traffic. These routes are specific and do not change unless manually altered by an administrator. In this article, we’ll discuss how to set up static routes on a Red Hat server using the Network Manager Command Line Interface (NMCLI).
## Introduction to NMCLI
NMCLI is a command-line interface for managing NetworkManager (NM) and reporting network status. It’s designed to be simple, script-friendly, and suitable for automation, batch processing, and scripting.
## Setting Up Static Routes
Before we begin, we need the name of the network connection on which we want to set the static route. This can be done using the command:
“`
nmcli connection show
“`
This command displays a list of all current network connections on the server. Look for the name of the connection you wish to edit in this list.
The next command we will use is:
“`
nmcli connection modify YourConnectionName +ipv4.routes “192.168.1.99/32 192.168.1.1”
“`
Here, replace “YourConnectionName” with the name of the connection you wish to edit. This command adds a new static route to the specified connection. The route directs traffic for 192.168.1.99 via the gateway 192.168.1.1.
You can remove an added static route using the following command:
“`
nmcli connection modify YourConnectionName -ipv4.routes “192.168.1.99/32 192.168.1.1”
“`
This command does the opposite of the previous one. It removes the static route that directs traffic for 192.168.1.99 via the gateway 192.168.1.1.
To apply the changes, the network connection needs to be restarted. This can be done using the following command:
“`
nmcli connection down YourConnectionName && nmcli connection up YourConnectionName
“`
This command first turns off the network connection and then turns it back on. This allows the changes you’ve made to be applied.
You can check the current settings of your connection using the following commands:
“`
nmcli connection show YourConnectionName | grep routes
“`
This command displays all routes set on the specified connection.
“`
ip route show
“`
This command provides an overview of all routes on the server, regardless of the specific connection.
## Conclusion
Setting up static routes on a Red Hat server can be easily done using NMCLI. By using these commands, you can effectively manage your network traffic and ensure that your server is communicating efficiently within your network.