habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Easy Add Static Route on CentOS

43 sec read

Add Static Route on CentOS

When we face the situation where different subnet cannot be accessed through your default gateway. So, we have to add static route to help traffic get route in centos.

For temporary route, can use this command:

user@server:~# ip route add 172.16.15.0/24 via 10.0.0.101 dev ens192
  • ip route add = Command to add new static routing.
  • 172.16.15.0 = Subnet interface destination
  • /20 = Subnet Mask
  • 10.0.0.101 = Gateway interface that want to route.
  • dev eth1 = Network Interface ens192

To make it permanent system or network settings restart not lost config, create a route-ifname file for an interface through which the subnet is accessed. In my case, our server use ens192.

user@server:~# vim /etc/sysconfig/network-scripts/route-ens192

Add the line with the network settings for the other subnet:

172.16.15.0/24 via 10.0.0.101 dev ens192

Save the file and restart network service. Or you can reboot for refresh.

And then, how to remove static route. Just type this command below.

user@server:~# ip route del 172.16.15.0/24

So simple right? add static route in centos. What if static route in windows? Here is article How to Add Static IP Route on Windows.

May be it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it.


See also  Install ISPConfig Centos7
habibzain Just husband, father and enthusiastic men about System Administration. Love to write short article about it. Perhaps can help and be useful for others.

Centos Failed Update Kernel

Today I did a kernel update on my server with Centos 7 OS. At the end of the update process, I found a kernel...
habibzain
1 min read

Easy Fix Missing mirrorlist http://mirrorlist.centos.org on CentOS 7

When running yum update or command that utilize the yum system, errors similar to the following are produced: If you’re encountering issues with the...
habibzain
1 min read

Easy Create Laravel Project with Composer

Requirement Laravel, a popular PHP framework, is renowned for its elegant syntax and robust features, making it a top choice for web developers. One...
habibzain
1 min read

Leave a Reply

Your email address will not be published. Required fields are marked *

Never miss good article from us, get weekly updates in your inbox