You are on page 1of 5

4/6/2016 ExamplesofaddingstaticroutesinSolaris

The{Geek}Diary
HowTos|Concepts|Guides

SOLARIS SOLARIS11 ZONES LDOMS VCS LINUX INTERVIEWQUESTIONS ORACLE

ExamplesofaddingstaticroutesinSolaris
BySandeep 4Comments

StaticVsDynamicroutes
Staticroutesareaddedusingtheroutecommandeitherbyascriptorbyusingcommandline.Dynamic
routesareaddedbysomeroutingdaemon.Daemonsthatareresponsibleforaddingdynamicroutesthat
arecurrentlybundled/supportedwithSolarisare/usr/sbin/in.routed(RoutingInformationProtocol(RIP))
and/usr/sbin/in.rdisc(RouterNetworkDiscoveryProtocol).

Usingcommandline
Toaddanonpersistentroutewejustsimpleuserouteaddcommandwithouttheoptionp.Notethat
theseroutesgetsflushedifyourebootthesystem.Beloware2examplesofaddingaroute(192.168.1.1)
forthenetwork10.10.10.0/24

#routeadd10.10.10.0netmask255.255.255.0192.168.1.1
#routeadd10.10.10.0/24192.168.1.1

Toaddapersistentrouteweneedtousethepparameterwiththeroutecommand.Inthefollowing
examplesthenetwork10.10.10.0/24networkusesthegateway192.168.1.1.
http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/ 1/5
4/6/2016 ExamplesofaddingstaticroutesinSolaris

#routepadd10.10.10.0netmask255.255.255.0192.168.1.1
#routepadd10.10.10.0/24192.168.1.1

Toaddapersistentdefaultroute(192.168.1.1):

#routepadddefault192.168.1.1

Toretrieveinformationaboutaspecificroute:

#routegetdefault
routeto:default
destination:default
mask:default
gateway:192.168.1.1
interface:e1000g0
flags:
recvpipesendpipessthreshrtt,msrttvar,mshopcountmtuexpire
00000015000

Todisplaythecompleteroutingtable:

#netstatnr

RoutingTable:IPv4
DestinationGatewayFlagsRefUseInterface

192.168.1.0192.168.1.30U123e1000g0
224.0.0.0192.168.1.30U10e1000g0
224.0.0.0192.168.1.30UG10
127.0.0.1127.0.0.1UH4121lo0

Thevariousflags(intheFlagscolumn):

UTheinterfaceisup.
HHostroute.Thedestinationisasystem,notanetwork.
GThedeliverysystemisanothersystem(anindirectroute).
DTheentrywasaddeddynamicallybyanICMPredirect.

Toseethepersistentroutesaddedinthesystem:

#routepshow
persistent:routeadd10.10.10.0/24192.168.1.1

Todeleteapersistentroute(persistently):

#routepdelete10.10.10.0/24192.168.1.1

Usingrcscript
Theabovecommandlinemethodwillnotworkinsolaris8and9,alsoinsomeolderpatchversionsof
solaris10.Toovercomethiswehaveanothermethod.Wecancreatearcscriptin/etc/rc2.d,saywith

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/ 2/5
4/6/2016 ExamplesofaddingstaticroutesinSolaris

nameS91routes.Addtherouteaddcommandinthisscript:

#/usr/sbin/routeadd10.10.10.0netmask255.255.255.0192.168.1.1

Nowwhenthenexttimethesystembootsupthisscriptwouldrunandaddtheroutespecifiedinthescript.

Otherexamples
Tochangearoute,wecanuseroutechangecommand(tochangedefaultroutefrom192.168.1.1to
10.10.10.1):

#routechangedefault10.10.10.1

TocontinuouslymonitoranychangestotheRoutingtableandroutelookupmisseswecanuseroute
monitorcommand:

#routemonitor
gotmessageofsize124
RTM_DELETE:DeleteRoute:len124,pid:633,seq1,errno0,flags:
locks:inits:
sockaddrs:
192.168.3.0sys11ext255.255.255.0

Toflush(remove)theroutingtableofallgatewayentries,usetherouteflushcommand.

#routeflush
default192.168.1.1done
10.10.10.010.10.10.1done

Tocausetheroutingtabletoflushbeforetheremainingoptionsareevaluated,usetheflushoptionbefore
usingotheroptions:

#routefadd10.10.10.0/24192.168.1.1

Toaddaroutemanuallytothemulticastaddressrangeof224239:

#routeadd224.0/4`unamen`

Toaddadefaultstaticrouteusingthe/etc/defaultrouterfile,addthedefaultrouterIPaddresstothefile
/etc/defaultrouter.Asystemthatisconfiguredwithan/etc/defaultrouterfiledoesnotexecutethein.routed
daemon.

#echo"192.168.1.1">>/etc/defaultrouter

Wecanalsousethe/etc/gatewaysfiletoaddstaticroutes.Ifthe/etc/gatewaysfileexists,thein.routed
daemonreadsthefilewhenitstarts.Nowtoaddastaticroute(192.168.1.1)fornetwork192.168.1.0,edit
the/etc/gatewaysfileandaddbelowentry

#cat/etc/gateways

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/ 3/5
4/6/2016 ExamplesofaddingstaticroutesinSolaris
net192.168.1.0gateway192.168.1.1

SHAREON
Twitter Facebook Google+

FiledUnder:Solaris

RelatedPosts
Scripttoresettheiostaterrorscounters(hard/soft/trn)withoutreboot

HowtomountthezfsrpoolwhilebootedfromCD[SPARC]

M4000/M5000:HowtoassignIPaddresstoXSCFU

ComparingNetworkconfiguration:Solaris10VsSolaris11

Solaris:Howtocreateprocessorset(pset)andassociateitwithapool

LOADCOMMENTS

Searchtheblog...

AboutTheGeek
IndiabasedUnixAdmin,Cloud
EvangelistandaVirtualization
lover.Readmoreaboutmehere...
Twitter Facebook Google+

GETYOURFREEE
BOOK
DownloadtheFREEebookThe
CompleteOracleHardware
reference

Enteryouremail

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/ 4/5
4/6/2016 ExamplesofaddingstaticroutesinSolaris

SUBSCRIBE

ARCHIVES CONTACTUS COPYRIGHT

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/ 5/5

You might also like