Network Managers IPv4 Routes Creation with nmcli: Alternative Manually Deleting Routes
Network managers are essential tools for managing network interfaces, IP addresses, and routes on Linux systems. This article focuses on creating and deleting IPv4 routes using the command-line tool, nmcli, on a network device that requires 100% uptime for Internet access, such as a cellular modem or an Ethernet interface for Modbus TCP connection.
Understanding IP Routes
IP routes are rules that determine how network traffic flows between devices. They define the path that packets take to reach their destination. Each route contains information about the destination network, the gateway, and the interface to use.
Managing IP Routes with nmcli
nmcli is a powerful command-line tool for managing network interfaces, IP addresses, and routes on Linux systems. It is a part of the NetworkManager package and provides a simple and efficient way to configure network settings.
Creating IPv4 Routes
To create an IPv4 route using nmcli, you need to specify the destination network, the gateway, and the interface to use. The following command creates a route to the 192.168.1.0/24 network, with the gateway at 10.0.0.1, using the eth0 interface:
sudo nmcli connection modify eth0 +ipv4.routes "192.168.1.0/24 10.0.0.1"
You can add multiple routes by separating them with a space:
sudo nmcli connection modify eth0 +ipv4.routes "192.168.1.0/24 10.0.0.1 10.0.0.2/30"
Deleting IPv4 Routes
To delete an IPv4 route using nmcli, you need to specify the destination network and the gateway. The following command deletes the route to the 192.168.1.0/24 network, with the gateway at 10.0.0.1:
sudo nmcli connection modify eth0 -ipv4.routes "192.168.1.0/24 10.0.0.1"
You can delete multiple routes by separating them with a space:
sudo nmcli connection modify eth0 -ipv4.routes "192.168.1.0/24 10.0.0.1 10.0.0.2/30"
Alternative: Manually Deleting Routes
If you prefer to manage IP routes manually, you can use the ip command. The following command deletes the route to the 192.168.1.0/24 network, with the gateway at 10.0.0.1:
sudo ip route del 192.168.1.0/24 via 10.0.0.1
Managing IP routes is an essential task for network administrators. The nmcli command provides a simple and efficient way to create and delete IPv4 routes on Linux systems. However, if you prefer to manage IP routes manually, you can use the ip command. This article has covered the key concepts and provided detailed instructions for managing IP routes on a network device that requires 100% uptime for Internet access, such as a cellular modem or an Ethernet interface for Modbus TCP connection.
References
Types of references: online resources