Linux Tutorial Networking
Linux Tutorial Networking
TutorialContents:
l l
OtherYoLinuxNetworkingTutorials:
l
l l l l l l l l l
l l
l l l l
l l
l l l
#Configurationfiles #RedHatLinuxnetworkGUI configurationtools. #AssigninganIPaddress #ActivatingandDeActivatingyourNIC #Subnets #EnableForwarding #Addinganetworkinterfacecard(NIC) #Route #VPN,Tunneling #UsefullLinuxnetworkingcommands #inetd/xinetd:NetworkSocket ListenerDaemons #rwhod:RemoteWhoDaemon #RPC:RemoteProcedureCall. (portmapper) #PAM:NetworkWrappers. #ICMPprotocol. #NetworkMonitoringTools #IDS:IntruderDetectionSystem SNORT #ARP:AddressResolutionProtocol #ConfiguringLinuxForNetwork Multicast #LivinginaMS/Windowsworld #NetworkDefinitions #RelatedLinks
l l
l l l l
Settingupaninternetgatewayforhomeoroffice usingiptables LoadbalancingserversusingLVS(LinuxVirtual Server) Modemdialup: ConfiguringPPPdialupconnectionstoan ISP DialingCompuserve DialingAOL ConfiguringPPPdialinconnections DNSNameserverconfiguration DHCPserverconfiguration:DynamicHost ConfigurationProtocol NISauthenticationconfiguration:ServerandClient Internet/NetworkSecurity SecurityToolsandHackerTools YoLinuxTutorialsIndex
TCP/IPNetworkConfigurationFiles:
l
File: /etc/resolv.confhostnameresolverconfigurationfile
search nameofdomain.comNameofyourdomainorISP'sdomainifusingtheirnameserver nameserver XXX.XXX.XXX.XXXIPaddressofprimarynameserver nameserver XXX.XXX.XXX.XXXIPaddressofsecondarynameserver
Notewhenaddinghoststothisfile,placethefullyqualifiednamefirst.(Ithelpssendmailidentifyyourservercorrectly)i.e.:
XXX.XXX.XXX.XXXsuperserver.yolinux.comsuperserver
ThisinformsLinuxoflocalsystemsonthenetworkwhicharenothandledbytheDNSserver.(orforallsystemsinyourLAN ifyouarenotusingDNSorNIS)
/usr/sbin/systemconfignetwork
File: /etc/nsswitch.confSystemDatabasesandNameServiceSwitchconfigurationfile
hosts:filesdnsnisplusnis
ThisexampletellsLinuxtofirstresolveahostnamebylookingatthelocalhostsfile( /etc/hosts ),thenifthenameisnot foundlooktoyourDNSserverasdefinedby /etc/resolv.conf andifnotfoundtherelooktoyourNISserver. Inthepastthisfilehashadthefollowingnames:/etc/nsswitch.conf,/etc/svc.conf,/etc/netsvc.conf,...dependingonthe distribution. FreeInformation Technology Magazine Subscriptions andDocument Downloads
Fedora/RedHatNetworkConfigurationFiles:
l
/etc/sysconfig/network RedHatnetworkconfigurationfileusedbythesystemduringthebootprocess.
ExamplestatementforIntelethernetcard:
Modulesforotherdevicesonthesystemwillalsobelisted.Thistellsthekernelwhichdevicedrivertouseifconfiguredasa loadablemodule.(defaultforRedHat)
Fedora/RedHatNetworkGUIConfigurationTools:
ThefollowingGUItoolseditthesystemconfigurationfiles.ThereisnodifferenceintheconfigurationdevelopedwiththeGUItools andthatdevelopedbyeditingsystemconfigurationfilesdirectly. TCP/IPethernetconfiguration:
l
Networkconfiguration:
/usr/sbin/systemconfignetwork (FC2/3)GUIshownhere> /usr/bin/redhatconfignetwork (/usr/bin/neat)(RH7.2+FC1)
Textconsoleconfigurationtool:
/usr/sbin/systemconfignetworktui (TextUserInterface(TUI)forFedoraCore2/3) /usr/bin/redhatconfignetworktui (RH9.0FC1)
GnomeDesktop:
l
AssigninganIPaddress:
ComputersmaybeassigedastaticIPaddressorassignedonedynamically.
StaticIPaddressassignment:
Chooseoneofthefollowingmethods:
CommandLine:
/sbin/ifconfigeth0192.168.10.12netmask255.255.255.0broadcast192.168.10.255
RedHat/FedoraConsoletools:
Directlyeditconfigurationfiles/scripts.Seeformatbelow.
TheifconfigcommanddoesNOTstorethisinformationpermanently.Uponrebootthisinformationislost.(Manuallyaddthe commandstotheendofthefile /etc/rc.d/rc.local toexecutethemuponboot.)Thecommandsnetcfgandnetconfigmake permanentchangestosystemnetworkconfigurationfileslocatedin /etc/sysconfig/networkscripts/ ,sothatthisinformation isretained. TheIANAhasallocatedIPaddressesintherangeof192.168.0.0to192.168.255.255forprivatenetworks. Helpfultools:
l l
NetworkCalculators:Subnetmaskcalculator,nodecalculator,maskinverter,... IPsubnetcalculator
Ubuntu/DebianIPConfigurationFiles:
File: /etc/network/interfaces StaticIPexample:
autolo ifaceloinetloopback autoeth0 ifaceeth0inetstatic address208.88.34.106 netmask255.255.255.248 broadcast208.88.34.111 network208.88.34.104 gateway208.88.34.110
DynamicIP(DHCP)example:
autolo ifaceloinetloopback autoeth0 ifaceeth0inetdhcp autoeth1 ifaceeth1inetdhcp autoeth2 ifaceeth2inetdhcp autoath0 ifaceath0inetdhcp autowlan0 ifacewlan0inetdhcp
RedHat/FedoraCoreIPConfigurationFiles:
TheRedHatconfigurationtoolsstoretheconfigurationinformationinthefile/etc/sysconfig/network . Theywillalsoallowonetoconfigureroutinginformation.
l
ORforDHCPclientconfiguration:
NETWORKING=yes HOSTNAME= myhostnameHostnameisdefinedhereandbycommandhostname
(GatewayisassignedbyDHCPserver.) ORforNISclientconfiguration:
NETWORKING=yes HOSTNAME= myhostnameHostnameisdefinedhereandbycommandhostname NISDOMAIN= NISProject1 NISdomaintoattach
RHEL4/FC3additions: l IPV6INIT=no l USERCTL=no l PEERDNS=yes l TYPE=Ethernet l HWADDR=XX:XX:XX:XX:XX:XX (Usedbyscript /etc/sysconfig/networkscripts/ifup tobringthevariousnetworkinterfacesonline) TodisableDHCPchange BOOTPROTO=dhcp toBOOTPROTO=none Inorderforupdatedinformationinanyofthesefilestotakeeffect,onemustissuethecommand: servicenetworkrestart (or: /etc/init.d/networkrestart )
Changingthehostname:
Thisisathreestepprocess: 1. Issuethecommand: hostnamenewhostname 2. Changenetworkconfigurationfile: /etc/sysconfig/network Editentry: HOSTNAME= newhostname 3. Restartsystemswhichreliedonthehostname(orreboot): Restartnetworkservices: servicenetworkrestart (or: /etc/init.d/networkrestart ) Restartdesktop: n Bringdownsystemtoconsolemode: init3 n BringupXWindows: init5 Onemayalsowanttocheckthefile /etc/hosts foranentryusingthesystemnamewhichallowsthesystemtobeselfaware. Thehostnamemaybechangedatruntimeusingthecommand: sysctlwkernel.hostname=" superserver "
Selectthe"DNS"tab. Selectthe"Devices"tab+"Edit"+the"General"tab.
NetworkIPaliasing:
AssignmorethanoneIPaddresstooneethernetcard:
ifconfigeth0 XXX.XXX.XXX.XXXnetmask255.255.255.0broadcast XXX.XXX.XXX.255 ifconfigeth0:0192.168.10.12netmask255.255.255.0broadcast192.168.10.255 ifconfigeth0:1192.168.10.14netmask255.255.255.0broadcast192.168.10.255 routeaddhost XXX.XXX.XXX.XXXdeveth0 routeaddhost192.168.10.12deveth0 routeaddhost192.168.10.14deveth0
Inthisexample0and1arealiasesinadditiontotheregulareth0.Theresultoftheifconfigcommand:
eth0Linkencap:EthernetHWaddr00:10:4C:25:7A:3F inetaddr:XXX.XXX.XXX.XXXBcast:XXX.XXX.XXX.255Mask:255.255.255.0 UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
RXpackets:14218errors:0dropped:0overruns:0frame:0 TXpackets:1362errors:0dropped:0overruns:0carrier:0 collisions:1txqueuelen:100 Interrupt:5Baseaddress:0xe400 eth0:0Linkencap:EthernetHWaddr00:10:4C:25:7A:3F inetaddr:192.168.10.12Bcast:192.168.10.255Mask:255.255.255.0 UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1 Interrupt:5Baseaddress:0xe400 eth0:1Linkencap:EthernetHWaddr00:10:4C:25:7A:3F inetaddr:192.168.10.14Bcast:192.168.10.255Mask:255.255.255.0 UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1 Interrupt:5Baseaddress:0xe400
Configfile: /etc/sysconfig/networkscripts/ifcfgeth0:0
DEVICE=eth0:0 ONBOOT=yes BOOTPROTO=static BROADCAST=192.168.10.255 IPADDR=192.168.10.12 NETMASK=255.255.255.0 NETWORK=192.168.10.0 ONBOOT=yes
DHCPLinuxClient:getconnectioninfo:/sbin/pumpieth0status (RedHatLinux7.1andolder)
Deviceeth0 IP:4.XXX.XXX.XXX Netmask:255.255.252.0 Broadcast:4.XXX.XXX.255 Network:4.XXX.XXX.0 Bootserver131.XXX.XXX.4 Nextserver0.0.0.0 Gateway:4.XXX.XXX.1 Domain:vz.dsl.genuity.net Nameservers:4.XXX.XXX.14.XXX.XXX.24.XXX.XXX.3 Renewaltime:SatAug1108:28:552001 Expirationtime:SatAug1111:28:552001
ActivatingandDeActivatingyourNIC:
CommandsforstartingandstoppingTCP/IPnetwork servicesonaninterface:
l
Start/Stopnetworkinterfaces
/usr/bin/systemcontrolnetwork (FedoraCore
2/3)
/usr/bin/redhatcontrolnetwork (RH9.0FC1)
l
Subnets:
M A S K
#OFSUB NETS
Slash Fmt
CLASSA HOSTS
CLASSB MASK
CLASS C HOSTS
CLASSC MASK
CLASSCSUB MASK
/32
16,777,214
255.0.0.0 65,534
255.255.0.0 254
255.255.255.0
Invalid 1address Invalid 2addresses 2hosts 4addresses 6hosts 8addresses 14hosts 16addresses 30hosts 32addresses 62hosts 64addresses
255.255.255.255
128 2
/25
255.255.255.128
Binaryposition 8 7 6 5 4321 Value 128 64 32 16 8 4 2 1 Example:192 1 1 0 0 0000 Example192=128+64 Someaddressesarereservedandoutsidethisscope.Loopback(127.0.0.1),reservedclassC192.168.XXX.XXX,reserved classB172.31.XXX.XXXandreservedclassA10.XXX.XXX.XXX. SubnetExample: YourISPassignsyouasubnetmaskof255.255.255.248foryouroffice. l 208.88.34.104NetworkBaseaddress l 208.88.34.105Computer1 l 208.88.34.106Computer2 l 208.88.34.107Computer3 l 208.88.34.108Computer4 l 208.88.34.109Computer5 l 208.88.34.110DSLrouter/Gateway l 208.88.34.111Broadcastaddress Oftheeightaddresses,therearesixassignedtohardwaresystemsandultimatelyonlyfiveusableaddresses. Links:
l l l l l
NetworkClasses:
Theconceptofnetworkclassesisalittleobsoleteassubnetsarenowusedtodefinesmallernetworks.Thesesubnetsmaybe partofaclassA,B,C,etcnetwork.Forhistoricalreferencethenetworkclassesaredefinedasfollows:
l
ClassC:Definedbythefirst8bitswitharangefrom192223 Firstthreenumbers(24bits)aredefinedbyInternici.e.220.56.222.XXX OneclassBnetworkcandefine254hosts. Range:192.0.0.0223.255.255.255 ClassD:Definedbythefirst8bitswitharangefrom224239 Thisisreservedformulticastnetworks(RFC988) Range:224.0.0.0239.255.255.255 ClassE:Definedbythefirst8bitswitharangefrom240255 Thisisreservedforexperimentaluse. Range:240.0.0.0247.255.255.255
EnableForwarding:
Forwardingallowsthenetworkpacketsononenetworkinterface(i.e. eth0 )tobeforwardedtoanothernetworkinterface(i.e. eth1 ).ThiswillallowtheLinuxcomputertoconect("ethernetbridge")orroutenetworktraffic. Thebridgeconfigurationwillmergetwo(orseveral)networksintoonesinglenetworktopology.IpTablesfirewallrulescanbe usedtofiltertraffic. ArouterconfigurationcansupportmulticastandbasicIProutingusingthe"route "command.IPmasquerading(NAT)canbe usedtoconnectprivatelocalareanetworks(LAN)totheinternetorloadbalanceservers.
l
Addinganetworkinterfacecard(NIC):
Manualmethod:Thisdoesnotalterthepermanentconfigurationandwillonlyconfiguresupportuntilthenextreboot.
l
Theeasyway:RedHatversions6.2andlater,shipwithKudzu,adevicedetectionprogramwhichrunsduringsystem initialization.(/etc/rc.d/init.d/kudzu)ThiscandetectanewlyinstalledNICandloadtheappropriatedriver.Then use/usr/sbin/netconfig toconfiguretheIPaddressandnetworksettings.Theconfigurationwillbestoredsothatitwillbe utilizeduponsystemboot. SystemswithtwoNICcards:Typicallytwocardsareusedwhenconnectingtotwonetworks.Inthiscasethedevicemustbe definedusingoneofthreemethods: 1. UsetheRedHatGUItool /usr/bin/netcfg OR 2. Definenetworkparametersinconfigurationfiles: Definenewdeviceinfile(RedHat/Fedora) /etc/sysconfig/networkscripts/ifcfgeth1 (S.u.s.e9.2: /etc/sysconfig/network/ifcfgethidXX:XX:XX:XX:XX)
DEVICE=eth1 BOOTPROTO=static IPADDR=192.168.10.12 NETMASK=255.255.255.0 GATEWAY=XXX.XXX.XXX.XXX HOSTNAME= nodename.nameofdomain.com DOMAIN= nameofdomain.com
OR 3. DefinenetworkparametersusingUnixcommandlineinterface: DefineIPaddress:
ifconfigeth0XXX.XXX.XXX.XXXnetmask255.255.255.0broadcastXXX.XXX.XXX.255 ifconfigeth1192.168.10.12netmask255.255.255.0broadcast192.168.10.255
WhereXXX.XXX.XXX.XXXisthegatewaytotheinternetasdefinedbyyourISPornetworkoperator. Ifamistakeismadejustrepeattheroutecommandsubstituting"del"inplaceof"add".
ConfiguringyourNIC:SpeedandDuplexsettings:
Thisisusuallynotnecessarybecausemostethernetadapterscanautonegotiatelinkspeedandduplexsetting.
l
ListNICspeedandconfiguration:miitool
eth0:negotiated100baseTxFDflowcontrol,linkok
Verbosemode: miitoolv
eth0:negotiated100baseTxFDflowcontrol,linkok
SetNICconfiguration:miitoolF option Option Parameters F 100baseTxFD 100baseTxHD 10baseTFD 10baseTHD 100baseT4 100baseTxFD 100baseTxHD 10baseTFD 10baseTHD
QueryNICwithethtool: Command
ethtoolgeth0 ethtoolaeth0 ethtoolceth0 ethtoolieth0 ethtooldeth0 ethtoolketh0 ethtoolSeth0
ManPages:
l l
miitoolview,manipulatemediaindependentinterfacestatus ethtoolDisplayorchangeethernetcardsettings
Route:
Staticroutes:IP(InternetProtocol)usesaroutingtabletodeterminewherepacketsshouldbesent.Firstthepacketisexamined toseeifits'destinationisforthelocalorremotenetwork.Ifitistobesenttoaremotenetwork,theroutingtableisconsultedto determinethepath.Ifthereisnoinformationintheroutingtablethenthepacketissenttothedefaultgateway.Staticroutesare setwiththe route commandandwiththeconfigurationfile (RedHat/Fedora): /etc/sysconfig/networkscripts/routeeth0 or (RedHat7: /etc/sysconfig/staticroutes ) (S.u.s.e.9.2: /etc/sysconfig/network/routes ):
10.2.3.0/16via192.168.10.254
routeshow/manipulatetheIProutingtable(Staticroute) Examples: Showroutingtable: routee Accessindividualcomputerhostspecifiedvianetworkinterfacecardeth1: routeaddhost123.213.221.231eth1 AccessISPnetworkidentifiedbythenetworkaddressandnetmaskusingnetworkinterfacecardeth0: routeaddnet10.13.21.0netmask255.255.255.0gw192.168.10.254eth0 Conversly: routedelnet10.13.21.0netmask255.255.255.0gw192.168.10.254eth0 Specifydefaultgatewaytousetoaccessremotenetworkvianetworkinterfacecardeth0: routeadddefaultgw201.51.31.1eth0 (Gatewaycanalsobedefinedin /etc/sysconfig/network )
l l
Specifytwogatewaysfortwonetworkdestinations:(i.e.oneexternal,oneinternalprivatenetwork.Two routers/gatewayswillbespecified.) Addinternetgatewayasbefore: routeadddefaultgw201.51.31.1eth0 Addsecondprivatenetwork: routeaddnet10.0.0.0netmask255.0.0.0gw192.168.10.254eth0 routednetworkroutingdaemon.UsesRIPprotocoltoupdateroutingtable. ipx_routeshow/manipulatetheIPXroutingtableIPXistheNovellnetworkingprotocol(Nottypicallyusedunlessyour officehasNovellservers) ifuserIdentifydestinationsroutedtoaparticularnetworkinterface.
VPN,Tunneling:
l l l l l
l l l l
l l l l
CommercialVPNLinuxsoftwaresolutionsYoLinux OpenSWAN.orgIPSecVPNforLinux FreeSWAN.orgIPSecVPNforLinux FreeSWANtutorialhowto OpenVPNSSLVPNsolutionforsitetosite,WiFisecurity,andenterprisescaleremoteaccesswithloadbalancing, failover,andfinegrainedaccesscontrols. SSLExplorerJavaSLLbasedVPN QuaggadynamicroutingsuiteVLAN n2npiertopierwithinaprivatefabric CIPE:CryptoIPEncapsulation(EasiestwaytoconfiguretwoLinuxgatewaysconnectingtwoprivatenetworksoverthe internetwithencryption.) CIPEHomepageCIPEisasimpleencapsulationsystemthatsecurelyconnectstwosubnets. TheLinuxCipe+MasqueradingminiHOWTOAnthonyCiaravalo GRETunnelingGenericRoutingEncapsulationHugoSamayoa VPNHowToMatthewD.Wilson InstallingandRunningPPTPonLinux L2TPExtensions(l2tpext)InternetDrafts.
UsefullLinuxnetworkingcommands:
l l
/etc/rc.d/init.d/networkstart commandtostart,restartorstopthenetwork
l l
l l
l l l l
netstatDisplayconnections,routingtables,statsetc Listexternallyconnectedprocesses: netstatpunta Listallconnectedprocesses: netstatnap Shownetworkstatistics: netstats Kernelinterfacetableinfo: netstataieth0 pingsendICMPECHO_REQUESTpacketstonetworkhosts.UseCntlCtostopping. tracerouteprinttheroutepacketstaketonetworkhost traceroute IPaddressofserver traceroute domainnameofserver mtranetworkdiagnostictoolintroducedinFedoraLiketracerouteexceptitgivesmorenetworkqualityandnetwork diagnosticinfo.Leaverunningtogetrealtimestats.Reportsbestandworstroundtriptimesinmilliseconds. mtr IPaddressofserver mtr domainnameofserver whoisLookupadomainnameintheinternicwhoisdatabase. fingerDisplayinformationonasystemuser.i.e. finger user@host Uses $HOME/.plan and $HOME/.project userfiles. Oftenusedbygamedevelopers.Seehttp://finger.planetquake.com/ iptablesIPfirewalladministration(Linuxkernel2.6/2.4)SeeYoLinuxfirewall/gatewayconfiguration. ipchainsIPfirewalladministration(Linuxkernel2.2)SeeYoLinuxfirewall/gatewayconfiguration. socklistDisplaylistofopensockets,type,port,processidandthenameoftheprocess.Killwith fuser orkill . hostGiveahostnameandthecommandwillreturnIPaddress.Unlike nslookup ,thehost commandwilluse both /etc/hosts aswellasDNS. Example: host domainnameofserver nslookupGiveahostnameandthecommandwillreturnIPaddress.AlsoseeTestingyourDNS(YoLinuxTutorial)Note thatnslookupdoesnotusethe /etc/hosts file.
inetd/xinetd:NetworkSocketListenerDaemons:
ThenetworklisteningdaemonslistenandrespondtoallnetworksocketconnectionsmadeontheTCP/IPportsassignedtoit. Theportsaredefinedbythefile /etc/services .Whenaconnectionismade,thelistenerwillattempttoinvoketheassigned programandpipethedatatoit.Thissimplifiedmattersbyallowingtheassignedprogramtoreadfromstdininsteadofmaking itsownsocketsconnection.Thelistenerhadlesthenetworksocketconnection.Twonetworklisteningandmanagement daemonshavebeenusedinRedHatLinuxdistributions:
l l
inetd:RedHat6.xandolder xinetd:RedHat7.09.0,FedoraCore
inetd:
Configurationfile: /etc/inetd.conf Entriesinthisfileconsistofasinglelinemadeupofthefollowingfields:
servicesockettypeprotocolwaituserservercmdline
l l
l l
service:Thenameassignedtotheservice.Matchesthenamegiveninthefile /etc/services sockettype: stream:connectionprotocols(TCP) dgram:datagramprotocols(UDP) raw rdm seqpacket protocol:Transportprotocolnamewhichmatchesanameinthefile /etc/protocols .i.e.udp,icmp,tcp,rpc/udp, rpc/tcp,ip,ipv6 wait:Appliesonlytodatagramprotocols(UDP). wait[.max]:Oneserverforthespecifiedportatanytime(RPC) nowait[.max]:Continuetolistenandlaunchnewservicesifanewconnectionismade.(multithreaded) Maxreferstothemaximumnumberofserverinstancesspawnedin60seconds.(default=40) user[.group]:loginidoftheusertheprocessisexecutedunder.Oftennobody,rootoraspecialrestrictedidforthat service. server:Fullpathnameoftheserverprogramtobeexecuted. cmdline:Commandlinetobepassedtotheserver.Thisincludesargument0(argv[0]),thatisthecommandname. Thisfieldisemptyforinternalservices.ExampleofinternalTCPservices:echo,discard,chargen(character generator),daytime(humanreadabletime),andtime(machinereadabletime).(seeRFC)
SampleFile: /etc/inetd.conf
#echostreamtcpnowaitrootinternal #echodgramudpwaitrootinternal ftpstreamtcpnowaitroot/usr/sbin/tcpdin.ftpd la #pop3streamtcpnowaitroot/usr/sbin/tcpdipop3d #swatstreamtcpnowait.400root/usr/sbin/swatswat
xinetd:ExtendedInternetServicesDaemon:
Xinetdhasaccesscontrolmachanisms,loggingcapabilities,theabilitytomakeservicesavailablebasedontime,andcan placelimitsonthenumberofserversthatcanbestarted,redirectservicestodifferentportsandnetworkinterfaces(NIC)or eventoadifferentserver,chrootaserviceetc...andthusaworthyupgradefrominetd. Usethecommand chkconfiglist toviewallsystemservicesandtheirstate.Itwillalsolistallnetworkservices controlledbyxinetdandtheirrespectivestateunderthetitle"xinetdbasedservices".(Worksforxinetd(RH7.0+)butnot inetd) ThexinetdnetworkdaemonusesPAMalsocallednetworkwrapperswhichinvokethe /etc/hosts.allow and/etc/hosts.deny files. Configurationfile: /etc/xinetd.conf whichinturnusesconfigurationfilesfoundinthedirectory /etc/xinetd.d/ . Toturnanetworkserviceonoroff:
l
Editthefile /etc/xinetd.d/servicename Setthedisablevalue: disable=yes or disable=no Restartthexinetdprocessusingthesignal: SIGUSR1( killSIGUSR1processid )Softreconfigurationdoesnotterminateexistingconnections. (Importantifyouareconnectedremotely) SIGUSR2Hardreconfigurationstopsandrestartsthexinetdprocess. (Note:UsingtheHUPsignalwillterminatetheprocess.) OR
Thefilecontainsentriesoftheform:
serviceservicename { attributeassignmentoperatorvaluevalue... ... {
Where: l attribute: disable: n yes n no type: n RPC n INTERNAL: n UNLISTED:Notfoundin /etc/rpc or /etc/services id:Bydefaulttheserviceidisthesameastheservicename. socket_type: n stream:TCP n dgram:UDP n raw:DirectIPaccess n seqpacket:servicethatrequiresreliablesequentialdatagramtransmission flags:Combinationof: REUSE,INTERCEPT,NORETRY,IDONLY,NAMEINARGS,NODELAY,DISABLE,KEEPALIVE, NOLIBWRAP . Seethexinetdmanpagefordetails. protocol:Transportprotocolnamewhichmatchesanameinthefile /etc/protocols . wait: n no:multithreaded n yes:singlethreadedOneserverforthespecifiedportatanytime(RPC) user:Seefile: /etc/passwd group:Seefile: /etc/group server:Programtoexecuteandrecievedatastreamfromsocket.(Fullyqualifiednamefullpathenameof program) server_args:Unlikeinetd,arg[0]orthenameoftheserviceisnotpassed. only_from:IPaddress,factorizedaddress,netmaskrange,hostnameornetworknamefrom file /etc/networks . no_access:Denyfrom...(inverseofonly_from) access_times port:Seefile /etc/services Also:log_type,log_on_success,log_on_failure(Logoptions:+=PID,HOST,USERID,EXIT,DURATION,ATTEMPT andRECORD),rpc_version,rpc_number,env,passenv,redirect,bind,interface,banner,banner_success, banner_fail,per_source,cps,max_load,groups,enabled,include,includedir,rlimit_as,rlimit_cpu,rlimit_data, rlimit_rss,rlimit_stack. Thebestsourceofinformationisthemanpageanditsmanyexamples. l assignmentoperator: = +=:addavaluetothesetofvalues =:deleteavaluefromthesetofvalues Thenrestartthedaemon: /etc/rc.d/init.d/xinetdrestart Examplefrommanpage:Limittelnetsessionsto8Mbytesofmemoryandatotal20CPUsecondsforchildprocesses.
servicetelnet { socket_type=stream wait=no nice=10 user=root server=/usr/etc/in.telnetd rlimit_as=8M rlimit_cpu=20 }
Formoreinfosee:
l l l l l
RWHO:RemoteWhodaemonrwhod
The"rwho "commandisusedtodisplayusersloggedintocomputersonyourLAN. Bydefault,RedHatLinuxhasthenetworkinterfacetotherwhoddisabled.Thusifoneissuesthecommand" rwho ",youwillonly seewhoisloggedintothesystemyouareloggedintoandnotremotesystemsonthenetwork.Thisisasafeapproachfor internetserversasitreducestheexposureofaservicewhichcouldbeexploitedbyhackers.Ifyouwishtouse rwhod onalocal privateandfirewallprotectednetwork,hereishow: Allowbroacastcapabilities.Edit /etc/init.d/rwhod changefrom: daemonrwhod to:daemonrwhodb Startservice:
l l
Manpages:
l l l
RPC:RemoteProcedureCalls(Portmapper)
PortmpperisanetworkservicerequiredtosupportRPC's.ManyservicessuchasNFS(filesharingservices)require portmapper. ListRPCservicessupported: [root]#rpcinfoplocalhost Startingportmapserver:
l l
ManPages:
l l l l
PAM:NetworkWrappers:
PluggableAuthenticationModulesforLinux(TCPWrappers) Thissystemallowsordeniesnetworkaccess.OnecanrejectorallowspecificIPaddressesorsubnetstoaccessyoursystem. File:/etc/hosts.allow
in.ftpd:208.188.34.105
l l
Modules:
l l l l
Wietse'sPapers PluggableAuthenticationModulesforLinux(PAM)HomePage
ICMP:
ICMPisthenetworkprotocolusedbythe ping and traceroute commands. ICMPredirectpacketsaresentfromtheroutertothehosttoinformthehostofabetterroute.ToenableICMPredirect,addthe followinglineto /etc/sysctl.conf :
net.ipv4.conf.all.accept_redirects=1
Addthefollowingtothefile: /etc/rc.d/rc.local
forfin/proc/sys/net/ipv4/conf/*/accept_redirects
do echo1>$f done
BlockingICMPandlookinvisibletoping:
ThefollowingfirewallruleswilldropICMPrequests. Iptables:
iptablesAOUTPUTpicmpd0/0jDROP
Ipchains:
ipchainsAoutputpicmpd0/0jDENY
ORdropallincommingpings:
echo1>/proc/sys/net/ipv4/icmp_echo_ignore_all
ThisissometimesnecessarytolookinvisibletoDOS(DenialOfService)attackerswhousepingtowatchyourmachineand launchanattackwhenit'spressenceisdetected
NetworkMonitoringTools:
l
tcpdumpdumptrafficonanetwork.Seediscussionbelow. Commandlineoption Description c C i wfilename n t Filterexpressions: primitive hosthostname Exitafterreceivingcountpackets. Specifysizeofoutputdumpfiles. Specifyinterfaceifmultipleexist.Lowestusedbydefault.i.e.eth0 Writetherawpacketstofileratherthanparsingandprintingthemout. Theycanlaterbeprintedwiththeroption. ImprovespeedbynotperformingDNSlookups.ReportIPaddresses. Don'tprintatimestamponeachdumpline.
Description IfhosthasmultipleIP's,allwillbechecked.
Networknumber. netnetworknumber networknumbermaskmask Networknumberandnetmaskspecified. net port portnumber tcp udp icmp Examples:
l l l l
iptrafInteractiveColorfulIPLANMonitor nmapNetworkexplorationtoolandsecurityscanner Listpingablenodesonnetwork: nmapsP192.168.0.0/24 ScansnetworkforIPaddresses192.168.0.0to192.168.0.255usingping. EtherealNetworkprotocolanalyzer.Examinedatafromalivenetwork. RPM'srequired: l ethereal0.8.152.i386.rpmRedHat7.1PowertoolsCDRPM l ucdsnmp4.212.i386.rpmRedHat7.1binaryCD1 l ucdsnmputils4.212.i386.rpmRedHat7.1binaryCD1 l Also:gtk+,glib,glibc,XFree86libs4.0.35(baseinstall)
l l l
l l
l l l l
Thereisanerrorintheetherealpackagebecauseitdoesnotshowthesnmplibrariesasadependancies,butyou candeducethisfromtheerrorsthatyougetiftheucdsnmplibrariesarenotinstalled. EtherApeGraphicalnetworkmonitorforUnixmodeledafteretherman.Thisisagreatnetworkdiscoveryprogramwith coolgraphics.(RedHatPowertoolsCD7.1) GkrellmNetworkandsystemmonitor.Goodformonitoringyourworkstation.(RedHatPowertoolsCD) IPTrafncursesbasedIPLANmonitor.(RedHatPowertoolsCD) CheopsNetworkdiscovery,location,diagnosisandmanagement.Cheopscanidentifyallofthecomputersthatareon yournetwork,theirIPaddress,theirDNSname,theoperatingsystemtheyarerunning.Cheopscanrunaportscanonany systemonyournetwork.(RedHatPowertoolsCD) ntopShowsnetworkusageinawaysimilartowhattopdoesforprocesses.Monitorshowmuchdataisbeingsentand receivedonyournetwork.(RedHatPowertoolsCD) MRTGMultiRouterTrafficGrapherMonitornetworktrafficloadusingSNMPandgenerateanHTML/GIFreport.(See sampleoutput) dnsadIPtrafficcapture.ExporttoCiscoNetflowfornetworkanalysisreporting. scottyObtainstatusandconfigurationinformationaboutyournetwork.SupportsSNMP,ICMP,DNS,HTTP,SUNRPC, NTP,&UDP.(RedHatPowertoolsCD) BigBrotherMonitoringansservicesavailablility. OpenNMS.orgNetworkManagementusingSNMP. Nagioshost,serviceandnetworkmonitoring Angelnetworkmonitor
Usingtcpdumptomonitorthenetwork:
[root]#ifconfigeth0promiscPutnicintopromiscuousmodetosnifftraffic. [root]#tcpdumpnhostnot XXX.XXX.XXX.XXX|moreSniffnetbutignoreIPwhichisyourremotesession. [root]#ifconfigeth0promiscPullnicoutofpromiscuousmode.
NetworkIntrusionandHackerDetectionSystems:
SNORT:Monitorthenetwork,performingrealtimetrafficanalysisandpacketloggingonIPnetworksforthedetectionofan attackorprobe.
l l
LinuxJournal:PlanningIDSforYourEnterpriseNalneeshGaur InterSectAllianceIntrusiuonanalysis.Identifiesmaliciousorunauthorizedaccessattempts.
ARP:AddressResolutionProtocol
EthernethostsusetheAddressResolutionProtocol(ARP)toconverta32bitinternetIPaddressesintoa48bitEthernetMAC addressusedbynetworkhardware.(See:RFC826)ARPbroadcastsaresenttoallhostsonthesubnetbythedatatransmitting hosttoseewhoreplies.ThebroadcastisignoredbyallexcepttheintendedreceiverwhichrecognizestheIPaddressasitsown. TheMACaddressesareremembered(APRcache)forfuturenetworkcommunications.Computersonthesubnettypicallykeep acacheofARPresponses.ARPbroadcastsarepassedonbyhubsandswitchesbutareblockedbyrouters. ReverseARP(See:RFC903)isabootstrapprotocolwhichallowsaclienttobroadcastrequestingaservertoreplywithitsIP address.
l l l l l l
l l
arp(8)manpagemanipulatethesystemARPcache Showsothersystemsonyournetwork(includingIPaddressconflicts): arpa ShowARPtableLinuxstyle: arpe arpwatch(8)manpagekeeptrackofethernet/ipaddresspairings arpsnmp(8)manpagekeeptrackofethernet/ipaddresspairings.Readsinformationgeneratedbysnmpwalk arping(8)manpagesendARPREQUESTtoaneighborhost PrintARPreply(similarto arpa):arping 192.168.10.99 ListARPtable: cat/proc/net/arp ip(8)manpageshow/manipulaterouting,devices,policyroutingandtunnels ViewARPtable: ipneighbor
ARPissomethingthatsimplyworks.NoLinuxsystemconfigurationisnecessary.It'sallpartoftheethernetandIPprotocol.The aforementionedinformationisjustpartoftheLinuxcultureoffullvisibilityintowhatisgoingon.
ConfiguringLinuxForNetworkMulticast:
Regularnetworkexchangesofdataarepeertopeerunicasttransactions.AnHTTPrequesttoawebserver(TCP/IP),email SNMP(TCP/IP),DNS(UDP),FTP(TCP/IP),...areallpeertopeerunicasttransactions.Ifonewantstotransmitavideo,audioor datastreamtomultiplenodeswithonetransmissionstreaminsteadofmultipleindividualpeertopeerconnections,oneforeach node,onemayusemulticastingtoreducenetworkload.Notethatmulticastandanetworkbroadcastaredifferent.Multicast messagesareonly"heard"bythenodesonthenetworkthathave"joinedthemulticastgroup"whicharethosethatareinterested
Description Listmulticastgrouptowhichthehostissubscribed.Use"InternetGroupManagement Protocol". (See /usr/src/linux/net/core/igmp.c ) Listmulticastinterfaces. (See /usr/src/linux/net/core/dev_mcast.c ) AllhostsconfiguredformulticastwillrespondwiththeirIPaddresses Allroutersconfiguredformulticastwillrespond AllPIMroutersconfiguredformulticastwillrespond AllDVMRProutersconfiguredformulticastwillrespond AllOSPFroutersconfiguredformulticastwillrespond
routeadd224.0.0.0netmask240.0.0.0deveth0
LivinginaMS/WindowsWorld:
l
LinNeighborhoodHomePage
LinNeighborhoodHomePage LinNeighborhoodScreenShot
SeetheYoLinuxtutorialonintegratingLinuxintoaMicrosoftnetwork.
NetworkDefinitions:
l
l l l
IPv4:MostoftheInternetserversandpersonalcomputersuseInternetProtocolversion4(IPv4).Thisuses32bitsto assignanetworkaddressasdefinedbythefouroctetsofanIPaddressupto255.255.255.255.Whichisthe representationoffour8bitnumbersthustotaling32bits. IPv6:InternetProtocolversion6(IPv6)usesa128bitaddressandthusbillionsandbillionsofpotentialaddresses.The protocolhasalsobeenupgradedtoincludenewqualityofservicefeaturesandsecurity.CurrentlyLinuxsupportsIPv6but IPv4isusedwhenconnectingyourcomputertotheinternet. TCP/IP:(TransmissionControlProtocol/InternetProtocol)usesaclientservermodelforcommunications.Theprotocol definesthedatapacketstransmitted(packetheader,datasection),dataintegrityverification(errordetectionbytes), connectionandacknowledgementprotocol,andretransmission. TCP/IPtimetolive(TTL):Thisisacountingmechanismtodeterminehowlongapacketisvalidbeforeitreachesits destination.EachtimeaTCP/IPpacketpassesthrougharouteritwilldecrementitsTTLcount.Whenthecountreaches zerothepacketisdroppedbytherouter.Thisensuresthaterrantroutingandloopingaimlesspacketswillnotfloodthe network. MACAddress:(mediaaccesscontrol)isthenetworkcardaddressusedforcommunicationbetweenothernetwork devicesonthesubnet.Thisinfoisnotroutable.TheARPtablemapsTCP/IPaddress(globalinternet)tothelocalhardware onthelocalnetwork.Usethecommand /sbin/ifconfig toviewboththeIPaddressandtheMACaddress.TheMAC addressuniquelyidentifieseachnodeofanetworkandisusedbytheEthernetprotocol. FullDuplex:Allowsthesimultaneoussendingandreceivingofpackets.Mostmodernmodemssupportfullduplex. HalfDuplex:Allowsthesendingandreceivingofpacketsinonedirectionatatimeonly. OSI7LayerModel:TheISO(InternationalStandardsOrganization)hasdefinedtheOSI(OpenSystemsInterconnection) modelforcurrentnetworkingprotocols. OSILayer Description LinuxNetworkingUse 7 6 5 4 3 2 1 ApplicationLayer. telnet,webbrowser,sendmail Thetoplayerforcommunicationsapplicationslikeemailandtheweb. PresentationLayer. Syntaxandformatofdatatransfer. SessionLayer. TransportLayer. Connection,acknowledgementanddatapackettransmission. NetworkLayer. DataLinkLayer. Errorcontrol,timing SMTP,http
RelatedLinks:
l l l l l l l l l
l l l l
CablemodemHowToVladimirVuksan EthernetHowToPaulGortmaker YoLinuxTutorial:Settingupaninternetgatewayforhomeorofficeusingiptablesoripchains FirewallHowToMarkGrennan YoLinuxnetworkingtutorial NetworkingOverviewHowToDanielLopezRidruejo NetworkingHowtoJoshuaDrake NFSHowtoNicolaiLangfeldt SNMP:SimpleNetworkManagementProtocol(Usesports161,162,391,1993) SNMPIntroandtutorials LinuxSNMPNetworkManagementTools SNMPFAQ netsnmptoolsandlibraries News/UsenetGroup:comp.os.linux.networkingDeja MARSnweNetwareemulator Linux2.4AdvancedRoutingHOWTOiproute2,trafficshapingandabitofnetfilter ISDN: ISDN4LINUXFAQMatthiasHessler
l l
ISDN4LinuxHomePage DanKegel'sISDNPage PPP:PointtoPointProtocol YoLinuxTutorial:ConfiguringPPPdialupconnectionstoanISP YoLinuxTutorial:DialingCompuserve YoLinuxTutorial:DialingAOL YoLinuxTutorial:ConfiguringPPPdialinconnections PPTP:PointtoPointTunnelingProtocol RFC2637:PointtoPointTunnelingProtocol(PPTP). PPTPLinuxClientAPPTPLinuxclientthatallowsalinuxsystemtoconnecttoaPPTPserver.DevelopedbyC.S. Ananian. CounterpaneSystemsFAQonMicrosoft'sPPTPImplementationFAQonthesecurityflawsinMicrosoft'sPPTP Implementation. DHCP:(DynamicHostConfigurationProtocol) YoLinuxDHCPTutorialHowtosetupaDHCPserver. ISCDynamicHostConfigurationProtocolDHCPhomepage Multicast: YoLinuxTutorial:ConfiguringLinuxformulticastthistutorialinsectionabove MulticastoverTCP/IPHOWTO ISP's:(National/Global) TheList.comComprehensivelistofISP's Earthlink Concentric ATTWorldnet NIS:(NFSinfrastructure) YoLinuxNIStutorial NIShowto NISconfigurationanduse Ethernetcables: MakingCAT3,5,5ERJ45EthernetCables WiringandInstallation GigabitEthernet VIX:ViennaInterneteXchangeEuropeantrafficexchangeforISP's
TestInternetBandwidth:
l l l l l
ManPages:
l l l l l
Books:
"NetworkingLinux:APracticalGuidetoTCP/IP" byPatEyler ISBN#0735710317,NewRidersPublishing
"AdvancedLinuxNetworking"
byRoderickW.Smith ISBN#0201774232,AddisonWesleyProfessional1stedition(July15,2002)
"RedHatLinux9Unleashed" byBillBall,HoytDuff Sams,ISBN#0672325888 IhavetheRedHat6versionandIhavefoundittobeveryhelpful.Ihavefoundittobe waymorecompletethantheotherLinuxbooks.ItisthemostcompletegeneralLinux bookinpublication.Whileotherbooksinthe"Unleashed"serieshavedissapointed me,thisbookisthebestoutthere. "RedhatLinux9(VisualQuickProGuide)" byHaroldDavis ISBN#032121918X,PeachpitPress,AddisonWesley ThebestbasicLinuxbookaroundfortheGUIgeneration.Thisbookcanbebest describedasaguidetousingtheGUIconfigurationtools.