How to add and delete temporary or persistent static route in CentOS 7 - Linux Dukes - Secret Revealed of Offshore Hosting Company | Bulletproof Hosting Directory 2022

How to add and delete temporary or persistent static route in CentOS 7 – Linux Dukes

Static Routes

Static routes are configured on linux servers when the enterprise has received a couple of routers, the place one router acts as a default gateway that join with the remainder of the world and inside routers join completely different branches and sections of the workplace. For a system administrator it is extremely essential to have the ability to perceive and carry out static route configurations on a linux server.

This text illustrates other ways of including and deleting static routes specifically on CentOS 7 linux system.

Verify Current Routes

Earlier than begin including or deleting static routes, it’s essential to confirm the present routes accessible, in order that any incorrect or lacking route will be rectified, added or eliminated. To take action, merely launch your terminal and situation the command beneath.

ip route present

Following command may even return comparable outcomes.

ip route checklist

Identical info may also be obtained utilizing route and netstat instructions as proven beneath

route -n
netstat   -nr

View Available Routes
View Out there Routes

Contemplate following topology, lets assume you may have a department workplace the place few shoppers want entry to the system, and the department workplace community is And the default route for Server0 is about to web router IP (ie Right here Its inconceivable to achieve department workplace by way of web router.

You’ll create a static route on the server which can let the server know, that for reaching subnet it should handover the visitors to This will probably be achieved by configuring a static route.

Static Route Topology
Topology Beneath Consideration

First verify interface ID or quantity on which two routers are accessible, by issuing ifconfig command. It’s enp0s3 in my case.

Interface To be configured
Work out the Interface to be configured

Add a Non permanent Static Route

ip  route  add   through   dev   enp0s3

Temporary Static Route
Non permanent Static Route is added

Delete a Non permanent Static Route

The static route added utilizing above technique stays configured until the system is working, it is going to be eliminated if the system is rebooted due to this fact it’s known as non permanent static route.

Now, if the the static route isn’t any extra wanted or the non permanent static was beforehand misconfigured and must be eliminated, then you’ll have to delete the route utilizing following command:

ip route delete through dev enp0s3

Temporary Static Route Removed
Non permanent Static Route Eliminated

Add a Everlasting or Persistent Static Route

It may be skilled that non permanent static routes aren’t persistent; these routes are deleted upon subsequent reboot, now we’ll see find out how to make them everlasting or persistent.

We must create a file the place interface configuration recordsdata reside (ie /and so on/sysconfig/network-scripts)

Problem following command to create a brand new file named route-enp0s3 and kind the community and the gateway IP from which visitors must be handed adopted by interface ID or title as proven beneath.

vi  /and so on/sysconfig/network-scripts/route-enp0s3

Sort the static route as per following sample. through dev enp0s3
  1. Save the file
  2. Restart community service
  3. View routing desk

Route is added permanently
Everlasting Route is added

Delete a Everlasting or Persistent Static Route

  1. Take away the file named route-enp0s3
  2. Restart community service
  3. View routing desk
rm  -rf  /and so on/sysconfig/network-scripts/route-enp0s3
systemctl restart community
ip route present

Permanent route is removed
Everlasting route is eliminated

Loved the content material! Please discover extra.

offshore vps
Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker. We use only Banner Ads (No Pop Ads)

Powered By
Best Wordpress Adblock Detecting Plugin | CHP Adblock