Digital Marketing

Add Permanent Routes in CentOS

Method One : Using nmcli command line tool

nmcli connection show
nmcli connection modify "connection-name" +ipv4.routes "network address/prefix gateway"
nmcli connection up "connection-name"

Example:
sudo nmcli connection modify "Bond connection 1" +ipv4.routes "172.31.0.0/16 192.168.0.1"
sudo nmcli connection reload
sudo nmcli connection up "Bond connection 1"
sudo nmcli connection show

After running the above commands, you can see the changes in the file:
sudo vim /etc/sysconfig/network-scripts/route-Bond_connection_1
It is the same as method 2, directly making changes to the file.

Method Two : Manually Create Configuration File

configuration file inside the /etc/sysconfig/network-scripts/ directory using the following format.

route-connectioname

For example, if the name of the network connection is "Bond connection 1", then The name of the configuration file should be

route-Bond_connection_1

sudo cat /etc/sysconfig/network-scripts/route-Bond_connection_1

ADDRESS0=172.31.0.0
NETMASK0=255.255.0.0
GATEWAY0=192.168.0.1

Example format:
ADDRESS0=10.0.0.0

NETMASK0=255.255.255.0

GATEWAY0=192.168.1.10

ADDRESS1=192.168.50.10

NETMASK1=255.255.255.255

GATEWAY1=192.168.1.1

Finally, you need to restart the network connection using nmcli command.

sudo nmcli connection reload

sudo nmcli connection up "Bond connection 1"


Comments

Popular posts from this blog

Make online money from the Internet