Network Routing Basics

We've seen how TCP/IP addresses combined with netmasks determine networks. For example, and are on separate networks if the netmask is (a class C netmask).

If this concept isn't completely clear to you, go back and review.

See Networks 101 and Advanced TCP and CIDR

So, let's say that is our server, and is a Windows machine. Again, it's a class C netmask (, so there is going to have to be a router in the network. That router is going to have to have one port on the 192.168.200 network, and one on the 192.168.201 network.

How that happens depends on the router, but usually these things get configured initially by connecting to a serial port, and typing commands to set addresses and protocols on the other network ports. For the purposes of this article, we'll assume that the router has one port addressed at and another at (it's very common for routers to use the "1" address).

Starting at the Win machine, it needs to have a route so that it can get off its network (192.168.201) to the server's network (192.168.200). You'd do this in Settings->Control Panel ->Networks. Under the Properties for TCP/IP, you'd find a tab for Gateway. Here you'd enter the address of the router port on your network. That's because the Win machine is on the 192.168.201 network.

If you dropped out to DOS and typed "ping" (that's the server address) before setting that gateway, you'd get "Destination host unreachable" (from a Unix machine you would get "No route to host"). After making this setting (and rebooting the machine, you'll get "Request timed out" instead.

See Why "no route to host" when it can be pinged? also.

The problem is that the Win machine knows how to get to the server through the router, but the server doesn't know how to get back. The server needs a route to get to the 192.168.200 network.

So we need to do it there, also. If the server were a SCO Unix machine, we might type "route add default" (on older SCO you'd do "route add 0".

Note that we are saying our route goes to, not to a specific address: the .0 says we're giving a route to the whole network. If this were a class A network ( netmask) we'd use route add, etc.

Linux is similar, but you need "gw" in there: "route add default gw"

NT is similar to Win, though in both cases you can also issue "route add" commands at the command prompt. With NT and (I think) , doing this adds the routing information to the registry, so it sticks through a reboot. On SCO, that's not the case. You'll need to add the commands to a start-up file (/etc/rc2.d/S99route, for example: it doesn't exist, but you can create it) or modify the /etc/gateways file (see 'man routed'for the syntax of that file). The disadvantage of /etc/gateways is that it is used by routed, so if you are not running routed, that won't work.

You could also modify /etc/tcp and add your routes after it sets up its default routes. That has the disadvantage of modifying a system file: an upgrade will overwrite that.

SCO 5.0.4 adds a /etc/rc2.d/S90iproute script that reads /usr/internet/etc/sco_ip/routes. It's the Internet Manager that can add info to that file, but there's no reason you can't do it manually. The format is simple:

# comments are ok
# simple form
net default
# it's smart enough to delete the previous default
net default 
# routes to specific hosts
# netmasks optional
# if field 1 isn't host or net, it's ignored

Another advantage of this script is that when called with "stop" (/etc/rc2.d/S90iproute stop), it will delete the routes listed in the file.

Beginning with 5.0.6, you can add the default route in /etc/default/tcp. Just modify the GATEWAY= line, and /etc/tcp will read that. DON'T DO THIS ON PRIOR RELEASES; /etc/tcp doesn't look for that until 5.0.6

So how does the OS know where to send a packet when you have more than one card in your machine such as when you have DS internet access and an internal network? You may not have realized this, but that's routing.

The OS "knows" by the addresseses and netmask you have put on the cards.

Lets say you have two cards: your internal network card which is with a mask of, and your external card which gets a DHCP address that's real, but let's pretend that right this minute it's,xyz.12 again with a mask.

If you "ping" (some other machine on your internal network, the only place that packet will be sent to is your card.

If you ping something on the network of the other card, that's where those packets will go.

So what if you ping something else like "" ? That's where your default route comes into play. It might, for example, be,xyz.1. It *has* to be something on one of the networks defined by your cards. It could not be "" for instance because you have no such network. So, if it were, the packets would go out your 64. interface and find their way to that router, which presumably can get them to the 132 address, either directly or by sending them along somewhere else.

You can see this stuff in action by using "traceroute"

Here's a traceroute from my machine to

 1 (  12.640 ms  23.976 ms  12.765 ms
 2 (  12.103 ms  13.057 ms  12.767 ms
 3 (  12.732 ms  12.472 ms  12.177 ms
 4 (  13.177 ms  22.586 ms  11.567 ms
 5 (  16.168 ms  14.617 ms  16.164 ms
 6 (  15.968 ms  21.932 ms  19.366 ms
 7 (  14.354 ms  16.152 ms  20.548 ms
 8 (  40.957 ms  25.775 ms  19.749 ms
 9 (  22.161 ms  20.915 ms  18.146 ms
10 (  49.996 ms  21.813 ms  20.946 ms
11 (  20.369 ms  21.435 ms  19.783 ms
12 (  20.199 ms  20.250 ms  20.146 ms
13  283.ATM7-0.XR1.BOS1.ALTER.NET (  30.349 ms  30.457 ms  29.981 ms
14  191.ATM7-0.GW3.BOS1.ALTER.NET (  35.961 ms  26.439 ms  40.353 ms
15 (  43.999 ms  61.854 ms  50.184 ms
16 (  63.528 ms  81.948 ms  84.958 ms

No route to host

It's important to understand that this message doesn't necessarily come from the system that tried to get somewhere. It comes from the machine doesn't know how to get to the next stop. If your own routing table is incorrect, then it's you. If you can get to at least the next hop (as seen in a traceroute), then the "no route" message comes from them, not you. That could mean you have the wrong gateway route, but it could also mean that they do. See Telnet: route to host for a detailed explanation.

See also :

Networking 101

Advanced TCP


Got something to add? Send me email.

(OLDER) <- More Stuff -> (NEWER)    (NEWEST)   

Printer Friendly Version

-> -> Network Routing Basics


Increase ad revenue 50-250% with Ezoic

More Articles by

Find me on Google+

© Tony Lawrence

To keep things saved after a reboot for NT/2K, you must specify:

route add -p mask

The -p should save the route in the registry.

- Bruce Garlock

Tue Apr 5 18:03:07 2011: 9431   Martin


Thanks for this overview.
I was hoping that I could set up routing from my XP machine so that when I am connected to a VPN, I could still access my email on the internet by routing packets through the default interface connection, but this does not seem to work. Your comment about the server not knowing how to get back made me think that maybe that is the reason, but then how am I able to access my email if not connected to the VPN?

Tue Apr 5 20:19:52 2011: 9432   TonyLawrence


Most vpn's that I have used offer a choice of leaving the gateway alone or sending through the VPN. Are you sure you didn't just miss that in the set up?

Thu May 26 09:41:09 2011: 9513   anonymous


I have the same problem (wish :-)).
I am sure there is no way to enable it in client. So, is there any way to do it using routing?

Thu May 26 11:02:47 2011: 9514   TonyLawrence


You can set your route to anything you want. However, it's still up to that machine whether or not it will route your packets and return the results to you.

Sat Apr 27 13:54:45 2013: 12048   Bell


Hello everyone!!

I have Within my network some users that have need to access to another LAN in order to access that LAN INTRANET for work purposes.

Thats how my LAN design is: ROUTER��ASA��TMG��LOCAL LAN.
SO My local LAN uses a DHCP server for distribuiting IP ADD on

These user normally goes to that specific INTRANET through internet.

The thing is, i want those users to still get access to the even if there�s no internet connection, so they can access minfin intranet and keep there job going.

So we got a Router, that is connected to a dedicated telefone line, that connect to the Minfin like a frame relay. in that router two interface i have the following configuration that where done by the Minfin:

So this is what is configured on the Fa to Minfin

And on ther Fa is thats the interface that connects to my LAN.

On the other side, we have to configure manually a static route in the ROUTE PRINT

Verificar e adicionar rotas est�ticas.

Route print

Caso n�o haja rotas est�ticas, adicionar manualmente
Route add -p mask
Route add -p mask
Route add -p mask

So the thing is, i use DHPC to address LAN ip addressing,

How can my internal PCs still access the INTRANET even is theres no internet?

What other configuration i must do and where?

Please help


Sat Apr 27 14:05:39 2013: 12049   TonyLawrence


Don't have them use the public IP. Set in /etc/hosts with its internal LAN address.

Kerio Samepage

Have you tried Searching this site?

Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.

Contact us

privacy policy