LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-25-2008, 02:46 PM   #1
LotharIrausquin
LQ Newbie
 
Registered: Feb 2008
Posts: 16

Rep: Reputation: 0
How to add a persistent route in Debian Linux


Dear LinuxQuestions.org

We have a server that runs CensorNet which is a Proxy Server and runs on Debian Linux.

We need to add persistent static routes to it so that when the server gets rebooted , the routes stay in and do not disappear.

Every time the server reboots we have to add the routes back in manually.

e.g. "route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.0.228"

Can you help us out?


Regards,

Lothar Irausquin
e-mail: IrausquinL@arubadigital.com
 
Old 02-25-2008, 03:13 PM   #2
TigerOC
Senior Member
 
Registered: Jan 2003
Location: Devon, UK
Distribution: Debian Etc/kernel 2.6.18-4K7
Posts: 2,380

Rep: Reputation: 49
Edit your /etc/network interfaces;

auto ethX
iface ethX inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.228

Where X=card # which starts at zero.
 
Old 02-27-2008, 02:08 PM   #3
LotharIrausquin
LQ Newbie
 
Registered: Feb 2008
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TigerOC View Post
Edit your /etc/network interfaces;

auto ethX
iface ethX inet static
address 192.168.0.2
netmask 255.255.255.0
gateway 192.168.0.228

Where X=card # which starts at zero.
Do you mean
address 192.168.2.0 <----
netmask 255.255.255.0
gateway 192.168.0.228?

In CensorNet we use a bridge br0 [eth0, eth1]and we have to add a persistent route to this bridge.
 
Old 02-27-2008, 04:04 PM   #4
TigerOC
Senior Member
 
Registered: Jan 2003
Location: Devon, UK
Distribution: Debian Etc/kernel 2.6.18-4K7
Posts: 2,380

Rep: Reputation: 49
It cannot be a 0 configuration as in 192.168.2.0 as this is reserved it must be greater than zero and less than 255 i.e. between 1 and 254.

The iface above would be in the form eth0:0. Never used the bridge so you need to do some reading.
 
Old 02-28-2008, 05:56 AM   #5
LotharIrausquin
LQ Newbie
 
Registered: Feb 2008
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by TigerOC View Post
It cannot be a 0 configuration as in 192.168.2.0 as this is reserved it must be greater than zero and less than 255 i.e. between 1 and 254.

The iface above would be in the form eth0:0. Never used the bridge so you need to do some reading.
I need to add the route :
route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.0.228

NOT 192.168.0.2 netmask 255.255.255.0 gw 192.168.0.228

That's what is confusing me.
 
Old 02-28-2008, 07:53 AM   #6
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Rep: Reputation: 30
That network address 192.168.2.0 its for broadcasting the entire network, isnt it?
 
Old 02-28-2008, 08:16 AM   #7
rupertwh
Member
 
Registered: Sep 2006
Location: Munich, Germany
Distribution: Debian / Ubuntu
Posts: 297

Rep: Reputation: 49
Hi Lothar,

I'm not aware of any config file that would make the system add the route, so I'd just add the route command to a script in /etc/network/if-up.d.
In that script, check for $IFACE, so your route isn't added whenever just any interface comes up.
 
Old 02-28-2008, 10:15 AM   #8
LotharIrausquin
LQ Newbie
 
Registered: Feb 2008
Posts: 16

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Ricio View Post
That network address 192.168.2.0 its for broadcasting the entire network, isnt it?
Yes, the customers network is on a LAN with Network ID 192.168.0.0 Mask
255.255.255.0. The CensorNet Server on this LAN run Debian Linux and this server needs to be configured for routing:

One route is to the Network ID 192.168.2.0 Mask 255.255.255.0 over gateway 192.168.0.228 and the other route is to the Network ID 192.168.4.0 Mask 255.255.255.0 over gateway 192.168.0.229.

I have to add these routes manually every time the server restarts and I want the routes to stay in when the server restarts.
 
Old 02-28-2008, 03:49 PM   #9
Ricio
Member
 
Registered: Sep 2003
Location: Colombia
Distribution: Debian
Posts: 220

Rep: Reputation: 30
Why dont you try bash scripting and run it at boot... I actually dont know how to start scripts at boot!

Or just add the same line you do at boot at etc/network/interfaces try and see what happens...
 
Old 02-29-2008, 02:04 AM   #10
TigerOC
Senior Member
 
Registered: Jan 2003
Location: Devon, UK
Distribution: Debian Etc/kernel 2.6.18-4K7
Posts: 2,380

Rep: Reputation: 49
Edit /etc/network/interface to

auto eth0:0
iface eth0:0 inet static
address 192.168.2.1
netmask 255.255.255.0
gateway 192.168.0.228

Rem (#) anything else relating to ethX as there maybe a line relating to dhcp.

In a root consol do;

/etc/init.d/networking restart

Check for any errors. Unlike some other operating systems that shall remain nameless Linux systems do not have to be rebooted to restart services as they are running daemons and can be started, stopped and restarted at any time via this route. Most servers are never rebooted accept to do kernel updates or physical work. My server was last rebooted 3 months ago after a kernel upgrade.
 
Old 02-29-2008, 02:28 AM   #11
yongitz
Member
 
Registered: Nov 2005
Location: Davao City, Philippines
Distribution: RHEL, CentOS, Ubuntu, Mint
Posts: 139

Rep: Reputation: 20
Quote:
Originally Posted by LotharIrausquin View Post
Dear LinuxQuestions.org

We have a server that runs CensorNet which is a Proxy Server and runs on Debian Linux.

We need to add persistent static routes to it so that when the server gets rebooted , the routes stay in and do not disappear.

Every time the server reboots we have to add the routes back in manually.

e.g. "route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.0.228"

Can you help us out?


Regards,

Lothar Irausquin
e-mail: IrausquinL@arubadigital.com
For this, I'd try the /etc/rc.d/rc.local equivalent. I'd do the following:

1. Create a file named local in /etc/init.d/, for example:
#!/bin/bash

# your route command here
/sbin/route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.0.228

2. run "update-rc.d local defaults"

That should do it. Hope this helps.
 
Old 03-11-2008, 09:18 AM   #12
LotharIrausquin
LQ Newbie
 
Registered: Feb 2008
Posts: 16

Original Poster
Rep: Reputation: 0
It Worked!

Quote:
Originally Posted by yongitz View Post
For this, I'd try the /etc/rc.d/rc.local equivalent. I'd do the following:

1. Create a file named local in /etc/init.d/, for example:
#!/bin/bash

# your route command here
/sbin/route add -net 192.168.2.0 netmask 255.255.255.0 gw 192.168.0.228

2. run "update-rc.d local defaults"

That should do it. Hope this helps.

Hi Yongitz!

Yes it worked!

Thanks a million!

You have a Very Nice Day!


Regards,

Lothar Irausquin
 
  


Reply

Tags
networking, routing


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
persistent static route ANU Linux - Networking 5 04-01-2012 07:23 PM
How does one make a static route persistent in AIX? artasse AIX 2 11-22-2006 02:51 PM
I am not able to add a new route to my route table using route command prashanth s j Linux - Networking 2 09-03-2005 04:34 AM
Make a ROUTE persistent accross boots of the system thecrab Linux - Networking 2 05-30-2002 02:51 PM
Adding persistent(permanent) route entries on Red hat Linux 7.1 sram Linux - Networking 1 02-08-2002 10:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration