Setting Up Routes To Foreign IP Networks

Definition
In order to assist understanding of this note, it is important to understand the term "IP network".

Each physically separate connection is a separate IP network. Therefore, if you have Ethernet attached to your machine, that is one network. If you have one port of an X.25 card attached to an IP over X.25 system, that is a different IP network. If you have a second port on an X.25 card attached to an IP over X.25 system, that is a different (a third) IP network. Even if the two X.25 wires are attached to the same X.25 system, you still have two networks. (From the perspective of your machine, these are two separate physically entities — two wires — and therefore two networks.)

The other key part to note about the definition of an IP network is that each network (each physical connection) must have a different network portion in its address.

A host on a foreign IP network is therefore a host with an IP address whose network portion does not match any of those in the local machine.

The NetcomRouter User's Guide goes into more detail about this topic including the general selection of "good" IP addresses.


The Problem
When you have complete control over the selection of IP addresses, the easiest (and therefore generally preferable) method of handling IP routing is to assign everyone on the same network an address with the same network portion. For example, all the hosts on ethernet (including the local interface) may be 192.1.2. something and all the hosts that can be reached via X.25 (including the local "xinet" interface) may have an IP address of 192.3.4something. IP will then implicitly know how to reach the remote hosts. IP will simply send the data to the local interface that has an IP address with a matching network portion of the host you are trying to reach.

But what if the network portion of the address of someone you want to reach is not on the same network as any of the local interfaces? What if, in the example above, you want to reach 192.5.6.something and it can be accessed via X.25? IP will not automatically know how to reach that host, so you have to set up some routes.

Again, it is much easier to have everyone you want to reach via the same interface on the same IP network. So if you can adjust the IP addresses to achieve this, then do so. The rest of this note describes what to do if you have to keep some assigned IP addresses.


IP Routing
By now, the experienced IP administrator will be thinking of the IP command "route add ...". There is however one very common pitfall that you must watch out for.

Let's refer to the above example and add in some host numbers. Suppose local IP address for NetcomRouter (for the xinet0 interface) is 192.3.4.1 and the remote is 192.5.6.100. The first thing you might want to do is:
          route add 192.5.6.100 192.3.4.1 1
          or
          route add net 192.5.6 192.3.4.1 1
where the final "1" in each case is the metric or the number of "hops" to the remote host. You do NOT want to do this. Think of this from IP's perspective. You are telling it to send the data to 192.3.4.1 first. IP looks at this and responds "OK, I'm already there. 192.3.4.1 is me." Therefore, the data does not get sent to any interface. The remote machine doesn't get the data.

What you need to do is route the call to some remote host. The network portion of the IP address should match the appropriate local interface, but the host portion must be different. You must do this even if you are just creating an alias for the remote machine.

Back to the example. Suppose we give the host 192.5.6.100 a second IP address — one on the xinet network such as 192.3.4.100. Then set up the routing:
          route add 192.5.6.100 192.3.4.100 1
          or
          route add net 192.5.6 192.3.4.100 1
Now IP will try to send the data to 192.3.4.100, the alias for the remote host. Also, since the local IP address for the xinet interface is 192.3.4.1, IP will send the data to NetcomRouter — exactly what you want.

There is just one thing more that you need to do. NetcomRouter will be told to send the data to 192.3.4.100 (the alias). If you set up /etc/x25hosts for this IP address, NetcomRouter can deliver it. Just add a second entry to the file for the alias name and use the same X.25 address:
192.5.6.100 89035555 link00 IP 192.3.4.100 89035555 link00 IP

That's all. Note that what you have effectively done is created an alias name for routing purposes only. You do NOT have to change the IP address for the remote (for example, in /etc/hosts). For all other purposes, you can refer to the remote by its real name.