We generally think that a router is connected to multiple networks, so it should have a NIC and an IP address for each network. However, in practice, you may need to create an Intranet to solve the problem of insufficient IP addresses on the Internet, and the workstation often has integrated a NIC on its own motherboard. How can we use existing resources to set up routers? However, a single Nic workstation can be configured with a TCP/IP router. On the SUN Workstation With the Solaris2.x operating system, you can configure it as follows.
1. Configure vro Interfaces
1. Create the/etc/hostname. interface file.
Each connected network should have a hostname. interface file, where interface is the name of the NIC. The interfaces for multiple NICs should be different, but the interfaces for these files are the same for a single Nic router. How can we differentiate these files? You can create a hostname. interface: n file and use n as the difference to virtualize multiple NICs. When the computer starts, it will detect the number of such files. If multiple hostname. interface files are found, they are considered as routers; otherwise, they are considered as hosts. For example, if a SUN Workstation is connected to the Internet and Intranet, two files can be created: hostname. le0 and hostname. le0: 2.
2. assign a host name for the interface
In each of the above hostname. interface files, add the host name. You must note that different network interfaces correspond to the same host, that is, you must use different host names to distinguish different IP addresses. For the above example, use the vi command to edit the two files into sun1 and sun2, which are actually a host.
3. Add the Host Name and IP address to/etc/inet/hosts in the format:
IPaddresshostname
202.114.209.37sun1
180.114.20.1sun2
Note that the IP address is the IP address of the network adapter that corresponds to multiple networks. 202.114.209.37 is the valid IP address of the host on the Internet, while 180.114.20.1 is the address assigned by the host on the Intranet, the IP address on the Intranet does not have to worry about conflict with the IP address with a duplicate name on the Internet, because the upper-level gateway will regard it as illegal and refuse to provide services.
4. Modify the/etc/inet/netmasks File
If the vro is connected to a subnet, modify/etc/inet/netmasks and enter the subnet network number (such as 129.9.0.0) and Shield number (such as 255.255.255.0 ).
Ii. Routing Protocol Selection
Static or dynamic routing protocols such as RIP and RDISC can be used ).
When dynamic routing protocol is selected, you can leave the/etc/defaultrouter file blank. The router automatically communicates with RIP and RDISC. These protocols track the router and broadcast route information so that the router can work in local file mode. This ensures that the router can work as usual after the configuration of the network server fails.
If you select static protocols, you only need to enter the default router name in the/etc/defaultrouter file, so that when the Unix router cannot find the path routing, the IP packet is sent to the default router. In this example, if misrouter is used as the default router, you also need to add its IP address: 202.114.209.19 and machine name to/etc/inet/hosts:
Misrouter.
3. restart the computer
When the computer starts, the system calls the ifconfig command to configure interfaces for multiple connected networks and detects that multiple hostname. interface files exist. Therefore, the computer considers itself as a router.
A single Nic router is configured. Computers on all intranets can communicate with each other using internal IP addresses.
Communication over the Internet is performed through a single Nic's Unix router. It can be seen that although it is a single Nic, It has multiple IP addresses. In essence, it uses the virtual interface file hostname. interface: n to "Impersonate" multiple NICs.