Anda di halaman 1dari 4

9/15/2015

How To Use Ip Command In Linux with Examples

HOME
LINUXHOWTO
LINUXCOMMANDS
UBUNTUHOWTO
SHELLSCRIPTS
EnterSearchTerms

search

LINUXCOMMANDS>HowToUseIpCommandInLinuxwithExamples
AdsbyGoogle IPAddress IPCheck

IPPort

FindIP

HowToUseIpCommandInLinuxwithExamples
May2,2014|By Bobbin Zachariah in LINUX COMMANDS , LINUX HOWTO More
The linux ip command is similar to ifconfig, but more powerful and is intended to be a replacement for it. With ip you have the advantage of
performing several network administration tasks with only one command. ifconfig is one of the deprecated command within nettools that has not
beenmaintainedformanyyears.Thefunctionalitiesofmanycommandsisretainedwithmorefeaturesunderiproute2suite.

http://linoxide.com/linux-command/use-ip-command-linux/

1/4

9/15/2015

How To Use Ip Command In Linux with Examples

Toinstallipdownloadtheiproute2suiteutilityhere,howevermostLinuxdistributionswillcomewiththeiproute2toolspreinstalled.
Youcanalsouseusegittodownloadthesourcecode:
$gitclonehttps://kernel.googlesource.com/pub/scm/linux/kernel/git/shemminger/iproute2.git

SettingandDeletinganIpAddress
TosetanIPaddressforyourcomputer,thecommandipcanbeusedasfollows:
$sudoipaddradd192.168.0.193/24devwlan0
NotethattheIPaddresshasaprefix,forexample/24.Thisisusedinclasslessinterdomainrouting(CIDR)toshowthesubnetmaskused.Inthis
casethesubnetmaskis255.255.255.0.
AfteryouhavesettheIPaddressconfirmwithshow,whetherthethechangeshavetakeneffect.
$ipaddrshowwlan0

YoucanalsousethesameproceduretodeleteanIPaddressbyjustreplacingaddwithdel.
$sudoipaddrdel192.168.0.193/24devwlan0

ShowRoutingTableEntry
Therouteobjectofipcommandalsohelpsyoutoseetheroutepacketswilltakeinyournetworkassetinyourroutingtable.Thefirstentryisthe
defaultroutewhichyoucanchangeasyouprefer.
Inthisexamplethereareseveralroutes.Thesearearesultofhavingaseveraldevicesconnectedthroughdifferentnetworkinterface.Theseinclude
WIFI,Ethernetandapointtopointlink.
$iprouteshow

SupposenowthatyouhaveanIPaddresswhichyouneedtoknowtheroutepacketswilltake.Youcanuserouteoptionasfollows:
$iprouteget10.42.0.47

ChangingTheDefaultRoute
Tochangethedefaultroute,theipcommandcanbeusedasfollows:
$sudoiprouteadddefaultvia192.168.0.196

ShowNetworkStatistics
Theipcommandcanalsobeusedtoshowthestatisticsofthevariousnetworkinterfaces.Todothisyoucanusetheipcommandwiththeoptions
andthenspecifythenetworkdevice.
$ipslink

Whenyouneedtogetinformationaboutaparticularnetworkinterface,addtheoptionlsfollowedbythenameofthenetworkinterface.Theoptions
whenusedmorethanoncegivesyoumoreinformationaboutthatparticularinterface.Thiscanbeveryusefulespeciallywhentroubleshootingerrors
innetworkconnectivity.
$ipsslinklsp2p1

ARPEntries
AddressResolutionProtocol(ARP)isusedtotranslateanIPaddresstoitscorrespondingphysicaladdress,commonlyknownasMACaddress.With
ipcommandyoucanviewtheMACaddressofthedevicesconnectedinyourLANbyusingtheoptionneighorneighbour.
$ipneighbour

MonitorNetlinkMessages
Itisalsopossibletoviewnetlinkmessageswithipcommand.Themonitoroptionallowsyoutoseethestateofyournetworkdevices.Forinstancea
computeronyourLANcouldbecategorizedasREACHABLEorSTALEdependingonitsstatus.Thecommandcanbeusedasfollows:
$ipmonitorall

http://linoxide.com/linux-command/use-ip-command-linux/

2/4

9/15/2015

How To Use Ip Command In Linux with Examples

ActivateandDeactivateNetworkInterface
Toactivateanparticularinterfaceyoucanusetheipcommandwithoptionsupanddown,almostsimilartohowifconfigisused.
In this example you can see the routing table entry when the ppp0 interface is activated and after it is deactivated and activated once again. The
interfacecanbewlan0oreth0.Changeppp0towhateverinterfaceisavailableinyourcase.
$sudoiplinksetppp0down
$sudoiplinksetppp0up

GettingHelp
Incaseyougetstuckanddonotknowhowaparticularoptionworksyoucanusethehelpoption.Themanpagedoesnotgivealotofinformationon
howtousetheipoptionsandthisiswherehelpcomestotherescue.
Forexample,toknowmoreabouttherouteoption:
$iproutehelp

TCPDelayedACK
FromRHEL7.1iproutepackageaddedsupportforTCPDelayedACK.Usebelowcommandtoenableit
iproutequickack

Conclusion
ThecommandipisamusthavetoolfornetworkadministratorsandallLinuxusersalike.Itistimetomovefromifconfig,especiallywhenyouare
writingscripts.

Youmightalsolike
LinuxwhocommandDisplayswhoisonthesystem
BestallOptionsforDNSlookupusingLinuxhostcommand
HowtouseLinuxNetcatCommandasPortScanner
HowtoInstallandConfigureuTorrenton7LinuxDistros
Linuxifconfig:HowToSetIpAddress/ConfigureInterface
APocketGuideforLinuxsshCommandwithExamples
HowtoDeployDeisusingHerokuBuildpacks
BuiltinAuditTrailToolLastCommandinLinux
LinuxUmask:PermissionSetWhenNewFile/FolderCreated
HowToDisplayAndSetHostnameinLinux
Like

Share

13,734peoplelikethis.SignUptoseewhatyourfriendslike.

Category:LINUXCOMMANDS,LINUXHOWTO
PREVIOUS ARTICLE

How to Create a Removeable Repository with AptonCD in Ubuntu


NEXT ARTICLE

How To Install Google Fonts In Ubuntu


Comments(9)
TrackbackURL|CommentsRSSFeed

1.

betazedsays:
May3,2014at6:03am
I'mcurious,canthetwobemixedsafely,forexamplewheremultiplepeoplearemaintainingasystem?
Reply

BobbinZachariahsays:
May3,2014at11:34am
AsfarasIknowitwillnotcreateanyissues!!!
Reply

2.

mesays:
May5,2014at3:34pm
Ioftenuseifconfigtocreatealiasinterface(whenIhavetoconfigurenewrouterwithfactorysetting,etc).Imisssimilarexampleusingip
command.Syntaxwithipconfigissimple:
ifconfigeth0:0192.168.0.2
IfoundthatIcandothatwithipcommandtoo,butitnotsimplecommand::(
ipaddradd192.168.0.2/24brd192.168.0.255deveth0labeleth0:0
Reply

ralasays:
December15,2014at6:55pm
useipaliascommand
Reply

3.

Mikesays:
May5,2014at10:36pm
Goodarticle.Thecheatsheetatthetopisreallyhelpful!Though,youdon'thavetoadd'show'foriprouteandipaddr.
Reply

4.

MichaelO'Donnellsays:
May14,2014at10:11pm
Hasitoccurredtoyouthatwhenyouwriteanarticlelikethisone(thatisn'tfullofcontentfreefluff)yourreadersmightwanttosavethe
informationitpresentsforlaterreference?AsonesuchreaderItypicallykeepacribsheetwithusefulexamplesthatI'vecut'n'pastedfrom
varioussources.Buthereyouare,perverselyusingPNGimagestopresent(someofthe)infoinanarticleaboutinherentlytextualcommand
linetools,therebymakingitdifficultforustopreservetheinfoinquestion.>/
Goodwork,nevertheless...
Reply

5.

Jetdillosays:
October29,2014at6:43pm
Thanksfortheinfo,thisisagoodwalkthroughofiproute,butI'mnotsure(orconvinced)ofwhyifconfigisnowconsideredharmful.
Imean,okay,woohooprogress,butasyourtableshows,youneedtwodifferentcommandstodowhatnetstatdoesbyitself.Youalsostillneed
tousecommandlikeiw(1)toconfiguretheunderlyingpropertiesofWLANdevices,theBlueZsuiteforbluetoothdevices,etc.
Removingnettoolsasapackageiscertainlyonewaytoforceuserstouseiproute,butIremainunconvincedthatit'sactuallymaterially
*better*.
Reply

6.

Mikesays:
November24,2014at6:56am
IPcommandisterriblelesspowerful,lessconfigurable,andexhibitsthetypicaldevelopermegalomania.
Reply

7.

Teleboriansays:
July17,2015at2:46pm
I'msearchingasolutiontocreatetemporaryhostnamestospecifigIPAdresswithoutmodifythe/etc/hosts
http://test>{IPAdress}
AnyoneanIdea?
Reply

LeaveaReply

http://linoxide.com/linux-command/use-ip-command-linux/

3/4

9/15/2015

How To Use Ip Command In Linux with Examples


Name(required)
Email(requiredwillnotbepublished)
Website

CommentingPolicy:
Promotionofyourproducts?Commentgetsdeleted.
Allcommentsaresubjecttomoderation.
WhichOSuselinuxkernel,windowsorredhat

SubmitComment

GETARTICLESBYEMAIL
Join10000+LinuxFans

SUBSCRIBE

EnterYourEmail*

PopularPosts
LinuxCommandsCheatSheetinBlack&White
Colourful!systemdvssysVinitLinuxCheatsheet
LinuxntopngNetworkMonitoringToolInstallation(Screenshots)
IntrotoConfigureIPsecVPN(GatewaytoGateway)usingStrongswan
ShellScripttoCheckLinuxSystemHealth
HowtoInstallGNOME3.16OnUbuntu,MintandArchLinux
HowtoInstallCentOS7StepbyStepwithScreenshots
HowtoInstall/SetuprtorrentandrutorrentinCentOS/Ubuntu
InstallVivaldiinLinuxAwesomeMultiPlatformBrowser
HowToUseIpCommandInLinuxwithExamples
HowToScan/DetectNewLunsInRedhatLinux&OutputsToRemember
HowtoInstallandConfigureNagios4.0.7onCentOS7.0
HowtoChangeHostnameinRHEL/CentOS7.0
HowtoInstallApacheSVN(Subversion)onCentOS7.x/RHEL7.x
Unbelievable!30LinuxTOPCommandExamplesWithScreenshots
LinOxide Linux Trends
Seguir

+1

+ 4.125

ABOUT

Aboutus
ContactUs
Privacy
Terms
CATEGORIES

Monitoring
Firewall
OpensourceTools
FollowLinoxide
WebServers
GETARTICLESBYEMAIL
Join10000+LinuxFans
2015LinOxide.Allrightsreserved.PrivacyTermsofService

EnterYourEmail*

SUBSCRIBE

http://linoxide.com/linux-command/use-ip-command-linux/

4/4

Anda mungkin juga menyukai