Blog
The Blog

KB N°2003: ADD A STATIC ROUTE

KB Olfeo On-Premise
June 2, 2023

How to add a static route and make it persistent.

Objective

Add a static route and make it persistent.

STEPS

For example, pass through IP 192.168.1.100 to reach network 192.168.2.0/24:

route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.100

Make this route available each time the eth0 network interface is activated:

  • For Debian-like (Debian, Ubuntu...) :

    Write the following line in /etc/network/interfaces :

    up route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.1.100

  • For CentOS, RedHat... :

    echo "192.168.2.0/24 via 192.168.1.100" >> /etc/sysconfig/network-scripts/route-eth0

    For more information: www.akadia.com/services/redhat_static_routes.html.