Add, view, edit and configure route and static route on Linux Fedora Core - Linux Server Configuration.

 

Step by step guide on add, view, edit and configure static route on Linux Fedora Core.

 

The article below show the step by step to display route, configure route, adding and edit route and static route on Linux Fedora Core using Linux netstat command and route command.

 

1. Display or view routing table.

2. Add or change default route.

3. Add static route.

4. Add permanent (persistent) static routing.

 

Step-by-step how to display or view routing table on Linux Fedora Core machine.

 

Using Linux 'netstat' command to display or view kernel IP routing table.

 

[root@linux hack]# netstat -r

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface

203.106.93.64 * 255.255.255.224 U 0 0 0 eth0

10.2.0.0 * 255.255.0.0 U 0 0 0 eth1

10.3.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.6.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.7.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.4.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.5.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.10.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.8.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

169.254.0.0 * 255.255.0.0 U 0 0 0 eth1

10.9.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

default 203.106.93.93 0.0.0.0 UG 0 0 0 eth0

 

[root@linux hack]# netstat -nr

Kernel IP routing table

Destination Gateway Genmask Flags MSS Window irtt Iface

203.106.93.64 0.0.0.0 255.255.255.224 U 0 0 0 eth0

10.2.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1

10.3.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.6.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.7.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.4.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.5.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.10.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.8.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth1

10.9.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

0.0.0.0 203.106.93.93 0.0.0.0 UG 0 0 0 eth0

 

Using Linux 'route' command to display kernel IP routing table.

 

[root@linux hack]# /sbin/route

Kernel IP routing table

Destination Gateway Genmask Flags Metric Ref Use Iface

203.106.93.64 * 255.255.255.224 U 0 0 0 eth0

10.2.0.0 * 255.255.0.0 U 0 0 0 eth1

10.3.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.6.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.7.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.4.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.5.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.10.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

10.8.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

169.254.0.0 * 255.255.0.0 U 0 0 0 eth1

10.9.0.0 10.2.0.2 255.255.0.0 UG 0 0 0 eth1

default 203.106.93.93 0.0.0.0 UG 0 0 0 eth0

 

Step-by-step how to add/change default route on Linux Fedora Core machine.

 

You can add default route on your Linux machine by using route command.

 

[root@linux hack]# route add default gw 10.10.0.1 eth0

 

Add or edit the default gateway on /etc/sysconfig/network file, to make sure your default is preserve after your system boot.

 

Configuration example on network file:

 

NETWORKING=yes

HOSTNAME=fedora.hacking.com

GATEWAY=203.106.93.93

 

Or you can place the (# route add default gw 10.10.0.1 eth0) command to the rc.local script file. This rc.local script file is located under /etc/rc.d/rc.local. This rc.local script file are design to run at the end of each boot time.

 

Step-by-step how to add static route on Linux Fedora Core machine.

 

The route add command below show the example to add network and host to the routing table.

 

[root@linux hack]# route add -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 eth0

 

[root@linux hack]# route add -host 10.10.0.5 netmask 255.255.0.0 gw 10.2.0.1 eth0

 

To verify the current change to the routing table, execute the route command without any option.

 

The example below show the command to remove or delete routing form routing table.

 

[root@linux hack]# route del -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 eth0

 

[root@linux hack]# route del -host 10.10.0.5 netmask 255.255.0.0 gw 10.2.0.1 eth0

 

4. Step-by-step how to add route permanent ( persistent ) on Linux Fedora Core machine.

 

To make route permanent (persistent as on Windows machine) on Linux Fedora Core machine, place the route add command to the rc.local script file. This rc.local script file is located under /etc/rc.d/rc.local. The rc.local script file are design to run at the end of each boot time.

 

Configuration example on rc.local script file:

 

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

 

touch /var/lock/subsys/local

route add default gw 10.10.0.1 eth0

route add -net 10.1.0.0 netmask 255.255.0.0 gw 10.2.0.1 eth0

 

or

Using the Network Graphical User Interface to adding permanents / persistent route to Linux fedora Core machine.

 

1. Open Network GUI interface:

 

[root@linux hack]# /usr/bin/system-config-network-gui &

 

2. Select and highlight the network interface card on the Devices tab, in this example eth0

3. On the Network Configuration menu, click the Fedora Core utils: Network Configuration EDIT button button to edit the properties for Ethernet Device.

 

Fedora Core, Network Configuration GUI

 

4. On the Ethernet Device screen, click on the Route tab.

 

5. Click [ Add ] button to add static network routes to your Linux Fedora Core machine.

 

Fedora Core Ethernet Device, add/edit route IP address

 

Note: Example above show route network address is 10.10.0.0, the subnet mask is 255.255.0.0 and the gateway is 10.2.0.2

 

Step-by-step how to procedure above tested on:

Operating System: GNU/Linux Fedora Core 4

Kernel Name: Linux

Kernel Release: 2.6.11-1.1369_FC4

Kernel Version: #1 Thu Jun 2 22:55:56 EDT 2005

Machine Hardware: i686

Machine Processor: i686

Hardware Platform: i386

Shell: GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu)

Installation Type: Full Installation (Custom)

SELinux: Disable

 

Keywords: display routing table, configure static route, add persistent route, add route, add static network routes, edit routing table, route, static route, configure route Linux, netstat command, route command, configure network route, Fedora Core route, network configuration.

 

1 comment

27
Nov

Very good tutorial

helped me a lot

aaaaaaaaaaa