Where to add route command in files to make it stay on every bootup?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Where to add route command in files to make it stay on every bootup?
Hello,
I would like to add:
"route add 192.168.0.1 gw 30.38.72.50" to SuSE so that it's not required to be typed every time the system is rebooted.
I scavenged the net and it seems like within /ect/rc.d/boot.local I should be able to add the command and it be loaded with the OS.
Was this a correct notion or is boot.local not for commands like route?
I have seen other threads of various forums mention rc.local and I do not have this file. I attempted to do write that route command into boot.local and it didn't change anything.
It looks by the way as as if the site might be a handy one to book mark if you're doing Suse.
Section 10.4 from the above link says:
Quote:
10.4 Setting up static routing
We've discussed network configurations and what routing is used for. Now you're ready for setting up routing in SuSE Linux. YaST allows you to specify a default router in the format that you used to configure an interface. This is fine for a leaf node in a simple network. However, if the network has more than one router, or you actually want to set up a router, you'll need more than this. You need to specify a routing table. Even if YaST doesn't provide a way to set up a routing table, the SuSE Linux distribution has a fairly easy way to do this.
The file /etc/route.conf contains a routing table, which will be set up by the script /sbin/init.d/route whenever a networking runlevel (by default runlevels two and three) is reached. Following is a very simple routing table such as is found in /etc/route.conf.
#
# /etc/route.conf for hosts in 'Network A'
#
# In this file you can configure your static routing...
#
# This file is read by /sbin/init.d/route.
#
#
# Destination Dummy/Gateway Netmask Device
#
192.168.0.0 0.0.0.0 255.255.255.128 eth0
default 192.168.0.1
This routing table is typical for a simple network host. It could be any host in Network A from Figure 9-2. As you can see, comment lines start with a hash sign (#) in the first column. Comment lines and empty lines are ignored when the route script sets up the kernel routing table.
The other lines represent routing table entries. The format is very close to the output of the route command, as we demonstrate in Chapter 9.
The first column specifies a destination. This can be either a network address, a host address, or the string default for the default gateway. Whether the given address is a host or a network is determined by the netmask given in the third column. The network mask for a host is always 255.255.255.255. Everything else specifies a network route. Network route means a route to a network, whereas a host route is a route to a single host. The second column gives either the IP address of the router, which should be used to reach the destination given in the first column, or the special value 0.0.0.0, which means that all traffic headed to the destination will be given to1 the device specified in the last column. If a gateway address is given, the device specification is optional.
To clearly illustrate this, we refer back to Figure 9-2 and have a look at the entries of the routing tables of the hosts and routers in this network.
If you didn't have any statically defined routes you might not need it. You can create it from scratch. All the lines starting with "#" are comments so you can leave them out (or you can just cut and paste from the earlier post).
OK - so if you say forget the last thing you said which is to nevermind the question that means you DO want an answer to the question?
The answer is yes - you'll likely have to stop and start networking to make it take effect. However, if you've already statically set the route with "route add" at command line there's no hurry to do it. I would definitely plan to boot the box after making the change so you could verify the static route comes back in after a reboot. (e.g. Don't just wait for the next time it crashes - you might have forgotten by then and tear your hair out wondering why your networking suddenly is an issue.)
I've also been trying to use the Yast Routing GUI because it has a "expert configuration" portion where you can do the same thing.
The thing is, if I check the box to enable expert config, add my "expert" routing and then hit finish....next time I open up the routing tool the box is unchecked and my settings never go through!!!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.