We now have two networks: 192.168.22.0 and 192.168.44.0. Both contain a number of systems, each of which can communicate with every other system that is connected to their own network. However, they cannot see anything that is connected to the "other" network. hydrogen# ping antimony ICMP Net Unreachable from gateway hydrogen (192.168.22.1) for icmp unreachable from hydrogen (192.168.22.1) to 192.168.44.51 no answer from 192.168.44.51 hydrogen# To enable this to work, we will use a gateway machine that is physically connected to both networks. This means it must have two network connectionsone for each subnet. The machine we are using has two "hme" cards installed, so we'll go ahead and configure these next. After the tasks have been carried out, the network will be configured as shown in Figure 11.3. Figure 11.3. The completed network, including the gateway. Each interface needs to be assigned an IP address. We have decided to connect the primary interface, "hme0," to the internal network (192.168.22.0), and the second interface, "hme1," to the external facing network (192.168.44.0). From the hosts file we built earlier, the following addresses were defined: indium# more /etc/hosts <lines removed for clarity> # # Gateway machine with two interfaces # Supernet mask: 255.255.255.128 # 192.168.22.49 indium in 192.168.44.50 tin sn <lines removed for clarity> indium# We have updated the files shown below to assign the correct IP address to the relevant interface: indium# cat /etc/hostname.hme0 indium indium# indium# cat /etc/hostname.hme1 tin indium# indium# cat /etc/inet/netmasks 192.168.22.0 255.255.255.128 192.168.44.0 255.255.255.128 indium# As an aside, we can see from the shell prompt that the machine is called "indium," rather than "tin." It gets this information from another file named /etc/nodename. If we check its contents we'll see it contains the information below. It doesn't matter which interface is the "primary" and which is the "secondary": indium# cat /etc/nodename indium indium# After rebooting the system, we will see both interfaces will be enabled, and the system will, by default, act as a router between the two subnets. indium# ifconfig -a lo0: flags=849<UP,LOOPBACK,RUNNING,MULTICAST> mtu 8232 inet 127.0.0.1 netmask ff000000 hme0: flags=863<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.22.49 netmask ffffff80 broadcast 192.168.22.127 ether 8:0:20:dd:56:32 hme1: flags=863<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.44.50 netmask ffffff80 broadcast 192.168.44.127 ether 8:0:20:dd:56:32 indium# We can see from the output below that packets to the subnets are sent through the interface that is connected to the particular network: indium# netstat -rn Routing Table: Destination Gateway Flags Ref Use Interface --------------- ----------------- ----- ----- ------ --------- 192.168.22.0 192.168.22.49 U 3 5 hme0 192.168.44.0 192.168.44.50 U 3 5 hme1 127.0.0.1 127.0.0.1 UH 0 2 lo0 indium# For routing to work successfully, each machine needs a route to a host, and the host needs to have a route back. The gateway works fine because it has a network connection on each subnet, so each host it pings can acknowledge via its own subnet. This means that indium can now see every machine on both networks: indium# ping hydrogen hydrogen is alive indium# indium# ping antimony antimony is alive indium# |