A noticeable difference when using a system script such as ifup rather than ifconfig on its own, is that the systems routing tables are set in one case and not in the other.
This is because either the /etc/sysconfig/network
(or /etc/network/interfaces on Debian) file is read,
where a default gateway is stored, or the DHCP server has sent this information
together with the IP number. The routing tables are configured, checked and
changed with the /sbin/route tool.
Add a static route to the network 10.0.0.0 through the device
eth1 and use 192.168.1.108 as the gateway for
that network:
/sbin/route add -net 10.0.0.0 gw 192.168.1.108 dev eth1
Add a default gateway:
/sbin/route add default gw 192.168.1.1 eth0
Listing the kernel routing table:
/sbin/route -n Kernel IP routing table Destination Gateway Genmask Iface 192.168.1.0 0.0.0.0 255.255.255.0 eth0 10.1.8.0 192.168.1.108 255.0.0.0 eth1 127.0.0.0 0.0.0.0 255.0.0.0 lo 0.0.0.0 192.168.1.1 0.0.0.0 eth0
In the last listing, the Destination field is a list of networks. In particular, 0.0.0.0 means anywhere. With this in mind, there are two IPs in the Gateway field. Which one is the default gateway?
If you have several networks with more than one gateway you can use the
/etc/sysconfig/static-routes (instead of routing daemons).
These routes will be added at boot time by the network script.
If you belong to the 192.168.10.0 network and you add a route to the 192.168.1.0 network you may find that machines in the latter network are not responding. This is because no route has been set from the 192.168.1.0 network back to your host! This problem can be solved using dynamic routing.
To avoid having to enter static routes by hand special daemons gated or routed may be run to dynamically update routing tables across a network. For Linux routers there are two such daemons:
Using the /etc/networks file it is possible to
assign names to network numbers (for network numbers see
Chapter 5, TCP/IP Networks)
/etc/networks format
network-name network-number aliases
For example, the network number 10.0.0.0 can be called
office.org, following the above format.
It is then possible to use network names with tools like
route as below:
route add -net office.org netmask 255.0.0.0