- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- redhat linux - static route
Operating System - Linux
1819926
Members
3219
Online
109607
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2004 03:29 PM
тАО11-22-2004 03:29 PM
redhat linux - static route
Hi ,
I need to put a static route.I have edited the file /etc/sysconfig/static-route with below line :
eth0 net 224.0.0.0 subnet 255.0.0.0
but no avail.The netstat -rn entry missing everything it's reboot.
Linux Version = redhat
Any hint.
regard
mB
I need to put a static route.I have edited the file /etc/sysconfig/static-route with below line :
eth0 net 224.0.0.0 subnet 255.0.0.0
but no avail.The netstat -rn entry missing everything it's reboot.
Linux Version = redhat
Any hint.
regard
mB
There are three person in my team-Me ,myself and I.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2004 04:14 PM
тАО11-22-2004 04:14 PM
Re: redhat linux - static route
sorry.This is the entry in the /etc/sysconfig/static-route file.
eth0 net 224.0.0.0 netmask 255.0.0.0
regards
mB
eth0 net 224.0.0.0 netmask 255.0.0.0
regards
mB
There are three person in my team-Me ,myself and I.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2004 04:28 PM
тАО11-22-2004 04:28 PM
Re: redhat linux - static route
Depending on your RH version file name should be either
/etc/sysconfig/static-routes
or
/etc/sysconfig/network-scripts/route-
Read /usr/share/doc/initscript*/sysconfig.txt to see which one to use.
/etc/sysconfig/static-routes
or
/etc/sysconfig/network-scripts/route-
Read /usr/share/doc/initscript*/sysconfig.txt to see which one to use.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-22-2004 04:54 PM
тАО11-22-2004 04:54 PM
Re: redhat linux - static route
Dear mB,
With the introduction of Redhat version 8 and continued into version 9, the /etc/sysconfig/static-routes file no longer seems to function correctly.
Linux static routes changed in 8.0 to a new format. Now you are to create a file in /etc/sysconfig/network-scripts for each Ethernet interface you wish to create static routes on.
Example:
touch /etc/sysconfig/network-scripts/route-eth0
The syntax for this file is different from the traditional route format used in /etc/sysconfig/static-routes . Redhat has yet to document the change on their web site as of June 2003.
Syntax based on a usenet post go to /etc/sysconfig/network-scripts, make a file called route-devicename (ex: route-eth0) and populate it with your static routes for that device so if you wanted to make a static route to the 192.168.0.0/24 network through 152.3.182.5 type:
192.168.0.0/24 via 152.3.182.5
Persistent static routes for ANY linux distribution
You may use this method to add static routes and it will work under any Linux distribution. However, it is considered by some a 'hack' or the 'ugly way'.
Edit your /etc/rc.local file and add your static routes using the route statement.
Example:
route add -net 10.10.98.0 netmask 255.255.255.0 gw 10.164.234.132 dev eth1
route add -net 10.164.234.96 netmask 255.255.255.252 gw 10.164.234.132 dev eth1
route add -net 10.164.234.112 netmask 255.255.255.240 gw 10.164.234.132 dev eth1
Force the old static-routes file to work under Redhat 9
Clear out the new /etc/sysconfig/network-scripts/ifup-routes script so that you can populate it with the original shell script from Redhat 7.x.
cat /dev/null > /etc/sysconfig/network-scripts/ifup-routes
vi /etc/sysconfig/network-scripts/ifup-routes
type in the following (or copy and paste) not including the tilde lines:
#!/bin/sh
# adds static routes which go through device $1
if [ "$1" = "" ]; then
echo "usage: $0"
exit 1
fi
if [ ! -f /etc/sysconfig/static-routes ]; then
exit 0
fi
# note the trailing space in the grep gets rid of aliases
grep "^$1 " /etc/sysconfig/static-routes | while read device args; do
/sbin/route add -$args $device
done
grep "^any " /etc/sysconfig/static-routes | while read ignore type net netmask mask bogus dev ; do
if [ "$dev" = "$1" ]; then
/sbin/route add -$type $net $netmask $mask $dev
fi
done
Remember to use /etc/sysconfig/network for your default gateway
If you only intend to add one route, your default gateway, then you need not worry about the static routes file or using the route command. Simply add your default gateway in /etc/sysconfig/network.
Example
NETWORKING=yes
HOSTNAME="hostname.linux.org"
GATEWAY="10.164.234.1"
GATEWAYDEV="eth0"
FORWARD_IPV4="yes"
Regards,
Syam
With the introduction of Redhat version 8 and continued into version 9, the /etc/sysconfig/static-routes file no longer seems to function correctly.
Linux static routes changed in 8.0 to a new format. Now you are to create a file in /etc/sysconfig/network-scripts for each Ethernet interface you wish to create static routes on.
Example:
touch /etc/sysconfig/network-scripts/route-eth0
The syntax for this file is different from the traditional route format used in /etc/sysconfig/static-routes . Redhat has yet to document the change on their web site as of June 2003.
Syntax based on a usenet post go to /etc/sysconfig/network-scripts, make a file called route-devicename (ex: route-eth0) and populate it with your static routes for that device so if you wanted to make a static route to the 192.168.0.0/24 network through 152.3.182.5 type:
192.168.0.0/24 via 152.3.182.5
Persistent static routes for ANY linux distribution
You may use this method to add static routes and it will work under any Linux distribution. However, it is considered by some a 'hack' or the 'ugly way'.
Edit your /etc/rc.local file and add your static routes using the route statement.
Example:
route add -net 10.10.98.0 netmask 255.255.255.0 gw 10.164.234.132 dev eth1
route add -net 10.164.234.96 netmask 255.255.255.252 gw 10.164.234.132 dev eth1
route add -net 10.164.234.112 netmask 255.255.255.240 gw 10.164.234.132 dev eth1
Force the old static-routes file to work under Redhat 9
Clear out the new /etc/sysconfig/network-scripts/ifup-routes script so that you can populate it with the original shell script from Redhat 7.x.
cat /dev/null > /etc/sysconfig/network-scripts/ifup-routes
vi /etc/sysconfig/network-scripts/ifup-routes
type in the following (or copy and paste) not including the tilde lines:
#!/bin/sh
# adds static routes which go through device $1
if [ "$1" = "" ]; then
echo "usage: $0
exit 1
fi
if [ ! -f /etc/sysconfig/static-routes ]; then
exit 0
fi
# note the trailing space in the grep gets rid of aliases
grep "^$1 " /etc/sysconfig/static-routes | while read device args; do
/sbin/route add -$args $device
done
grep "^any " /etc/sysconfig/static-routes | while read ignore type net netmask mask bogus dev ; do
if [ "$dev" = "$1" ]; then
/sbin/route add -$type $net $netmask $mask $dev
fi
done
Remember to use /etc/sysconfig/network for your default gateway
If you only intend to add one route, your default gateway, then you need not worry about the static routes file or using the route command. Simply add your default gateway in /etc/sysconfig/network.
Example
NETWORKING=yes
HOSTNAME="hostname.linux.org"
GATEWAY="10.164.234.1"
GATEWAYDEV="eth0"
FORWARD_IPV4="yes"
Regards,
Syam
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP