Linux FAQ / Howtos
Solaris UNIX Add Static Routes
Q. How do I add Static Routes under Solaris UNIX? My default gateway configured in /etc/defaultrouter, but what is the proper place to configure static routes for a Solaris UNIX server? Can you tell me exact configuration file name for a static routing?
A.. There are many ways to configure static routing under Solaris UNIX.
Task: Display current routing table
Use netstat command, enter:
# netstat -nr
Task: Delete a route
To delete a route, enter:
# route delete dest gateway
# route delete myhost myrouter
Method # 1: Set static routes using route command
Use route command to add static route on fly (dynamic modification of routing table), enter:
# route add dest gateway
# route add net 10.0.0.0 netmask 255.0.0.0 10.20.110.1
# route add net 192.168.1.0 192.168.1.254
# route add host myhostname myrotername
The only drawback is static routes are not persistence i.e. routing will be deleted when Solaris box get rebooted.
Method # 2: Set static routing using /etc/gateways configuration for in.routed
The file /etc/gateways is act as configuration file for /usr/sbin/in.routed IPv4 network routing daemon. All you have to do is put static route per line using following format:
net Nname[/mask] gateway Gname metric value
Open config file:
# vi /etc/gateways
Append following entries:
net 192.168.1.0 gateway 192.168.1.254 metric 1 passive
net 10.0.0.0 gateway 10.20.110.1 metric 1 active
You must one of these keywords must be present to indicate whether the gateway should be treated as passive or active, or whether the gateway is external to the scope of the RIP protocol. A passive gateway is not expected to exchange routing information, while gateways marked active should be willing to exchange RIP packets. The keywoard passive should be used if you want the entry to be permanent.The keyword active should be used if you want in.routed to occasionally query the gateway host, and delte the route if it becomes inactive. See in.routed man page for further details.
Save and close the file. You can set default router in /etc/defaultrouter file.
Method #3 : Managing routing using routeadm command
Solaris has routeadm command which is used to administer system-wide configuration for IP forwarding and routing. IP forwarding is the passing of IP packets from one network to another; IP routing is the use of a routing protocol to determine routes. You need to use /etc/defaultrouter to setup the default route and /etc/gateways to set static routing. To start the in.routed, enter:
# routeadm -u -e ipv4-routing
To view current routing configuration, enter:
# routeadm
To stop the in.routed daemon, enter:
# routeadm -u -d ipv4-routing
Method # 4: Old way - Create a init script
Login as root and type the command:
# cd /etc/rc2.d/
# touch S99static-routes
# chmod +x S99static-routes
# vi S99static-routes
Write a shell script and append static route using route command itself:
#/bin/sh
route add net 192.168.1.0 netmask 255.255.255.0 192.168.1.254 1
route add net 10.0.0.0 netmask 255.0.0.0 10.20.110.1
Save and close the file.
I recommend using method # 2 to create static routing under Solaris UNIX. See following man pages for further details:
$ man in.routed
$ man route
$ man gateways
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our daily email newsletter to make sure you don't miss a single tip/tricks. Subscribe to our weekly newsletter here!
* Email FAQ to a friend
* Printable version
* Rss Feed
* Last Updated: 2-21-08
{ 3 comments… read them below or add one }
1 Vireak Muth 01.19.09 at 1:59 pm
Good website for research
2 Brian 04.08.09 at 2:03 pm
good helpful information!
3 Giuseppe Sacco 04.21.09 at 5:48 pm
I found this site after trying using /etc/gateways on solaris 8. Solution #2 did not worked since in.routed will not be started when booting a system with a single nic.
Leave a Comment
Name *
E-mail *
Website
Tagged as: /etc/defaultrouter, /etc/gateways, default gateway, default routing, defaultrouter, destination gateway, ip address routing, ip routing, metric value, netstat command, network routing, networking routing, route command, routeadm command, routing gateway, routing table, static route, static routes, static routing, tcp ip routing
Previous post: Linux / UNIX Find Out What Program / Service is Listening on a Specific TCP Port
Next post: FreeBSD VLAN Configuration
Sign up for our daily email newsletter:
No comments:
Post a Comment