Tải bản đầy đủ

OReilly windows XP hacks 100 industrial strength tips and tools aug 2003 ISBN 0596005113

Hack55ExtendtheRangeofYourWireless
Network

TheefficiencyandthroughputofWiFinetworkscanvary
dramatically.Makesureyougetmaximumthroughput
fromyourwirelessnetwork.
IfyouhavemorethanonePCathome,thebestwaytohook
themtogetherandshareahigh-speedInternetconnectionis
viaawirelessnetworkinparticular,onebasedontheWiFi
standard,whichisactuallyafamilyofstandardsknownunder
theumbrellatermof802.11x.
Thebiggestprobleminsettingupahomenetworkusually
involvesrunningthewiresbetweenPCsandaresidential
gateway.IfyourPCsareondifferentfloorsofthehouse,you
mayhavetodrillholesinyourwalls,ceiling,andfloorsandrun
wirethrough.EvenwhenPCsareonthesamefloor,youhaveto
dealwiththeproblemofwiressnakingalongthefloor.
That'stheproblemI'vehadinmy150-year-oldhomein
Cambridge.Drillthroughawall,ceiling,orfloorhere,andyou
neverknowwhatyou'llfind(horsehairinsulationwasonlyone
ofourmanysurprises).Evenmyelectricianshudderswhenhe

hastotakeoutthedrill.
So,forme,awirelessnetworkwasano-brainer.Inowhavegot
half-a-dozenPCsandlaptopsandthreeprintersinremoteparts
ofthehousefromeachother,allconnectedviaacombination
wired/wirelessnetworkandsharingasinglebroadbandInternet
connection.Andwhentheweatherisnicehere(twiceayear,by
mylastcalculation),Itakemylaptopoutonmybackporchand
workfromtherewhilestillconnectedtotheInternetandother


PCsandprintersinthehouse.
Butthere'sacatchwithallwirelessnetworks,includingmine.
Wirelessnetworksrarelydeliverdataattheirratedbandwidth
speed.Onefactoraffectingbandwidthspeedisthedistance
betweentheaccesspointandthewirelesslyequippedPC.
Compaq,forexample,notesthatatadistanceof150feetthe
throughputofitswirelessaccesspointdropsfrom11Mbpsto
5.5Mbps,andatadistanceof300feetitdropsto2Mbps.Even
thatsignificantlyunderstatesthedrop-offinspeed,andmost
peoplefindthatthedrop-offismuchmoredramaticthanthat,
mostcommonlybyafactoroftwo.


WiFiandBuyingNewEquipment
Thereareseveralversionsofthe802.11xWiFistandard,andunfortunately,they
don'tallworkwithoneanother.So,whenyou'rebuyingWiFiequipmentsuchas
hubs/routers,makesurethey'recompatible.The802.11bstandardwasthefirst
onetoberatified,isthemostcommontypeofWiFinetwork,anditsequipment
istheleastexpensive.(Thisisthestandardcommonlyusedbypublicwireless
"hotspots"incoffeeshops,airports,hotels,andotherlocations.)Itoperatesin
the2.4GHzpartofthespectrumanditsmaximumthroughputis11Mbps.
Increasinglypopular,though,isthe802.11gstandard,whichalsooperatesinthe
2.4GHzpartofthespectrumbuthasamuchhighermaximumthroughput:54
Mpbs.802.11bcardswillconnecttoa802.11gaccesspoint,butonlyata
maximumof11Mpbs.However,802.11gcardscan'tconnecttoan802.11b
accesspoint.Asofthiswriting,problemshavebeenreportedusing802.11b
hardwareonan802.11gnetwork,however.Therehavebeenreportsof
incompatibilitiesandofthe802.11bhardwareslowingtheentire802.11g
networkdowntoitsslowerspeed.However,that'sbecausethe802.11g
hardwarewasbuiltwhenthestandardwasonlyadraftandnotafinalstandard.
Thestandardhassincebeenfinalized,soifyoubuynewequipment,youshould
besafe.Bewaryofbuyingolder,usedequipment,though.

Distanceisonlyonefactoraffectingperformance.Interference
fromotherdevicesandtheexactlayoutofthehouseoroffice
canalsoaffectitdramatically.However,therearethingsyou
candotoextendtherangeofyournetworkandgetmore
throughputthroughoutyourhome:
Centrallylocateyourwirelessaccesspoint.Thisway,
it'smostlikelythatallofyourwirelesslyequippedPCswill
getreasonablethroughput.Ifyouputitinonecornerofthe
house,nearbyPCsmaygethighthroughput,but
throughputforothersmaydropsignificantly.
Orientyouraccesspoint'santennasvertically.Asa
generalrule,transmissionwillbebetterwhenantennasare
verticalratherthanhorizontal.Keepinmind,though,that
thisisonlyastartingpointforpositioningitsantenna.The
exactlayoutofyourhousemayalterthebestpositioningof


theantenna.
PointtheantennasofyourwirelessPCstowardthe
accesspoint.Although802.11technologydoesnotrequire
adirectlineofsight,pointingtheminthiswaytendsto
increasesignalstrength.USBwirelesscardsgenerallyhave
smallantennasthatcanbepositioned,butfrequently
wirelessPCcardsdon't,soyoumayhavetroublefiguring
outtheantennaorientationinawirelessPCcard.Ifyou
haveawirelessPCcardthatdoesn'thavewhatappearsto
beanantenna,theantennaisgenerallylocatedatthe
peripheryofthecarditself,sopointthatattheaccess
point.
Don'tplaceyouraccesspointnexttoanoutsidewall.
Ifyoudothat,you'llbebroadcastingsignalstotheoutside,
nottheinside,ofthehouse.That'sniceifyouwanttogive
yourneighborsaccesstoyournetwork,butnotgreatifyou
wanttoreachallthePCsinyourhouse.
AvoidputtingyouraccesspointorPCsnear
microwaveovensorcordlessphones.Manymicrowave
ovensandcordlessphonesoperateinthesame2.4GHz
partofthespectrumas802.11bWiFiequipment.So,
microwaveovensandcordlessphonescancausesignificant
interference.Cordlessphonestendtobethebigger
problem.
AvoidplacingtheantennasofaccesspointsorPCs
nearfilingcabinetsandotherlargemetalobjects.
Theycanbothcausesignificantinterferenceand
dramaticallyreducethroughput.
Considerusingexternalandboosterantennas.Some
PCcards,notablyOrinococards,willacceptexternal
antennasthatyoucanbuyorbuildonyourown.Theyhave


asmallconnectortowhichyouattachapigtailandwireand
thenattachthatwiretoanantenna.(Forinformationabout
buildingyourownantenna,see[Hack#42]).Someaccess
pointsoftenacceptboosterantennasthatyoucanbuyas
well.

IfyouhaveaLinksyswirelessnetworkandarelookingtoimprove
itssignalstrength,youcanbuya$99add-inthatpromisesto
extenditsrangeandstrengthenitssignal.TheWSB24Wireless
SignalBoostersitsontopofyourexistingwirelessrouter.Youtake
theantennasoffyourrouter,attachthemtothebooster,then
attachtheboostertotherouterviacables.Ihaven'ttriedit
myself,soIcan'tpersonallyvouchforit,butthosewhohavetried
claimitworks.

Tryandtryagain.Theultimatewaytofindthebest
placementforyouraccesspointandwirelessPCsisto
continuouslyexperimentandseewhatkindofthroughput
youget.Eachhouseandofficeissodifferentthatnosingle
configurationcansuitthemall.
Carefullymonitoryourthroughputasyoumakethesechanges,
sothatyoudeterminethebestpositioningforyouraccesspoint
andPCs.Todetermineyourtruethroughput,usethefree
networkanalysisprogramQCheck[Hack#57].

5.15.1SeeAlso
[Hack#42]
[Hack#57]


Hack42WarDrivingforWiFiAccess

WiFinetworksareeverywhere,itseems;youcangetfree
InternetaccessonwirelesscommunityFreeNetsarmed
withyourlaptop,acar,andsoftwarecalledNetwork
Stumbler.
Oneofthecoolesttechnologicaladvancesinpopularusetoday
isthewirelessnetwork.WirelessnetworksbasedontheWiFi
standard(802.11x)arebecomingincreasinglycommonacross
thecountrynotonlyinpeople'shomes,butalsoinuniversities,
corporations,coffeeshops,airportsandotherpublicplaces.
NowyoucanbringyouremailtoStarbucks.
Therearefrequentlydozensnearoneanother,particularlyin
certainurbanneighborhoodsandsuburbanofficeparksthat
househigh-techcompanies.WhereIliveinPorterSquarein
Cambridge,Massachusettstherearedozensofwireless
networksinprivatehomes,apartmentbuildings,andbusinesses
withinaveryshortwalkfrommyhome.Thereareatleasthalfa-dozenonmythree-blockstreetalone,inadditiontomine.
Frommybackporch,Igetaccesstomyownwirelessnetwork,
butcanalsooftenpickupsignalsfromfournearbyWiFi
networks.
ThewidespreadavailabilityoftheseinexpensiveWiFinetworks
hasledtoagrassrootscommunitywirelessnetworking
movement.Theideaissimple:allowpeoplepassingbytouse
yourWiFinetworktohopontotheInternetandtheyinturnlet
youandothersusetheirWiFinetworksforInternetaccess
whenyoupassneartheirhomesorplacesofbusiness.These
wirelessgrassrootsorganizationsareoftencalledFreeNets.
You'llfindthemincitiesincludingNewYork,Seattle,Houston,


andtheSanFranciscoBayarea,aswellasothers.Formore
detailsaboutthemandhowtoparticipate,gotoFree
Networks.org(http://www.freenetworks.org)Infact,some
citiesthemselvesarecreatingfreewirelesszonesindowntown
businessareastoallowanyonewithawireless-enabled
computertogetInternetaccess.Paris,forexample,maysoon
beknownformorethanitsbeauty,culture,goodfoodand
disdainfortourists;itmayturnintoonegiantwirelesszone,
allowingInternetaccessanywhereinthecity,thoughfora
price.
Howdoyoufindthesewirelessnetworks?Thebestwayisby
doingwhathasbecomeknownaswardrivingdrivingthrough
neighborhoodswithyourlaptop,specialsoftware,and,ifyou
wanttopickupmorenetworks,anantennahookeduptoyour
WiFicard.

Theextremelyenvironmentallyconsciousprefertogowarwalking,
thoughwalkingaroundwithalaptopisnotparticularlyeasy.Abetter
wayiswithaWiFi-equippedPDA,likethePalmTungstenC.

Runthesoftware,anditnotonlylocatesthenetwork,butalso
providesavarietyofinformationaboutitthatyoucanuseto
connecttoit,suchasitsSSID(networkname),whetherituses
encryption,andthewirelesschannelit'son.Armedwiththat
information,youshouldbeabletoconnecttoitifit'sa
FreeNetforexample,ifitissettoallowanyonetoconnecttoit,
orifitusesacommonlyagreed-uponsecurityschemethat
everyoneintheFreeNetusesfortheirWiFinetworks.

Ifyouwalkincertainurbanneighborhoods,youmaynoticestrange
symbolsonthesidewalkthatlooksomethinglikethosepicturedin
Figure5-1.Yes,it'saconspiracy,butinthepositivesense.Theseare
warchalkingsymbolsthattellpassersbythatthereisanearbyWiFi
network.Theleftsymbolmeansthewirelessnetworkisopen;the
middleonemeansitisclosed;andtherightonemeansitusesWEP
encryption.Theremaybeotherinformationnexttothesymbolthat


givesinformationonhowtoconnecttothenetwork,suchastheSSID.
Thesymbolswereinspiredbythepracticeofhoboes,whoduringthe
GreatDepressionwouldmakechalkmarksnearhomesthatwere
friendlytohoboesandwouldgivethemfood.Formoreinformation
aboutwarchalking,gotohttp://www.warchalking.org.

Figure5-1.Warchalkingsymbols

Togowardriving,downloadthefreeNetworkStumbler
program(http://www.netstumbler.com),whichshowsyou
detailedinformationaboutanynearbywirelessnetwork.Figure
5-2showswhathappenswhenIrunthesoftwareonmyback
porch.IcandetectsignalsfromfournearbyWiFinetworksin
additiontomyown.

Figure5-2.Detectingnearbywirelessnetworks
withNetworkStumbler

ForeachWiFinetworkituncovers,NetworkStumblertellsyou


thenetwork'sSSID,name,manufacturer,channel,type,signal
strength,signal-to-noiseratio,andwhetherthenetwork's
encryptionisenabled,amongotherdetails.Armedwiththat
information,youcantrytoconnecttothenetwork.

Ifanetworkusesencryption,asmalllockappearsnexttoit;look
closelyattheMookievillenetworkinFigure5-2andyoumightbeable
toseeit.

Onceyou'vefoundanetwork,exitNetworkStumbler.Then,to
connecttothenetwork,double-clickonthesmallnetworkicon
intheSystemTray(officiallyknownastheXPNotification
AreatheareaoftheTaskbarwhereXPcorralslittleicons).The
WirelessNetworkConnectionStatusscreenappears.(Tosee
whatitlookslike,flipaheadtoFigure5-26.)Fromthisscreen,
chooseProperties WirelessNetworks,andyou'llseethe
screenshowninFigure5-3.

Figure5-3.TheWirelessNetworkConnection
Propertiesscreen


Ifthisscreendoesn'tshowyouthenetworkuncoveredby
NetworkStumbler,clickRefresh.Ifthenetworkstilldoesn't
showup,that'sbecausethesignalistooweakforyouto
connecttoit.Toconnecttoanetworkshownonthisscreen,
clickConfigureandfillouttheinformationrequiredinthe
screen.You'llthengetintothenetwork.
NoteveryonewillbeabletouseNetworkStumbler,becauseit
won'tworkwithallwirelessnetworkcards.Asofthiswriting,it
workedwiththefollowingcards(andpossiblysomeothersnot
listedhereaswell):LucentTechnologiesWaveLAN/IEEE(Agere
ORiNOCO);DellTrueMobile1150Series(PCMCIAandminiPCI);AvayaWirelessPCCard;ToshibaWirelessLANCard
(PCMCIAandbuilt-in);CompaqWL110;Cabletron/Enterasys
Roamabout;ElsaAirlancerMC-11;ARtemComCard11Mbps;
IBMHighRateWirelessLANPCCard;and1stWave1ST-PCDSS11IS,DSS11IG,DSS11ES,andDSS11EG.Formore
information,gotoC:\ProgramFiles\Network
Stumbler\readme.html,assumingyou'veinstalledtheprogram
inC:\ProgramFiles\NetworkStumbler.


NetworkStumblerwillfindallwirelessnetworksnearyou,not
justthosethatarepartofFreeNets.So,youmaywellfindthe
wirelessnetworksofpeoplewhodon'trealizethatothers
outsideoftheirhomesorbusinessescantapintotheirnetwork.
Somelawenforcementofficialswilltellyouthattappinginto
thosepeople'snetworksisillegal,sobeforewarned.

5.2.1MappingWirelessNetworks
NetworkStumblerletsyousaveyourwar-drivinginformationin
afile,andyoucanthenuploadthatinformationtoawebsite
(suchashttp://wifimaps.com)thatusesyourinformationand
informationprovidedbymanyotherwar-driverstocreatemaps
ofWiFinetworksacrossthecountry.Youcanzoominandout
onthesemaps,soyoucangetaviewoftheconcentrationof
WiFinetworksinametropolitanarea,oryoucanseeindividual
WiFinetworksonindividualstreets,asshowninFigure5-4.

Figure5-4.AmapshowingWiFinetworksinmy
Somervilleneighborhood


Gotohttp://wifimaps.comtoviewthemapsortouploadyour
NetworkStumblerinformation.Beawarethatthesiteisa
volunteereffort,and,notuncommonly,you'llfindthatthemaps
aren'tworking.Ifthathappens,checkbackagaininafewdays;
itusuallygetsupandrunningafterawhile.

5.2.2BuildaHomemadeWirelessCantennafor
WarDriving
Onewaytoincreasetherangeofyourwardrivingandthe
strengthofthesignalwhenyouconnecttoWiFinetworksisto
buildyourownwirelessantenna.Youcanbuildthemforafew
dollarsusingatincanandotherstrayparts,aslongasyou're
willingtodoalittlebitofsoldering.Becausethey'rebuiltoutof
tincans,they'refrequentlycalledcantennas.
My13-year-oldsonGabebuiltseveralforhisseventh-grade
sciencefairprojectandcomparedtheeffectivenessofeach.The
resultswereclear:thegiant34.5-ouncecoffeecanswerefar
superiortonormal-sizedcoffeecansandPringle'scans.
Ifyouhaven'tboughtaWiFicardyetandareconsidering
buildingoneofthesecantennas,IsuggestbuyinganOrinoco
card.Ithasasmallconnectorinitssidethroughwhichyou
connectapigtailconnector,whichcanthenbehookeduptoa
smallantennayoubuildoutofcopperwireandasmall
connector,whichgoesinsidethetincan.Thereareanumberof
placesyoucanbuyapigtailandtherequiredconnectors,
includingHyperlinkTechnologies
(http://www.hyperlinktech.com).Ifyoudon'thaveaWiFicard
withasmallconnector,buildingoneofthesecantennas
becomesmuchmoredifficult.
Therearemanyplacesonlinewhereyoucanfindgood
directionsformakingcantennas.Threegoodplacestostartare
www.oreillynet.com/cs/weblog/view/wlg/448,


www.netscum.com/~clapp/wireless.html,and
www.turnpoint.net/wireless/cantennahowto.html.Justsoyou
gettheideaofwhatyou'lldo,though,youfirstemptyandwash
thecan.Next,youbuildthesmallantennathatwillgoinside
thecoffeecanbysolderingashortpieceofthickcopperwireto
asmallpieceofhardwarecalledanNconnector.Then,drilla
holeinthecanandinsertthesmallantennayoujustsoldered.
Attachtheantennatothecanbysecuringitwithsmallscrews
andbolts.Attachoneendofthepigtailtoyourwirelesscard,
attachtheotherendtotheNconnector,andvoila!Youhavea
cantenna.

5.2.3SeeAlso
[Hack#57]
[Hack#53]


Hack57CheckWiFiNetworkPerformancewith
QChecktoHelpImproveThroughput

XPcan'ttellyouthetruethroughputoryourwiredor
wirelessnetwork.Forthat,you'llneedfree,third-party
softwarethatcanhelpyouimprovethroughput.
Whenyoubuynetworkhardware,includingahub/routerand
networkcards,you'retoldthathardware'sratedspeedfor
example,100MbpsforanEthernetnetwork,or11Mpbsfora
an802.11bWiFinetwork.
Butthosenumbersonlytellyouhowyournetworkmayperform
inidealconditions;asthesayinggoes,"yourmileagemay
vary,"andusuallydoes.WiFinetworksareparticularlyfinicky
andareespeciallypronetobeingaffectedbyinterferenceand
otherfactors.Whereyouplaceyourwirelessaccesspointand
PCsandhowyoupositiontheirantennas[Hack#55]canmake
adramaticdifferenceintheactualspeedofyournetwork.So,
you'llwanttoknowthetrueconnectionspeedofyournetwork,
WiFinetworksinparticular,sothatyoucanoptimizetheir
performancewhenyoutroubleshootthem.
Buthowcanyoufindoutyourtruenetworkperformance?If
youhaveaWiFicard,youcanfindinformationaboutyour
connectionbydouble-clickingonthesmallnetworkiconinthe
NotificationArea(alsocalledthesystemtray).Whenyoudo
that,theWirelessNetworkConnectionStatusscreenappears,
asshowninFigure5-26.

Figure5-26.TheWirelessNetworkConnection
Statusscreen


There'sonlyoneproblemwiththatscreen:it'shighly
inaccurate.True,itslittlegreenbarsandSignalStrength
indicationgiveyouabroadpictureoftherelativestrengthof
yournetworkconnection.ButtheSpeedindicationisn'tan
actualmeasurementasfarasIcantell;itappearstotellyou
onlyyourmaximumtheoreticalconnectionspeed,giventhe
natureofyourhardware,anddoesn'treflectyourtruecurrent
connectionspeed.WhenIusemyWiFinetwork,italwaystells
methespeedis11Mbps,evenwhenactual,real-time
measurementshowsmytruethroughputislessthanhalfof
that.
So,howdoyoumeasurethetruespeedofanetworkinyour
real-worldconditions?GetNetIQ'sfreeQCheck
(http://www.netiq.com/qcheck/).Itperformsaseriesoftests,
includingthroughputandresponsetime,andgivesyouagood
snapshotofyournetwork'srealperformance.Whentryingto
optimizeaWiFinetwork,runQCheckoneachPConthe
networktogetbaselineperformanceresultsforeach.Thenrun
thetestforeachPCafteryoumovethebasestationandPCs,
changethepositioningoftheantennas,andsoforth,as
outlinedin[Hack#55].Thatway,you'llbeabletofine-tune
yournetworkforoptimumefficiency.
Onceinstalledoneverymachineinyournetwork,QCheck


measurestheperformanceofthenetworkbetweenanytwoof
yourPCs.QCheckismadeupoftwocomponents:theconsole
whereyourunyourtests,showninFigure5-27,andan
endpoint,whichrunsinvisiblyinthebackgroundoneachPCon
whichyou'veinstalledQCheck.Whiletheexactmetricsvary
fromtesttotest,theprogramworksbysendingdatafromone
PCtoanotheronyournetwork.Thedataisthensentfromthe
receivingPCbacktotheoriginatingPC,andQCheckmeasures
theround-triptime,calculatesthroughput,anddisplaysthe
results.

Figure5-27.TheQCheckconsole

NotethethroughputinFigure5-27;it's5.128Mbps.Iwas
measuringthespeedofmyWiFinetworkwhieseatedonmy
backyardporch,whichisabout30feetandawallawayfrom


myaccesspoint.Justtoshowyouhowmuchmoreaccurate
QCheckis,theWirelessNetworkConnectionStatusscreen
reportedmyspeedas11Mbpstheexactconnectionspeedmy
laptopwouldhaveifIwereinchesawayfromthewireless
accesspoint.(Andinactuality,theconnectionspeedofaWiFi
network,evenwhendevicesarenexttooneanother,iswell
under11Mbps.)
ToruntheQChecktests,runtheconsoleandthenchoosethe
twoPCsbetweenwhichyouwanttomeasurespeedonyour
network.OnlyonemustbethePCwiththeconsoleonit,but
eachPCdoeshavetohaveQCheckonit.Youdon'tneedtorun
theconsoleoneachmachine,becausetheendpointsare
runningontheminvisiblyinthebackground;duringQCheck's
installationtheendpointslaunchonstartup.
You'llneedtoknowtheIPaddressesofthePCsyouwantto
test.IfoneofthePCsyou'retestingistheonerunningthe
console,chooselocalhostforthatendpoint.TofindtheIP
addressofotherPCsonyournetwork,firstgotothatPC,rightclickonMyNetworkplaces,thendouble-clickonyournetwork
connection(itmightreadLocalAreaConnection,forexample,
orWirelessNetworkConnection).ClickontheSupporttab,and
you'llseeyourIPaddress.
OnceyouchoosethePCsyouwanttotest,choosethespecific
testtorun.ThebestoverallbenchmarkwillbetheThroughput
testusingeithertheTCPorUDPprotocols.Ifyouhappentouse
IPXorSPXonyournetwork(somepeoplestillusetheseolder
protocolsratherthanTCP/IP),youcandobenchmark
throughputtestsusingthemaswell,thoughfewhome
networksusethoseprotocols.Ifyourunanykindofstreaming
mediaacrossyournetworkforexample,ifyouwillbeusingyour
networktoplayMP3filesorotherdigitalmusiconaPCand
thenstreamittoanotherlocationinyourhousechoosetheUDP
streamingtest.StreamingmediausetheUDPprotocol,sothe
onlywaytotesthowtheywillperformonyournetworkisto
usethetestforthatprotocol.


Makesuretorunyourtestmultipletimes,and,tobesafe,run
themahalf-hourormoreapart.Becauseoftheficklenatureof
wirelesstransmissions,youcanfinddramaticdifferencesin
throughputfromonemomenttothenext.Forexample,afew
minutesafterrunningthethroughputtestshowninFigure5-27,
Iranitagainandwasshownathroughputof1.602Mbps.That
onetestwasananomaly,andothertestsweremoreinkeeping
withmyinitialones.

5.17.1SeeAlso
[Hack#42]


Hack53TroubleshootingNetworkConnections
withnetsh,netstat,andipconfig

Morecommand-linetoolsfortrackingdownproblems
withyournetworkconnection.
Inadditiontowell-knowncommand-linenetworkutilitiessuch
asping,tracert,andpathping,thereareseveralotherallpurposeutilitiesthatcanhelpyoutroubleshootnetwork
connections:netsh,netstat,andipconfig.

5.13.1UsenetshtoTroubleshootNetworkand
InternetConnections
netshisawide-rangingcommand-linediagnostictoolthathas
anexceedinglylargenumberofcommandsavailable.(Fora
completelistofavailablecommands,useWindowsXPHelpand
Supportandsearchfornetsh.)Hereyou'lllearnthemost
interesting.
Perhapsthemostusefulofthenetshcommandsarethenetsh
diagcommands.Usethemtofindoutinformationaboutyour
PC'snetworksetup,suchasfindingtheIPaddressofitsmail
server,newsgroupserver,DNSserver,andsimilarresources.
Therearetwowaystousenetsh:directlyfromthecommand
linewithallitsswitches,orfirstgettingtothenetshconsoleby
typingnetshatthecommandlineandthentypingthe
commandfromthenetsh>promptthatappears.Forexample,
youcouldtypenetshdiagshowadapteratthecommand
line,whichlistseverynetworkadapteronyourPC,oryoucould


gettothenetsh>promptandtypediagshowadapter.
Usethenetshcommandtoconnecttotheresourcesandthen
getinformationaboutthem.Forexample,tofindouttheIP
addressofyourDNSservers,typenetshdiagshowdns;to
findouttheIPaddressofyourmailserver,typenetshdiag
connectmail.
Table5-7listthemostusefulofthenetshdiagcommands.
Precedeeachofthemwithnetshdiag.Notethattheyeach
havemanyswitchesassociatedwiththem.Formoredetails,
useWindowsXPHelpandSupportandsearchfornetsh.
Table5-7.Usefulnetshdiagcommands
Command

Whatitdoes

connect
ieproxy

EstablishesaconnectiontoInternetExplorer'sproxyserver,ifoneexists.

connect
mail

EstablishesaconnectiontothedefaultOutlookExpressmailserver.

connect
news

EstablishesaconnectiontothedefaultOutlookExpressnewsgroupserver.

ping
adapter

Establishesaconnectionwiththenamedadapter.

pingdhcp EstablishesaconnectionwithaDHCPserver.
show
adapter

ListsalltheadaptersonthePC.

showall

ListsallthenetworkobjectsdefinedforthelocalPC,suchasadapters,network
clients,servers,modems,andotherobjects.

showdhcp ListsalltheDHCPserversforthespecifiedadapter.
showdns

ListsalltheDNSserversforthespecifiedadapter.


show
gateway

Listsallthegatewaysforthespecifiedadapter.

5.13.2UsenetstattoGetInformationAbout
OpenNetworkConnections
Ifyouwanttogetasnapshotofallincomingandoutgoing
networkconnections,usethenetstatcommand.Ata
commandprompt,typenetstat.Itlistsallconnections,
includingtheprotocolbeingused,thelocalandInternet
addresses,andthecurrentstateoftheconnection,likethis:

ActiveConnections
ProtoLocalAddressForeignAddressState
TCPPrestonGralla:1031localhost:2929ESTABLISHED
TCPPrestonGralla:2887192.168.1.103:netbios-ssnTIME_WAIT
TCPPrestonGralla:2899www.oreillynet.com:httpESTABLISHED
TCPPrestonGralla:2900www.oreillynet.com:httpESTABLISHED
TCPPrestonGralla:2932mail.attbi.com:pop3ESTABLISHED
TCPPrestonGralla:2936vmms2.verisignmail.com:pop3ESTABLI
Itwillhelpyouknowwhetherconnectionsarelive,thenetwork
orInternetdevicetowhichthey'reconnected,andwhichlocal
resourceismakingtheconnection.It'sbestsuitedforwhen
you'retroubleshootingnetworkproblemsandwanttofindout
whethercertainportsareopen,whycertaincomputersonthe
networkarehavingconnectionproblems,andsimilarissues.
Youcanusecommand-lineswitcheswithnetstat.Forexample,
displayopenportsandopenconnectionswiththissyntax:
netstat-a.Table5-8listsnetstatswitches.
Table5-8.Netstatswitches
Switch

Whatitdoes


-a

Displaysallopenconnectionsandports.

-e

DisplaysEthernetstatisticsaboutpacketstransmittedandreceived.Can
becombinedwiththe-sswitch.

-n

Displaystheaddressesandportsinnumeric,IPaddressform.

-o

Displaystheprocessidentifier(PID)thatownseachconnection.

-pproto

Displaystheconnectionsusedbytheprotocol,whichcanbeIP,IPv6,
ICMP,ICMPv6,TCP,TCPv6,UDP,orUDPv6.

-r

Displaysthenetwork'sroutingtable.

-s

Displaysstatisticsforeachprotocol.Itlistsallstatisticsforallprotocols,
butyoucanlistonlythoseforaspecifiedprotocolifyoucombineitwith
the-pswitch.

intervalvalue

Runnetstatrepeatedly,pausingvaluesecondsbetweeneachnew
display.Tostopthedisplay,pressCtrl-C.

5.13.3UseIPConfigtoTroubleshootTCP/IP
Oneofthemostpowerfultoolsforanalyzingand
troubleshootingTCP/IPproblemsistheipconfigcommand-line
utility.Itprovidesinformationabouteachofyouradapters,
includingtheassignedIPaddress,subnetmask,default
gateway,MACaddress,DNSservers,whetherDHCPisenabled,
andavarietyofotherdata.Toseebasicinformationaboutyour
adapters,typeipconfigatacommandprompt,andyou'llsee
informationlikethis:

WindowsIPConfiguration
EthernetadapterLocalAreaConnection:
Connection-specificDNSSuffix.:ne1.client2.attbi.c
IPAddress............:192.168.1.100
SubnetMask...........:255.255.255.0


DefaultGateway.........:192.168.1.1
PPPadapter{6A724E76-AB59-4ABC-BBF5-41CA4410EB8D}:
Connection-specificDNSSuffix.:
IPAddress............:172.165.155.106
SubnetMask...........:255.255.255.255
DefaultGateway.........:
Asyoucansee,ipconfigprovidesbasicinformationaboutyour
IPaddress,subnetmask,defaultgateway,andaconnectionspecificDNSsuffix,ifany.However,youcangetmuchmore
detailedinformationbyusingthe/allswitch,likethis:
ipconfig/all.Formosttroubleshootingpurposes,usethe
/allswitch.Yougetamuchmorecomprehensivelisting,as
shownhere:

WindowsIPConfiguration
HostName............:PrestonGralla
PrimaryDnsSuffix.......:
NodeType............:Hybrid
IPRoutingEnabled........:No
WINSProxyEnabled........:No
EthernetadapterLocalAreaConnection:
Connection-specificDNSSuffix.:ne1.client2.attbi.c
Description...........:CNetPRO200WLPCIF
PhysicalAddress.........:00-08-A1-00-9F-32
DhcpEnabled...........:Yes
AutoconfigurationEnabled....:Yes
IPAddress............:192.168.1.100
SubnetMask...........:255.255.255.0
DefaultGateway.........:192.168.1.1
DHCPServer...........:192.168.1.1
DNSServers...........:204.127.202.19
216.148.227.79
LeaseObtained..........:Saturday,December
LeaseExpires..........:Sunday,December29
PPPadapter{6A724E76-AB59-4ABC-BBF5-41CA4410EB8D}:


Connection-specificDNSSuffix.:
Description...........:WAN(PPP/SLIP)Inte
PhysicalAddress.........:00-53-45-00-00-00
DhcpEnabled...........:No
IPAddress............:172.165.155.106
SubnetMask...........:255.255.255.255
DefaultGateway.........:
DNSServers...........:64.12.104.134
NetBIOSoverTcpip........:Disabled
YoucanalsouseipconfigtoreleaseandrenewIPaddresses,
andperformothertroubleshootingfunctionsaswell.For
example,torenewanadapter'sIPaddress,usethiscommand:
ipconfig/renew"adaptername"
whereadapternameisthenameoftheadapterwhoseIP
addressyouwanttorenew.Makesuretoputquotesaroundthe
adapternameandusespacesifthereismorethanonewordin
theadaptername.Table5-9listsotherswitchesyoucanuse
withipconfig.
Table5-9.Command-lineswitchesforipconfig
Switch

Whatitdoes

/all

DisplayscompleteTCP/IPconfigurationinformation.

/displaydns

DisplaysinformationfromtheDNSresolvercache
(formoreinformation[Hack#44]

/flushdns

ClearstheDNSresolvercache[Hack#44]

/registerdns

RefreshesallDHCPleasesandreregistersDNS
names.

/release"adapter"

ReleasedtheIPaddressforthespecifiedadapter.

/renew"adapter"

RenewstheIPaddressforthespecifiedadapter.


/setclassid"adapter"newclassid ResetstheDHCPClassIDforthespecifiedadapter.
/showclassid"adapter"

DisplaystheDHCPClassIDforthespecifiedadapter.


Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay

×

×