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 Apache PHP-FPM Centos 7
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 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

Virtualbox Change Storage Size

Changing the storage size of a virtual machine in VirtualBox involves a few steps. Here’s a general guide. Backup your Virtual Machine (VM) Before...
habibzain
35 sec read

Easy Setup Logrotate Nginx Ubuntu

Log rotation is an important aspect of managing log files on a Linux system, including those generated by Nginx. Logrotate is a utility that...
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