Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linux ROUTE ADD commands

0 views
Skip to first unread message

John Gill

unread,
Jul 1, 1998, 3:00:00 AM7/1/98
to

Hi all.

I am setting up a lynux box as a tcp.ip router, and am having trouble
with route add commands. I am new to Linux, but not to tcp.ip routing.
I am looking for a good source of route add command syntax.

My particular problem is as follows:

Local LAN eth1 192.168.0.0 255.255.255.0
Internet eth0 0.0.0.0

I have given the following commands:

route add default gw 25.2.2.1 eth0
route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.126 eth1

and the last command I cannot add.

Thanks in advance for a solution source.

John
ps -- please do not hit reply button. Reply to newsgroup or to
jg...@taxlaws.com

http://www.taxlaws.com jg...@taxlaws.com

Barry Margolin

unread,
Jul 1, 1998, 3:00:00 AM7/1/98
to

In article <359A6EAC...@visi.net>, John Gill <in...@taxlaws.com> wrote:
>Hi all.
>
>I am setting up a lynux box as a tcp.ip router, and am having trouble
>with route add commands. I am new to Linux, but not to tcp.ip routing.
>I am looking for a good source of route add command syntax.
>
>My particular problem is as follows:
>
> Local LAN eth1 192.168.0.0 255.255.255.0
> Internet eth0 0.0.0.0
>
>I have given the following commands:
>
> route add default gw 25.2.2.1 eth0
> route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.126 eth1
>
>and the last command I cannot add.

What is the last command supposed to do? Why are you trying to intall a
route for 192.168.0.0/24 when that's the network assigned to the
directly-connected ethernet? Routes for directly-connected networks don't
need to be installed manually -- configuring the interface causes them to
be installed automatically.

--
Barry Margolin, bar...@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.

Brian McCauley

unread,
Jul 1, 1998, 3:00:00 AM7/1/98
to

John Gill <gillco...@visi.net> writes:


> My particular problem is as follows:
>
> Local LAN eth1 192.168.0.0 255.255.255.0
> Internet eth0 0.0.0.0

What do you mean by this? Nither of these are good ifconfig settings.

The only way eth0 can have an address of 0.0.0.0 is if you are pending
a DHCP. If this is the case the DHCP client s/w should be setting
your default route - you should not be doing it by hand.

> I am setting up a lynux box as a tcp.ip router, and am having trouble
> with route add commands. I am new to Linux, but not to tcp.ip routing.
> I am looking for a good source of route add command syntax.

The man page?

The thing to remember is that with Linux you should use the "gw"
option to specify gateways. Do not use it to specify interfaces. The
ability to use the "gw" option to specify interfaces is supported for
compatablity with other OS but it's use can lead to confusion.

If you actually _need_ to specify interfaces do it explicit (using the
"dev" option). You almost never need to do so. No make things more
confusing still the word "dev" can be implied by context.

> I have given the following commands:
>
> route add default gw 25.2.2.1 eth0

My advice is don't explicitly specify the interface. If the kernel
would not be able to derive the correct interface then you've already
done something wrong.

route add default gw 25.2.2.1

> route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.126 eth1


>
> and the last command I cannot add.

Try

route add -net 192.168.0.0


--
\\ ( ) No Bullshit! | Email: B.A.Mc...@bham.ac.uk
. _\\__[oo from | Phones: +44 121 471 3789 (home)
.__/ \\ /\@ /~) /~[ /\/[ | +44 121 627 2173 (voice) 2175 (fax)
. l___\\ /~~) /~~[ / [ | PGP-fp: D7 03 2A 4B D8 3A 05 37...
# ll l\\ ~~~~ ~ ~ ~ ~ | http://wcl-l.bham.ac.uk/~bam/
###LL LL\\ (Brian McCauley) | Finger: b...@wcl-rs.bham.ac.uk

Brian McCauley

unread,
Jul 2, 1998, 3:00:00 AM7/2/98
to

Barry Margolin <bar...@bbnplanet.com> writes:

> What is the last command supposed to do? Why are you trying to intall a
> route for 192.168.0.0/24 when that's the network assigned to the
> directly-connected ethernet? Routes for directly-connected networks don't
> need to be installed manually -- configuring the interface causes them to
> be installed automatically.

Provided you are running a routing deamon, using a 2.1 series kernel
or using some sort of config tool that automatically adds the "route
add" commands.

Barry Margolin

unread,
Jul 2, 1998, 3:00:00 AM7/2/98
to

In article <td8bot...@wcl-l.bham.ac.uk>,

Brian McCauley <B.A.Mc...@bham.ac.uk> wrote:
>Barry Margolin <bar...@bbnplanet.com> writes:
>
>> What is the last command supposed to do? Why are you trying to intall a
>> route for 192.168.0.0/24 when that's the network assigned to the
>> directly-connected ethernet? Routes for directly-connected networks don't
>> need to be installed manually -- configuring the interface causes them to
>> be installed automatically.
>
>Provided you are running a routing deamon, using a 2.1 series kernel
>or using some sort of config tool that automatically adds the "route
>add" commands.

Well, I'm not familiar with Linux-specific configuration, but I would be
very surprised if it requires any of those things to add a route for the
directly connected subnet. Most flavors of Unix do it automatically when
you ifconfig the interface.

chasm...@my-dejanews.com

unread,
Jul 3, 1998, 3:00:00 AM7/3/98
to

In article <td8bot...@wcl-l.bham.ac.uk>,
Brian McCauley <B.A.Mc...@bham.ac.uk> wrote:
>
> Barry Margolin <bar...@bbnplanet.com> writes:
>
> > What is the last command supposed to do? Why are you trying to intall a
> > route for 192.168.0.0/24 when that's the network assigned to the
> > directly-connected ethernet? Routes for directly-connected networks don't
> > need to be installed manually -- configuring the interface causes them to
> > be installed automatically.
>
> Provided you are running a routing deamon, using a 2.1 series kernel
> or using some sort of config tool that automatically adds the "route
> add" commands.
>

You don't need a routing deamon to configure the interface and the gateway you
use as a default. You may though require a deamon such as gated to run OSPF or
RIP-2 ... if you don't want to mess around when you configure static tables.

Run netconfig to configure your interfaces and provide them with basical net
data like IP and mask and so on.
After this , look in /etc/sysconfig/ et add your gateway IP address in a file
called network after the GATEWAY= statement. This is for RH 5.x . It might be
slightly different for other systems.
You cannot add a default route if the gateway is not added ! it will say sth
like:Network unreachable.
After this, shutdown your sys and reboot. Type netstat -rn to see if your net
configuration is what you want it to be. Do not forget to put any static route
you added by hand to a startup file like rc.local ..etc....


hope this will help.

Greetings.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum

Vincent Zweije

unread,
Jul 3, 1998, 3:00:00 AM7/3/98
to

In article <359A6EAC...@visi.net>, John Gill <in...@taxlaws.com>
wrote:

|| I am setting up a lynux box as a tcp.ip router, and am having trouble


|| with route add commands. I am new to Linux, but not to tcp.ip routing.
|| I am looking for a good source of route add command syntax.
||

|| My particular problem is as follows:
||
|| Local LAN eth1 192.168.0.0 255.255.255.0
|| Internet eth0 0.0.0.0
||

|| I have given the following commands:
||
|| route add default gw 25.2.2.1 eth0

|| route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.126 eth1
||
|| and the last command I cannot add.

Please consult the NET-3 HOWTO, section 5.7: "Routing". (sigh)

The gateway on 192.168.0.0/24 does not make sense. For which addresses
can it forward packets? If you're the gateway yourself, don't put it in
the routing table.

I suspect you need something like:

ifconfig eth0 25.2.2.A netmask 255.255.255.0
ifconfig eth1 192.168.0.B
route add -net 192.168.0.0
route add -net 25.2.2.0


route add default gw 25.2.2.1

or, written out in full:

ifconfig eth0 25.2.2.A netmask 255.255.255.0 broadcast 25.2.2.255
ifconfig eth1 192.168.0.B netmask 255.255.255.0 broadcast 192.168.0.255
route add -net 25.2.2.0 netmask 255.255.255.0 dev eth0
route add -net 192.168.0.0 netmask 255.255.255.0 dev eth1
route add -net 0.0.0.0 netmask 0.0.0.0 gw 25.2.2.1

Substitute A and B with numbers appropriate for your own interfaces.

Bye. Vincent.
--
* <mailto:zwe...@xs4all.nl> * <http://www.xs4all.nl/~zweije/> *
"Xhost should be taken out and shot." Vincent Zweije

Gert Doering

unread,
Jul 5, 1998, 3:00:00 AM7/5/98
to

Barry Margolin <bar...@bbnplanet.com> writes:

>>I have given the following commands:
>>
>> route add default gw 25.2.2.1 eth0
>> route add -net 192.168.0.0 netmask 255.255.255.0 gw 192.168.0.126 eth1
>>
>>and the last command I cannot add.

>What is the last command supposed to do? Why are you trying to intall a


>route for 192.168.0.0/24 when that's the network assigned to the
>directly-connected ethernet? Routes for directly-connected networks don't
>need to be installed manually -- configuring the interface causes them to
>be installed automatically.

Uh, I have to disagree. On Linux 2.0.x (and earlier), you explicitely
have to add the directly connected route with "route add ... dev eth0". I
don't know why this was done in the past, and never understood it. Linux
2.1 changes this behaviour to what you would expect :-)

The problem with the command above is that the syntax is wrong. The
correct form is:

ifconfig eth1 192.168.0.x netmask 255.255.255.0


route add -net 192.168.0.0 netmask 255.255.255.0 dev eth1

route add default gw 192.168.0.126

gert
--
Yield to temptation ... it may not pass your way again! -- Lazarus Long
//www.muc.de/~gert
Gert Doering - Munich, Germany ge...@greenie.muc.de
fax: +49-89-3243328 gert.d...@physik.tu-muenchen.de

0 new messages