Title: add_route

From add_route(8):

"add_route is used for manual entry of routes in the IP routing table.

add_route has the following syntax:

add_route -g gateway [-d destination [-n netmask ]] [-i ip device]


-g gateway specifies the gateway IP address to use.
-d destination specifies the destination(s) reached via this gateway.
-n netmask specifies a netmask when the destination is a net.
-i ip device specifies the ip device.

add_route is implemented in /cmd/src/commands/simple/add_route.c of the CMD TAZ installation floppy.
It makes use of a NWIOIPSROUTE ioctl():

result= ioctl(ip_fd, NWIOSIPIROUTE, &route);

note: before Minix 2.0.4 NWIOIPSROUTE was used instead of NWIOSIPIROUTE

Boot(8) has more information on the overall networking installation.

-- * --

At http://www.geocities.com/ctantignone/routing.txt, there is an example of add_route:

You can manually add routes that are to be used to route packets from one
interface to another, with "add_route -i" ("i" for input, the other `normal'
routes are called output routes)

For example, assume a machine with ip address and netmask on /dev/ip0

The command,
add_route -i -g -d -m 1 -n -I /dev/ip0
adds a route to the directly attached ethernet. A packet for
that arrives at interface ip2 will be routed to ip0 and ARP will
be used to find the ethernet address associated with

It is also possible to specify a remote router. For example,
add_route -i -g -d -m 2 -n
-I /dev/ip0
adds a route to network through router

A third option is to add a default route. For example,
add_route -i -g -d -m 5 -n -I /dev/ip0

The "pr_routes -i" command shows the input routing table:
ent # dest netmask gateway dist pref flags
2 2 0 static
3 1 0 static
4 5 0 static

We also need a routing entry for the PPP interface. For example,
add_route -i -g -d -m 1 -n -I/dev/ip2

The "pr_routes -ai" shows the routing table entries for all interfaces:
ent # dest netmask gateway dist pref flags
2 2 0 static
3 1 0 static
4 5 0 static
5 1 0 static

Note that the "add_route -i" command only affects the routing of packets
that arrive over a network (PPP or ethernet). Packets that are sent by processes are routed using the (normal) output routing table.

Another useful example can be found at Claudio Tantignone's web site.