This procedure enables static routing on a single-interface host. Hosts that use static routing do not run a dynamic routing protocol such as RIP. Instead, the host must rely on the services of a default router for routing information. The figure IPv4 Autonomous System Topology shows several default routers and their client hosts. If you supplied the name of a default router when you installed a particular host, that host is already configured to use static routing.
You can also use the following procedure to configure static routing on a multihomed host.
For information about the /etc/defaultrouter file, see /etc/defaultrouter File. For information about static routing and the routing table, refer to Routing Tables and Routing Types.
On the single interface host, assume the Primary Administrator role, or become superuser.
The Primary Administrator role includes the Primary Administrator profile. To create the role and assign the role to a user, see Chapter 2, Working With the Solaris Management Console (Tasks), in System Administration Guide: Basic Administration.
Verify whether the /etc/defaultrouter file is present on the host.
# cd /etc # ls | grep defaultrouter |
Open a text editor to create or modify the /etc/defaultrouter file
Add an entry for the default router.
# vi /etc/defaultrouter router-IP |
where router-IP indicates the IP address of the default router for the host to use.
Verify that routing and packet forwarding are not running on the host.
# routeadm Configuration Current Current Option Configuration System State --------------------------------------------------------------- IPv4 routing disabled disabled IPv6 routing disabled disabled IPv4 forwarding disabled disabled IPv6 forwarding disabled disabled Routing services "route:default ripng:default" |
Add an entry for the default router in the local /etc/inet/hosts file.
For information about configuring /etc/inet/hosts, refer to How to Change the IPv4 Address and Other Network Configuration Parameters.
The following example shows how to configure static routing for hostb, a single-interface host on the network 172.20.1.0 that is shown in Figure 5–3. hostb needs to use Router 2 as its default router.
First, you would log in to hostb as superuser, or assume an equivalent role. Then, you would determine whether the /etc/defaultrouter file is present on the host:
# cd /etc # ls | grep defaultrouter |
No response from grep indicates that you need to create the /etc/defaultrouter file.
# vi /etc/defaultrouter 172.20.1.10 |
The entry in the /etc/defaultrouter file is the IP address of the interface on Router 2, which is attached to the 172.20.1.0 network. Next, you verify whether the host currently enables packet forwarding or routing.
# routeadm Configuration Current Current Option Configuration System State --------------------------------------------------------------- IPv4 routing disabled disabled IPv6 routing disabled disabled IPv4 forwarding enabled enabled IPv6 forwarding disabled disabled Routing services "route:default ripng:default" |
Packet forwarding is enabled for this particular host. You would turn it off as follows:
# svcadm disable ipv4-forwarding |
Lastly, you would make sure that the host's /etc/inet/hosts file has an entry for the new default router.
# vi /etc/inet/hosts 127.0.0.1 localhost 172.20.1.18 host2 #primary network interface for host2 172.20.1.10 router2 #default router for host2 |