Re: Linux Routing Woes
From: Floyd L. Davidson (floyd_at_barrow.com)
Date: 03/07/05
- Next message: Floyd L. Davidson: "Re: Linux Routing Woes"
- Previous message: Floyd L. Davidson: "Re: WRT54GS and port forwarding ssh"
- In reply to: Jeff: "Linux Routing Woes"
- Next in thread: Sir Jackery: "Re: Linux Routing Woes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 06 Mar 2005 17:18:56 -0900
"Jeff" <jeff@bruce.com> wrote:
>The following routing table is from my Solaris box (172.16.24.89):
>
>Routing Table: IPv4
> Destination Gateway Flags Ref Use Interface
>-------------------- -------------------- ----- ----- ------ ---------
>172.16.24.0 172.16.24.89 U 1 70 hme0
>224.0.0.0 172.16.24.89 U 1 0 hme0
>default 172.16.24.100 UG 1 494
>127.0.0.1 127.0.0.1 UH 6 129 lo0
>
>I want to dublicate that configuration on my Linux box (SuSE) but I've
>encountered a proble. It keeps placing 0.0.0.0 for the host route:
The 0.0.0.0 under the "Destination" heading is exactly the same
as "default". Under the "Gateway" heading it means no gateway
(With no gateway, the host with the addressed IP address must be
physically on the ethernet segment connected to the interface
the packets are routed to.)
The above routing table sends *all* traffic to one of two hosts
on your LAN (via interface hme0). Addresses in the 172.16.24.0
subnet and the 224.0.0.0 subnet are addressed to 172.16.24.89,
which *must* be a host physically on your ethernet. All other
traffic is addressed to 172.16.24.100, which also must be a
host physically on your ethernet.
>Destination Gateway Genmask Flags Mss Window Iface
>172.16.24.0 0.0.0.0 255.255.255.0 U 40 0 eth0
>224.0.0.0 0.0.0.0 240.0.0.0 U 40 0 eth0
>0.0.0.0 172.16.24.100 0.0.0.0 UG 40 0 eth0
The difference is that the Linux box is not routing to the
specific gateway, 172.16.24.89, that the Solaris box is.
With this route table the Linux box will route all 172.16.24.0
network and 224.0.0.0 network traffic to the addressed hosts on
the physical ethernet. It will fail if there is such host with
that IP address. Other than those two networks, all traffic
will be routed to eth0 addressed to 172.16.24.100, which must be
a host on your ethernet.
>I'm at wit's end. My route.conf on Linux has this entry:
>default 172.16.24.100
That's the only part that seems to be right!
>I've tried adding the address and routes manually with ifconfig and
>route and I've tried to add them with SuSE's init.d scripts. No matter
>what, I'm left with that routing table. Any thoughts?
I don't know SuSE, so I can't tell you how to configure it. But
the route commands themselves are fairly easy.
First, there must be a route to the gateway. Due to the way routes
are used that can either be a "host" route or a "network" route.
Any of one these commands will do it:
/sbin/route add -host 172.16.24.89 eth0
/sbin/route add -net 172.16.24.89 netmask 255.255.255.255 eth0
/sbin/route add -net 172.16.24.0 netmask 255.255.255.0 eth0
Note that the first two are actually exactly the same thing,
just expressed different ways. A network route with a mask
allowing only one host, is a host route! The third command
covers the entire subnet, but since the next thing you'll do is
send the entire subnet to a gateway, it is not a problem if the
routing entry is overly broad.
These two commands will then gateway the specific subnets to
that particular host.
route add -net 172.16.24.0 gw 172.16.24.89 netmask 255.255.255.0 eth0
route add -net 224.0.0.0 gw 172.16.24.89 netmask 255.0.0.0 eth0
Now you want to add the default gateway to 172.16.24.100. If
the host route command was used above, you'll need another one
for this host.
/sbin/route add -host 172.16.24.89 eth0
If the net route command was used, it already has a route, and
that is not necessary. Just add the default route,
/sbin/route add default gw 172.16.24.100 eth0
Different versions of the route command print the tables with different
formatting, but it appears to me that your Linux box would then have a
route table that is printed something like this, if the individual host
route commands are used:
Destination Gateway Genmask Flags Mss Window Iface
172.16.24.89 0.0.0.0 255.255.255.255 UH 40 0 eth0
172.16.24.100 0.0.0.0 255.255.255.255 UH 40 0 eth0
172.16.24.0 172.16.24.89 255.255.255.255 UG 40 0 eth0
224.0.0.0 172.16.24.89 240.0.0.0 UG 40 0 eth0
0.0.0.0 172.16.24.100 0.0.0.0 UG 40 0 eth0
If the network route command is used, it will look a little different:
Destination Gateway Genmask Flags Mss Window Iface
172.16.24.0 172.16.24.89 255.255.255.255 UG 40 0 eth0
224.0.0.0 172.16.24.89 240.0.0.0 UG 40 0 eth0
172.16.24.0 0.0.0.0 255.255.255.0 U 40 0 eth0
0.0.0.0 172.16.24.100 0.0.0.0 UG 40 0 eth0
Note that the most restrictive route is listed first, hence the switch
in the order they are listed. The results are exactly the same though.
Note also that current version of ifconfig will automatically add a
network route to whatever subnet matches the configured IP address.
You may want to delete that, or you might want to use it... depending
one what it is. For example, if eth0 is configured with an IP address
of 172.16.24.5, the above "172.16.24.0 0.0.0.0 255.255.255 ..."
network route will already be there. If the eth0 address is in some
other subnet range, it will need to be deleted.
-- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com
- Next message: Floyd L. Davidson: "Re: Linux Routing Woes"
- Previous message: Floyd L. Davidson: "Re: WRT54GS and port forwarding ssh"
- In reply to: Jeff: "Linux Routing Woes"
- Next in thread: Sir Jackery: "Re: Linux Routing Woes"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|