LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 05-23-2005, 11:24 PM   #1
beebop
Member
 
Registered: Sep 2004
Location: Bend, Oregon
Distribution: Ubuntu Breezy and FC4
Posts: 43

Rep: Reputation: 15
unable to add default route (network unreachable)


I am trying to connect my laptop to the ethernet at work. However, I cannot ping the router from my laptop, even though I am using the same cable as my work's desktop (I'm unplugging from the desktop and plugging in my laptop).

Booting into my freshly installed Fedora Core 3 partition doesn't work. I ran this

ifconfig eth0 192.168.0.71 netmask 255.255.255.224
ping 192.168.0.1

and no pings went through. Pinging 192.168.0.71 works fine though, so I know eth0 is working... And yes, the cable is connected :) Booting into windows on my laptop connects to the 'net just fine using the same cable. I just had to use the same static IP, gateway, and netmask as the desktop.

So I though the routing table might be off. Here's what `/sbin/route` shows:

Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.0.71 * 255.255.255.224 U 0 0 0 eth0

I thought, "why isn't there a default gateway?" so I typed `/sbin/route add default gw 192.168.0.1` which resulted in:

STOCADDRT: Network is unreachable

Any ideas?

Last edited by beebop; 05-23-2005 at 11:25 PM.
 
Old 05-23-2005, 11:33 PM   #2
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 50
why wouldn't be the netmask 255.255.255.0?
 
Old 05-24-2005, 04:45 AM   #3
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

By using 255.255.255.224 mask, this makes 32 hosts (well 30 if you count with network & broadcast addresses) in your network. Beeing the .71 host, your network ranges from 192.168.0.64 (network address) to 192.168.0.95 (broadcast address).
Thus 192.168.0.1 is not in your subnet. If it also has the samemask, it's subnet starts at 192.168.0.0 (network address) and ends at 192.168.0.31 (broadcast address).
So if you didn't mistake yourself with the mask, then you _have_ to choose an IP between 192.168.0.2 and 192.168.0.30.

If you can change the mask to 255.255.255.0 on _every_ machine of your LAN, I'll really advise you to do so, since it's much more simple to manage (with a .0 mask, network range is from .0 to .255 which is more common)
 
Old 05-24-2005, 08:11 AM   #4
beebop
Member
 
Registered: Sep 2004
Location: Bend, Oregon
Distribution: Ubuntu Breezy and FC4
Posts: 43

Original Poster
Rep: Reputation: 15
Well, the thing is, I am not the sysadmin of my workplace. But I believe he set up the netmask like that so he could make a sub-subnet with our alotted IPs. We only have about 10 computers, some for clients to use for browsing the net and checking email, and some more restrictive ones for accounting and stuff. I'm trying to connect to the "email" computer subnet.

But why would my windows partition connect? It uses the exact same numbers. 192.168.0.71, 255.255.255.224, and 192.168.0.1 for the gateway. It makes sense that it wouldn't be able to see the 192.168.0.1 because of the mask, so maybe there's some link before the internet gateway. Yeah, I bet I'm trying to make 2 hops, which requires some addition to the routing table in my laptop. Does Windows create the correct routing table automatically or something?

I'm trying to get ahold of the sysadmin, but he's busy with other companies, too. In the meantime, I'll keep plugging away with LQ's help I love this site!
 
Old 05-24-2005, 08:18 AM   #5
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Re,

it's possible that the Win PC got a route to 192.168.0.0 either configured 'in hard' or through dhcp. You can check it out with the 'route print' command in a DOS terminal.
 
Old 05-24-2005, 05:02 PM   #6
beebop
Member
 
Registered: Sep 2004
Location: Bend, Oregon
Distribution: Ubuntu Breezy and FC4
Posts: 43

Original Poster
Rep: Reputation: 15
Below is a printout from my windows partition on my laptop while connected to the ethernet cable at work. After rebooting into linux and running

route add 0.0.0.0 netmask 0.0.0.0 gw 192.168.0.1

I got the same 'network unreachable' error as before. I don't get why windows can get away with adding the default. Well, hopefully this printout will help answer some questions:

C:\Documents and Settings\becker>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 a0 cc c3 70 86 ...... SiS 900 PCI Fast Ethernet Adapter - Packet Sched
uler Miniport
===========================================================================
===========================================================================
Active Routes:
Network Destination Netmask Gateway Interface Metric
0.0.0.0 0.0.0.0 192.168.0.1 192.168.0.71 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
192.168.0.64 255.255.255.224 192.168.0.71 192.168.0.71 20
192.168.0.71 255.255.255.255 127.0.0.1 127.0.0.1 20
192.168.0.255 255.255.255.255 192.168.0.71 192.168.0.71 20
224.0.0.0 240.0.0.0 192.168.0.71 192.168.0.71 20
255.255.255.255 255.255.255.255 192.168.0.71 192.168.0.71 1
Default Gateway: 192.168.0.1
===========================================================================
Persistent Routes:
None

C:\Documents and Settings\becker>
 
Old 05-25-2005, 03:29 PM   #7
mrcheeks
Senior Member
 
Registered: Mar 2004
Location: far enough
Distribution: OS X 10.6.7
Posts: 1,690

Rep: Reputation: 50
could it be because you didn't put any nameserver in /etc/resolv.conf?
 
Old 05-26-2005, 05:04 AM   #8
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

I don't think it's linked to dns, since the route he tries to add doesn't contains references to names, only IPs.

this one route is queer :
192.168.0.255 255.255.255.255 192.168.0.71 192.168.0.71 20

it says : if you want to talk to 192.168.0.255, then do it right through your ethernet interface, there's no router in-between... why not, but that's a broadcast address... I don't think there's an host with this IP !

Maybe you could try to add this route in your Linux box and then add the default gw. I don't see why it would work, but that's the only thing that's not classical in your windows routing table (and you do have a routing issue, since your gateway is not in the same subnet as your Linux box).
 
Old 05-26-2005, 07:14 AM   #9
scowles
Member
 
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620

Rep: Reputation: 31
I guess Microsoft's tcp/ip stack compensates for specifying a gateway address outside the host address range for the subnet.

Just for grins, I tried configuring my XP box with the same netmask and... whoa! it worked.
Code:
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
          0.0.0.0          0.0.0.0      192.168.9.1    192.168.9.71       1
        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1
     192.168.9.64  255.255.255.224     192.168.9.71    192.168.9.71       1
     192.168.9.71  255.255.255.255        127.0.0.1       127.0.0.1       1
    192.168.9.255  255.255.255.255     192.168.9.71    192.168.9.71       1
        224.0.0.0        240.0.0.0     192.168.9.71    192.168.9.71       1
  255.255.255.255  255.255.255.255     192.168.9.71    192.168.9.71       1
Default Gateway:       192.168.9.1
===========================================================================

C:\>ping 192.168.9.1

Pinging 192.168.9.1 with 32 bytes of data:

Reply from 192.168.9.1: bytes=32 time<1ms TTL=64
Reply from 192.168.9.1: bytes=32 time<1ms TTL=64
Reply from 192.168.9.1: bytes=32 time<1ms TTL=64
Reply from 192.168.9.1: bytes=32 time<1ms TTL=64

C:\>ping www.yahoo.com

Pinging www.yahoo.akadns.net [68.142.197.83] with 32 bytes of data:

Reply from 68.142.197.83: bytes=32 time=27ms TTL=58
Reply from 68.142.197.83: bytes=32 time=25ms TTL=58
Reply from 68.142.197.83: bytes=32 time=25ms TTL=58
Reply from 68.142.197.83: bytes=32 time=25ms TTL=58
Incredible! In a perfect world, the above should NOT work. But then look at the classful broadcast address that the MS stack calculated. Again, in a perfect world (well classless at least), the broadcast address should be 192.168.9.95

To the OP - the problem description and solution that fr_laz posted is correct. Until you change your netmask to 255.255.255.0, the linux tcp/ip stack is NOT going to allow you to add a defualt route which is outside the host address range for the network address. Why the Micosoft stack does is anyones guess. You would think Microsoft would perform some sort of sanity check when you hit the OK button. <groan!>

Last edited by scowles; 05-27-2005 at 05:07 AM.
 
Old 05-26-2005, 02:22 PM   #10
beebop
Member
 
Registered: Sep 2004
Location: Bend, Oregon
Distribution: Ubuntu Breezy and FC4
Posts: 43

Original Poster
Rep: Reputation: 15
Hey guys, thanks for all your help. It's working fine now. I figured, "If my router (192.168.0.1) is outside my subnet (255.255.255.224), why not change my subnet to include it? So on my laptop I ran

ifconfig eth0 192.168.0.71 subnet 255.255.255.0 <--- note the changed subnet

and it worked just fine. I'm still confused as to why the the sysadmin configured the subnet with the 224, but oh well. My laptop works now and that's all that matters.

--Beebop
 
Old 05-27-2005, 05:48 AM   #11
scowles
Member
 
Registered: Sep 2004
Location: Texas, USA
Distribution: Fedora
Posts: 620

Rep: Reputation: 31
Glad you are up and running

For future reference - most, if not all linux distro's include a command called "ipcalc" (which I should have used before I posted my previous reply. I incorrectly stated the broadcast address). Anyway, given an IP/netmask combination...
Code:
[root@excelsior sysconfig]# ipcalc --network 192.168.0.71 255.255.255.224       
NETWORK=192.168.0.64
[root@excelsior sysconfig]# ipcalc --broadcast 192.168.0.71 255.255.255.224     
BROADCAST=192.168.0.95
...the host addressable range (including the default route) should fall between the two. The default route is "usually" the lower or upper end of the host address range. i.e.
Code:
NETWORK=192.168.0.64
HOST_ADDRESS_1=192.168.0.65  <- typical default route
.... PC/Server addresses
HOST_ADDRESS_30=192.168.0.94  <- typical default route
BROADCAST=192.168.0.95
 
Old 05-30-2005, 04:49 AM   #12
fr_laz
Member
 
Registered: Jan 2005
Location: Cork Ireland
Distribution: Debian
Posts: 384

Rep: Reputation: 32
Hi,

for info there's also a perl version of ipcalc, which can be usefull when scripting...
 
Old 05-30-2005, 11:07 AM   #13
charon79m
Member
 
Registered: Oct 2003
Distribution: Just about anything... so long as it is Debain based.
Posts: 297

Rep: Reputation: 30
I've set-up networks like this previously. The reason I did it was to provide an incorrect default gw to disallow internet acccess to users that should not have Internet connection. On these networks, we used a proxy server for internet access and there was no "Default Gateway" that allowed for direct internet access.

It was simply a way of confusing those who did not know how our network worked. Those who tired to figure it out were quickly detected by our IDS and dealt with.

In all, it was an effective method of controlling the network.

MrKnisely
 
  


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
Network route add file David@330 Linux - Networking 4 05-26-2005 07:38 AM
How to add a route table for eth1 and make it the default banner Linux - General 3 05-08-2005 11:14 AM
add a static route in Network init files Ghitza Linux - Networking 1 11-19-2004 05:26 AM
Route to subnet exists but I get "Network unreachable" when adding default route fciuffani Linux - Networking 4 08-18-2004 02:11 PM
route add default gw ... dhsieh Linux - Software 1 10-15-2003 01:40 PM


All times are GMT -5. The time now is 04:17 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration