Server Administration & Management

How to add static route in linux

Static routes improves overall performance of your network (especially bandwidth saving). They are also useful in stub networks (i.e. there is only one link to the network).

Display Current Routing Table Using following command

# ip route show

Sample output: dev eth1 proto kernel  scope link  src dev eth0  proto kernel  scope link  src
default via dev eth0

You can add static route using following command:

ip route add {NETWORK} via {IP} dev {DEVICE}

For example network available via

# ip route add via dev eth0

Alternatively, you can use old good route command:

# route add -net netmask gw dev eth0

The drawback of ‘ip’ or ‘route’ command is that, when Linux reboots it will forget static routes. So store them in configuration file. Static routing describes a system that does not implement adaptive routing. In these systems routes through a data network are described by fixed paths (statically). These routes are usually entered into the router by the system administrator. You need to open /etc/sysconfig/network-scripts/route-eth0 file to define static routes for eth0 interface:

# cat /etc/sysconfig/network-scripts/route-eth0

Sample Output:

# service network restart

Verify new routing table:

# route -n

To make the routing information persistent, add the “route add” line as seen above into the /etc/rc.local file.

February 8, 2012 Posted by | Tips & Tricks, Unix/Linux | , , , | Leave a comment

Protected: SYN_Flood Attack Protection

This content is password protected. To view it please enter your password below:

February 6, 2012 Posted by | Firewall, Security, Shell Script, Tips & Tricks | , , , , , | Enter your password to view comments.