Sei sulla pagina 1di 7

6/17/2016

ExamplesofaddingstaticroutesinSolaris

THE GEEK DIARY

SOLARIS

VXVM

VCS

LINUX

INTERVIEW QUESTIONS

ORACLE

Examples of adding static routes in Solaris


BySandeep 4Comments
Adsby Google

UnixSolaris

Solaris10

LinuxVSSolaris

192.1681.1

Static Vs Dynamic routes


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

Using command line


Toaddanonpersistentroutewejustsimpleuserouteaddcommandwithouttheoptionp.Notethatthese
routesgetsflushedifyourebootthesystem.Beloware2examplesofaddingaroute(192.168.1.1)forthe
network10.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/7

6/17/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):

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/

2/7

6/17/2016

ExamplesofaddingstaticroutesinSolaris

#routepdelete10.10.10.0/24192.168.1.1

Using rc script
Theabovecommandlinemethodwillnotworkinsolaris8and9,alsoinsomeolderpatchversionsof
solaris10.Toovercomethiswehaveanothermethod.Wecancreatearcscriptin/etc/rc2.d,saywithname
S91routes.Addtherouteaddcommandinthisscript:
#/usr/sbin/routeadd10.10.10.0netmask255.255.255.0192.168.1.1

Nowwhenthenexttimethesystembootsupthisscriptwouldrunandaddtheroutespecifiedinthescript.

Other examples
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`

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/

3/7

6/17/2016

ExamplesofaddingstaticroutesinSolaris

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
net192.168.1.0gateway192.168.1.1

Adsby Google

RouterLogin

RouterIPAddress

HTTP192.1680.1

RouterSetup

FiledUnder:Solaris

Related Posts
M4000/M5000:HowtoassignIPaddresstoXSCFU
Completehardwarereference:T1000/T2000/T5120/T5140/T5220/T5240/T5440
AbeginnersguidetoServiceManagementFacility(SMF)inSolaris
Solarisnetstat:Understandingtheoutputwhendisplayingroutingtable
SolarisZFS:Howtoimport2poolsthathavethesamenames

Comments
Leave a Reply
Youremailaddresswillnotbepublished.Requiredfieldsaremarked*
Comment

Name*

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/

4/7

6/17/2016

ExamplesofaddingstaticroutesinSolaris

Email*

Website

POST COMMENT

Rajasays
March4,2014at5:13AM
Niceworkbuddy,keepitcoming.
Reply

SandeepPatilsays
March4,2014at12:13PM
SureDude.Itsjustthebeginning.Moreandalotmoreyettocome.Staytuned:)
Reply

ManojRayatesays
May17,2014at5:31AM
Hi,
Wehavequery.
Whatisthelimitofaddingstaticrouteinsolaris10?
Wecanadd100or200staticrouteinsolaris10?
Pleasehelpus.
Thanksinadvance.
ManojRayate.

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/

5/7

6/17/2016

ExamplesofaddingstaticroutesinSolaris

Reply

SandeepPatilsays
May17,2014at5:43AM
Dontreallyknowaboutthelimit.ButImsureyoucanadd100/200routesinSolaris.Make
sureyouarenotduplicatingoraddingunnecessaryroutes.Asinglewiderroutecanreplace
10sofsmallerroutes.
Reply

Search this website

530

140

Fans

Followers

495

Subscribers

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/

279

Followers

6/7

6/17/2016

ExamplesofaddingstaticroutesinSolaris

Archives

http://thegeekdiary.com/examplesofaddingstaticroutesinsolaris/

Contact Us

Copyright

7/7

Potrebbero piacerti anche