LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 10-29-2015, 05:53 PM   #1
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Rep: Reputation: Disabled
Setting static route debian


Hello

I have Debian 8 and i want to set static route for two interfaces.
So i add route line to /etc/network/interfaces:
Code:
auto eth0
iface eth0 inet static
address 172.168.2.1
netmask 255.255.255.0
gateway 172.168.2.2
up route add -net 172.168.3.0 netmask 255.255.255.0 gw 172.168.1.3
But after restart networking
the route doesn't display in route command.

I tried few combinations:
with post-up
without up (only route)
up /sbin/ip r add 172.168.3.0/24 via 172.168.1.3

but nothing works

when i type in command line
route add -net 172.168.3.0 netmask 255.255.255.0 gw 172.168.1.3
it works, but i need permanent solution

Please help me
 
Old 10-29-2015, 06:16 PM   #2
hortageno
Member
 
Registered: Aug 2015
Distribution: Ubuntu 22.04 LTS
Posts: 240

Rep: Reputation: 67
Try

Code:
postup route add -net 172.168.3.0/24 gw 172.168.1.3
 
Old 10-30-2015, 07:13 AM   #3
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Original Poster
Rep: Reputation: Disabled
After reboot route shows:
Quote:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 172.168.2.2 0.0.0.0 UG 0 0 0 eth0
link-local * 255.255.0.0 U 1000 0 0 eth0
172.168.1.0 * 255.255.255.0 U 0 0 0 eth1
172.168.2.0 * 255.255.255.0 U 0 0 0 eth0
bolded line is new.

And here is my /etc/network/interfaces file:
Quote:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 172.168.2.1
netmask 255.255.255.0
gateway 172.168.2.2
#static route
postup route add -net 172.168.3.0/24 gw 172.168.1.3


auto eth1
allow-hotplug eth1
iface eth1 inet static
address 172.168.1.1
netmask 255.255.255.0
gateway 172.168.1.3
 
Old 10-30-2015, 08:16 AM   #4
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
May I ask why you are using public addresses for private networking? It is a violation, unless you have permission from AOL who owns these addresses.
 
Old 10-30-2015, 07:47 PM   #5
blackRonin
Member
 
Registered: Jun 2014
Distribution: Debian 9.6
Posts: 68

Original Poster
Rep: Reputation: Disabled
It's just school project, and whose ip addresses where in excersise.

Can you help me ?
 
Old 10-30-2015, 11:56 PM   #6
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
You could try the following:
Code:
ifdown -v eth0; ifup -v eth0
to get some information as to what's happening behind the scenes.

A few additional thoughts:
According to my manpage, it should be post-up with a dash in the middle, not postup.
I also wonder what's the sequence of events here - if eth1 is not up at the time the route command is executed, wouldn't route fail?
Finally, in this day and age you should use the iproute2 commands (ip route ....) instead of the old ones (ifconfig, route and company).

Last edited by berndbausch; 10-31-2015 at 12:02 AM.
 
  


Reply


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
route-eth - Adding a static route gbwien Linux - Networking 5 02-24-2012 05:15 AM
setting static IP on linux PCs with no static IP address from internet provider? solvetek Linux - Networking 1 10-22-2011 08:04 AM
Setting Static ip in debian version 4.0 (codename etch) problem neilcpp Debian 4 09-16-2008 02:17 PM
need help setting up static route with iptables2 hedpe Linux - Networking 1 03-22-2006 08:26 PM
Setting up Static Route for two Networks ctrylace Linux - Networking 2 07-23-2004 03:18 AM

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

All times are GMT -5. The time now is 06:34 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