• m Linux pЉ|
    osGAзR firefox s
    | cD | ̔D | g | A | ~R | ୱR | w޲z | QAO | Ŏ | y`~ | m | Xs |
    @ @ @
    @
    ̪sG2011/07/18
    Linux \SjA@ɤڭ̤]LkҦOAoӏظ`Dnتb@DZ`OӤwC ܩCӫONγ~NbA[]ɡA̷ӫO}ʨӶi满CSMAboӏظ`DnتObNҦOJb@_A eATIo@RӬSnIANOʥ]^OCYx]S}YAۡAŪA^ӳo@إJNmߔ[I


    jADϥ5.1 Ӌ]wϥΪO

    ɨpGAQnnAӋ]wA]A IP ӋBѰӋPLuΆΡANonAUoǬ}O~I䤤H ifconfig route oOOnI ^_^ISMAsA@kAiHϥ ip oӷJ㪺Oӳ]w IP ӋTI

    • ifconfig    GdߡB]wdP IP kά}ӋF
    • ifup, ifdownGoɮ׬O scriptAzL̔x覡ӎŰʺF
    • route       GdߡB]wѪ (route table)
    • ip          GƦXOA iH^קWz쪺\F


    pADϥ5.1.1 /۰ʳ]wPŰ/} IP ӋG ifconfig, ifup, ifdown

    oTӫOγ~ObŰʺALA ifup P ifdown ȯN /etc/sysconfig/network-scripts ifcfg-ethX (X Ӌr) iŰʩ}ʧ@Aäઽ^קӋADʽվ ifcfg-ethX ɮפ~Cܩ ifconfig hiH^ʵYӤ IP νվӋIUڭ̴NOӽͤ@͡I


    • ifconfig

    ifconfig DnOiHʪŰʡB[ԎPק}ӋAiHק諸Ӌܦh[A]A IP ӋH MTU ΆγiHקALykpUG

    [root@www ~]# ifconfig {interface} {up|down}  <== [ԎPŰʤ
    [root@www ~]# ifconfig interface {options}    <== ]wPק虜
    ﶵPӋG
    interfaceGdNA]A eth0, eth1, ppp0 Ά
    options  GiH^ӋA]ApUG
        up, down GŰ (up) } (down) M(AΥӋ)
        mtu      GiH]wP MTU ӋȡAҦp mtu 1500 (x쬰 byte)
        netmask  GNOlBnF
        broadcastGNOs}[I
    
    # dҤ@G[ԎҦ(^KJ ifconfig)
    [root@www ~]# ifconfig
    eth0      Link encap:Ethernet  HWaddr 08:00:27:71:85:BD
              inet addr:192.168.1.100  Bcast:192.168.1.255  Mask:255.255.255.0
              inet6 addr: fe80::a00:27ff:fe71:85bd/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:2555 errors:0 dropped:0 overruns:0 frame:0
              TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:239892 (234.2 KiB)  TX bytes:11153 (10.8 KiB)
    

    @ӻA^KJ ifconfig N|CXثewgQŰʪdAAoӥdO_ IPA|QܥXӡCpGOKJ ifconfig eth0Ahȷ|qXoi}ơA ӤMO_ŰCҥHpGAQnDYid Hardware AddressA^KJy ifconfig "N" zYiI ^_^IܩWX{UƬOo˪(ƱƦCѤWӤUBѥӥk)G

    • eth0GNOdNA] lo o loopback F
    • HWaddrGNOdw}AU٪ MAC O]F
    • inet addrGIPv4 IP }A Bcast, Mask ONO Broadcast P netmask I
    • inet6 addrGO IPv6 IP Aڭ̨SϥΡAҥHLF
    • MTUGNOĤGؽͨ쪺 MTU [I
    • RXG@NOюŰʨثeʥ]^pA packets Nʥ]ӋBerrors Nʥ]o͎h~ӋqB dropped Nʥ]ѩ󦳰DӾDӋqΆ
    • TXGP RX ۤϡAюŰʨثeǰepF
    • collisionsGNʥ]IpApGoͤӦhA ܧApӦnF
    • txqueuelenGNΨӶljKƪweϪxsסF
    • RX bytes, TX bytesG`^Bǰe줸œ`q

    zL[ԎWzơAjPWiHAApAרO RX, TX error ӋqA HάO_oY collision pAOݭn`NI ^_^

    # dҤGGȮɭקA eth0 @ 192.168.100.100/24 Ӌ
    [root@www ~]# ifconfig eth0 192.168.100.100
    # pG[LӋAht|̷M IP Ҧb class dA۰ʪpX
    # netmask H network, broadcast  IP ӋAYQLӋhG
    
    [root@www ~]# ifconfig eth0 192.168.100.100 \
    > netmask 255.255.255.128 mtu 8000 
    # ]wPӋAPɳ]w MTU ӋȡI
    
    [root@www ~]# ifconfig eth0 mtu 9000
    # ȭקM MTU ӋȡALOʡI
    
    [root@www ~]# ifconfig eth0:0 192.168.50.50
    # JNݨӤO eth0:0 INObMdWAA[@ӺA
    # YOb@idW]wh IP NTI
    
    [root@www ~]# ifconfig
    eth0      Link encap:Ethernet  HWaddr 08:00:27:71:85:BD
              inet addr:192.168.100.100  Bcast:192.168.100.127  Mask:255.255.255.128
              inet6 addr: fe80::a00:27ff:fe71:85bd/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:9000  Metric:1
              RX packets:2555 errors:0 dropped:0 overruns:0 frame:0
              TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:239892 (234.2 KiB)  TX bytes:11153 (10.8 KiB)
    
    eth0:0    Link encap:Ethernet  HWaddr 08:00:27:71:85:BD
              inet addr:192.168.50.50  Bcast:192.168.50.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:9000  Metric:1
    # JNݡAO_Pw馳}TۦP[IShI]OP@idI
    # pGQnNإߪi eth0:0 }NnAvT즳 eth0 OH
    
    [root@www ~]# ifconfig eth0:0 down
    # } eth0:0 oӤCpGQιw]ȎŰ eth1Gyifconfig eth1 upzYiF
    
    # dҤTGNʪBzAϥέ즳]wȭغӋG
    [root@www ~]# /etc/init.d/network restart
    # ]wƥġA|H ifcfg-ethX ]wDI
    

    ϥ ifconfig iHȮɤʨӳ]wέקYӤd}\AåB]iHzL eth0:0 oR[ӳ]wn@idWh IP Iʪ覡uO̔x[IåB]wh~]A]ڭ̥iHQ /etc/init.d/network restart ӭsŰʾӺA򤧫eʪ]wƷ|ijIt~A nŰʬYӺASL㦳 IP ӋɡA^L ifconfig eth0 up YiI oӰʧ@g`bLudS|iA]ڭ̥nŰʵLudLh AP sbP_[I


    • ifup, ifdown

    Yɪʭק@ǺӋAiHQ ifconfig ӹFApGOn^H]wɡA YOb /etc/sysconfig/network-scripts ̭ ifcfg-ethx ɮת]wӋӎŰʪܡA NonzL ifdown ifup ӹFFC

    [root@www ~]# ifup   {interface}
    [root@www ~]# ifdown {interface}
    
    [root@www ~]# ifup eth0
    

    ifup P ifdown uO̔xFIo{O script ӤwAL|^ /etc/sysconfig/network-scripts ؿUjMR]wɡAҦp ifup eth0 ɡAL|X ifcfg-eth0 oɮתeAMӥ[H]wC } ifcfg-eth0 ]whаѦĥ|C

    LAѩo{DnOjM]w (ifcfg-ethx) ӶiŰʻP}A ҥHbϥΫeнTw ifcfg-ethx O_usb󥿽TؿA_h|ŰʥѳI t~ApGH ifconfig eth0 .... ӳ]wΪ̬OקFA NLkAH ifdown eth0 覡}FI] ifdown |RثeӋP ifcfg-eth0 O_۲šAŪܡAN|Mʧ@C]Aϥ ifconfig ק粒ܫARMnH ifconfig eth0 down ~^}MI


    pADϥ5.1.2 ѭקG route

    ڭ̦bĤGغɭԽ͹L}ѪDA DE@wnѤ~^q TCP/IP wA_hNLkisu[I@ӻAunA MN|ͤ@ӸѡAҥHڭ̦wUDE@ eth0 Aݰ_ӴN|OoˡG

    [root@www ~]# route [-nee]
    [root@www ~]# route add [-net|-host] [kΥDE] netmask [mask] [gw|dev]
    [root@www ~]# route del [-net|-host] [kΥDE] netmask [mask] [gw|dev]
    [ԎӋG
       -n  GnϥγqTwΥDEW١A^ϥ IP  port numberF
       -ee GϥΧNT
    W[ (add) PR (del) Ѫ}ӋG
       -net    Gܫ᭱^Ѭ@ӺkF
       -host   Gܫ᭱^s^xDEѡF
       netmask GPk}AiH]w netmask MwkjpF
       gw      Ggateway ̔gA^O IP ӋȳAP dev PF
       dev     GpGuOnwѨ@dsuXhAhϥγoӳ]wA᭱^ eth0 
    
    # dҤ@Gxª[ԎѪA
    [root@www ~]# route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U     1002   0        0 eth0
    0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 eth0
    
    [root@www ~]# route
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
    link-local      *               255.255.0.0     U     1002   0        0 eth0
    default         192.168.1.254   0.0.0.0         UG    0      0        0 eth0
    

    ѤWҤlSJN[Ԏ route P route -n KXGAAiHo{[ -n ӋDnOܥX IP Aܩϥ route ӤwܡAܪhOyDEW١zI]NOAbw]pUA route |hXM IP DEW١ApG䤣OH N|ܪww(IpC)AҥHAmq`^ϥ route -n TI ѤWݰ_ӡAڭ̤]D default = 0.0.0.0/0.0.0.0 A ӤWTǧAnDOH

    • Destination, GenmaskGoӪNNOOO network P netmask TIҥHoөNNNœX@ӧ㪺koI

    • GatewayGMkOqL gateway s^XhHpG 0.0.0.0 MѬO^ѥEǰeAYiHzLk MAC ^ǰTFpG IP ܡAMѻݭngLѾ (qTh) D~^ǰeXhC

    • FlagsG`@hӺXAANNqpUG
      • U (route is up)GMѬOŰʪF
      • H (target is a host)G؊AO@DE (IP) ӫDkF
      • G (use gateway)GݭnzL~DE (gateway) 茻ʥ]F
      • R (reinstate route for dynamic routing)GϥΰʺAѮɡA_ѸTXAF
      • D (dynamically installed by daemon or redirect)GwgѪAȩ port \]wʺA
      • M (modified from routing daemon or redirect)GѤwgQקFF
      • ! (reject route)GoӸѱN|Q^(ΨөפwkI)

    • IfaceGoӸѶǻʥ]C

    ~A[Ԏ@UWѱƦCdzA̧ǬOѤpk (192.168.1.0/24 O Class C)Avjk (169.254.0.0/16 Class B) ̫hOw] (0.0.0.0/0.0.0.0)C MSڭ̭nP_YӺʥ]RMpǰeɭԡAMʥ]|gѳoӸѪL{ӧP_I |ҨӻAڤWYȦTӸѡAYڦ@Ӷǩ 192.168.1.20 ʥ]nǻA| 192.168.1.0/24 oӺkѡAFIҥH^ eth0 ǰeXhF

    pGOǰe Yahoo DEOH Yahoo DE IP O 119.160.246.241Aڭ̳qLP_ 1)O 192.168.1.0/24A 2)O 169.254.0.0/16 GF 3)0/0 ɡAOKIǥXhFAzL eth0 Nʥ]ǵ 192.168.1.254 gateway DE[IҥHAѬOǪC

    ]SAƳ]whӦP˪ѮɡA ҦpbADEWid]wۦPk IP ɡA|X{򱡪pH|X{pUpG

    Kernel IP routing table
    Destination    Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
    192.168.1.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
    

    ]NOAѩѬO̷ӶǨӱƦCPǰeA ҥHAʥ]OѨӤ (eth0, eth1) ^A|ѤWz eth0 ǰeXhA ҥHAb@DEW]wӬۦPk IP SNqIIh@|NOFC DO[E (Xen, VMware γn) Ҭ[]hDEɡA~|oӥn

    # dҤGGѪW[PR
    [root@www ~]# route del -net 169.254.0.0 netmask 255.255.0.0 dev eth0
    # WoӰʧ@iHR 169.254.0.0/16 oӺkI
    # Ъ`NAbRɭԡAݭnNѪWX{TgJ
    # ]A netmask , dev ΆΰӋI`N`N
    
    [root@www ~]# route add -net 192.168.100.0 \
    > netmask 255.255.255.0 dev eth0
    # zL route add ӼW[@ӸѡIЪ`NAoӸѪ]wn^PAqC
    # |ҨӻApGڤUFUON|܎h~G
    # route add -net 192.168.200.0 netmask 255.255.255.0 gw 192.168.200.254
    # ]ڪDEȦ 192.168.1.11 o IP AҥHઽ^P 192.168.200.254
    # oӺq^ϥ MAC qIo˻AiHzܡH
    
    [root@www ~]# route add default gw 192.168.1.250
    # W[w]ѪkIЪ`NAun@ӹw]ѴN^FI
    # P˪A 192.168.1.250  IP ]ݭnPA LAN q~I
    # boӦapGAHK]wAOoϥΩUOs]wA
    # /etc/init.d/network restart
    

    pGOniѪRPW[ANonѦҤWҤlFAAϥ man route ̭ƴN܂IFIJNd\@UoI AunOoASX{ySIOCADDRT: Network is unreachablez oӎh~ɡA֩wOѩ gw ᭱^ IP Lk^PAkq (Gateway äbAk)A ҥHAԒˬd@UO_KJh~[I

    Tips:
    @ӻAmpG^IJ@ӷs줺DEAbQnʭt]wɱpUAMwpϥΥѪ]wɡA ʪBzNܦGyifconfig eth0 192.168.1.100; route add default gw 192.168.1.254zo˴NdwFI ^pPCΨ짹AAo /etc/init.d/network restart _tYiC
    mϥ

    pADϥ5.1.3 ӋXOG ip

    ip OӫOIäO TCP/IP IP TIo ip O\ihFI򥻤WALNOXF ifconfig P route oӫOo㤣LA ip iHF\oShhIuOӬSF`OCpGAêܡAЦۦ vi /sbin/ifup AND ifup NOQ ip oӫOӹFCnFApϥΩOHڭ̨@@@I

    [root@www ~]# ip [option] [ʧ@] [O]
    ﶵPӋG
    option G]wӋADnG
        -s GܥXMUmpӋ(statistics)AҦp`^ʥ]ӋΡF
    ʧ@GYOiHwǺӋiʧ@A]AG
        link  G}Um (device) }]wA]A MTU, MAC }Ά
        addr/address G}B~ IP wAҦph IP FΆΡF
        route GPѦ}}]w
    

    ѤWykڭ̥iHDA ip FiH]w@ǰ򥻪Ӌ~AR^iB~ IP wA]Ah IP FAuOӧFIUڭ̴NTӈ (link, addr, route) Ӥo ip OaI


    • }Um (device) }]wG ip link

    ip link iH]wPUm (device) }}ӋA]A MTU HM MAC ΆΡASM]iHŰ (up) } (down) YӺTIӻykOo˪G

    [root@www ~]# ip [-s] link show  <== xªd\MUm}T
    [root@www ~]# ip link set [device] [ʧ@PӋ]
    ﶵPӋG
    showGܥXoӗUm}eApG[W -s |ܧhpӋڡF
    set GiH}l]wءA device O eth0, eth1 ΆΤNF
    ʧ@PӋG]AUoǰʧ@G
       up|down  GŰ (up) } (down) YӤALӋϥιw]AӺF
       address  GpGoӗUmiH MAC ܡAγoӰӋקI
       name     GoӗUm@ӯSWrF
       mtu      GNO̤jljKx[I
    
    # dҤ@GܥXҦT
    [root@www ~]# ip link show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 08:00:27:71:85:bd brd ff:ff:ff:ff:ff:ff
    3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
        link/ether 08:00:27:2a:30:14 brd ff:ff:ff:ff:ff:ff
    4: sit0: <NOARP> mtu 1480 qdisc noop state DOWN
        link/sit 0.0.0.0 brd 0.0.0.0
    
    [root@www ~]# ip -s link show eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 08:00:27:71:85:bd brd ff:ff:ff:ff:ff:ff
        RX: bytes  packets  errors  dropped overrun mcast
        314685     3354     0       0       0       0
        TX: bytes  packets  errors  dropped carrier collsns
        27200      199      0       0       0       0
    

    ϥ ip link show iHܥXӗUmw}TApWҥܡA]Ad}(MAC)BMTUΆΡA êRMO sit0 FA sit0 OΦb IPv4 IPv6 ʥ]茂WA ڭ̶Ȩϥ IPv4 OS@ΪC lo sit0 ODEҦۦ]wC ӦpG[W -s ӋAhoӺd}pTN|QCXӡA ]A^ (RX) ζǰe (TX) ʥ]ӋqΆΡANeP ifconfig ҉KXGۦPC

    # dҤGGŰʡB}P]wUm}T
    [root@www ~]# ip link set eth0 up
    # Ű eth0 oӗUmF
    
    [root@www ~]# ip link set eth0 down
    # N}[I̔xnR
    
    [root@www ~]# ip link set eth0 mtu 1000
    #  MTU ȡAF 1000 bytesAxNO bytes [I
    

    sd MTU ϥ ifconfig ]iHF[ISԣF_ALApGOnydNB MAC }TzܡAiNoϥ ip o㤣LA]weion}MdA_h|\C pUҥܡG

    # dҤTGקdNBMAC ΰӋ
    [root@www ~]# ip link set eth0 name vbird
    SIOCSIFNAME: Device or resource busy
    # ]MUmثeOŰʪAҥHo˰]wCARMno˰G
    
    [root@www ~]# ip link set eth0 down       <==}
    [root@www ~]# ip link set eth0 name vbird <==s]w
    [root@www ~]# ip link show                <==[Ԏ@U
    2: vbird: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 08:00:27:71:85:bd brd ff:ff:ff:ff:ff:ff
    # ȤFaIsdNiHܡILAOo^Ӕ[I
    # ]ڭ̪ ifcfg-eth0 ROϥέ쥻UmNIקKDAn^
    
    [root@www ~]# ip link set vbird name eth0 <==^
    
    [root@www ~]# ip link set eth0 address aa:aa:aa:aa:aa:aa
    [root@www ~]# ip link show eth0
    # pGAd䴩w}(MAC)iH諸ܡAWoӰʧ@NiH
    # Ad}FIF`aILAROyѸܡAХߨ^Ӕ[I
    

    boӗUmw}T]wWA]A MTU, MAC HζljKҦΆΡAiHbo̳]wC êO address ءAӶث᭱^iOw} (MAC) ӤO IP I ܮedh[IOOIhwӋiHϥ man ip d\@UP ip link }]wC


    • }B~ IP }]wG ip address

    pG ip link OP OSI Chw ĤGhƳs피h}ܡA ip address (ip addr) NOPĤThh}ӋTI DnOb]wP IP }UӋA]A netmask, broadcast ΆΡC

    [root@www ~]# ip address show   <==NOd\ IP Ӌ[I
    [root@www ~]# ip address [add|del] [IPӋ] [dev UmW] [}Ӌ]
    ﶵPӋG
    show    GxªܥX IP T[F
    add|del Gi}ӋW[ (add) ΧR (del) ]wADnG
        IP ӋGDnNOk]wAҦp 192.168.100.100/24 ]wF
        dev    Go IP Ӌҭn]wAҦp eth0, eth1 ΆΡF
        }ӋGDnUoǡG
            broadcastG]ws}ApG]wȬO + ܡyt۰ʭpz
            label    GYOoӗUmOWAҦp eth0:0 NOFI
            scope    GoӤZkAq`OoXӤjG
                       global G\Ӧ۩ҦӷsuF
                       site   GȤ䴩 IPv6 AȤ\DEsuF
                       link   GȤ\UmۧڳsuF
                       host   GȤ\DEsuF
                       ҥHSMOϥ global oIw]]O global TI
    
    # dҤ@GܥXҦ IP ӋG
    [root@www ~]# ip address show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 08:00:27:71:85:bd brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
        inet6 fe80::a00:27ff:fe71:85bd/64 scope link
           valid_lft forever preferred_lft forever
    3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
        link/ether 08:00:27:2a:30:14 brd ff:ff:ff:ff:ff:ff
    4: sit0: <NOARP> mtu 1480 qdisc noop state DOWN
        link/sit 0.0.0.0 brd 0.0.0.0
    

    ݨWӯSrܡHShINO IP ӋTI]O ip address ̥Dn\C Uڭ̶i@BӷsW[ݬݡG

    # dҤGGsW@ӤAWٰ] eth0:vbird 
    [root@www ~]# ip address add 192.168.50.50/24 broadcast + \
    > dev eth0 label eth0:vbird
    [root@www ~]# ip address show eth0
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 08:00:27:71:85:bd brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.100/24 brd 192.168.1.255 scope global eth0
        inet 192.168.50.50/24 brd 192.168.50.255 scope global eth0:vbird
        inet6 fe80::a00:27ff:fe71:85bd/64 scope link
           valid_lft forever preferred_lft forever
    # ݨWSrFaHhXF@sABW٬O eth0:vbird
    # ܩ󨺭 broadcast + ]iHg broadcast 192.168.50.255 TI
    
    [root@www ~]# ifconfig
    eth0:vbird Link encap:Ethernet  HWaddr 08:00:27:71:85:BD
              inet addr:192.168.50.50  Bcast:192.168.50.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
    # pGϥ ifconfig N^ݨoөǪFFIiRaI ^_^
    
    # dҤTGN誺R 
    [root@www ~]# ip address del 192.168.50.50/24 dev eth0
    # RN̔x[I ^_^
    

    • }Ѫ}]wG ip route

    oӶSMNOѪ[ԎP]woIWA ip route \XGP route oӫOthAOALRiHiB~Ӌ]pAҦp MTU WُΆΡASj[I

    [root@www ~]# ip route show  <==xªܥXѪ]wӤw
    [root@www ~]# ip route [add|del] [IPκk] [via gateway] [dev Um]
    ﶵPӋG
    show GxªܥXѪA]iHϥ list F
    add|del GW[ (add) ΧR (del) ѪNC
        IPκkGiϥ 192.168.50.0/24 kΪ̬Oxª IP F
        via     Gq gateway XhA@wݭnF
        dev     GѨӗUmsXhAoNݭnFI
        mtu     GiHB~]w MTU ӋȳI
    
    # dҤ@GܥXثeѸ
    [root@www ~]# ip route show
    192.168.1.0/24 dev eth0  proto kernel  scope link  src 192.168.1.100
    169.254.0.0/16 dev eth0  scope link  metric 1002
    default via 192.168.1.254 dev eth0
    

    pWҥܡA̔x\NOܥXثeѸTA route oӫOۦPTI ܥn`NXӤpFG

    • protoGѪѨwADn redirect, kernel, boot, static, ra ΡA 䤤 kernel O^Ѯ֤ߧP_۰ʳ]wC
    • scopeGѪdADnO link AYOPUm}^suC

    AӬݤ@UpiѪW[PRaI

    # dҤGGW[ѡADnOE^iqk
    [root@www ~]# ip route add 192.168.5.0/24 dev eth0
    # w糧E^qk]wnѡAݭnzL~Ѿ
    [root@www ~]# ip route show
    192.168.5.0/24 dev eth0  scope link
    ....(HUٲ)....
    
    # dҤTGW[iHq~ѡAݳzL router I
    [root@www ~]# ip route add 192.168.10.0/24 via 192.168.5.100 dev eth0
    [root@www ~]# ip route show
    192.168.5.0/24 dev eth0  scope link
    ....(Lٲ)....
    192.168.10.0/24 via 192.168.5.100 dev eth0
    # JNݳA]ڦ 192.168.5.0/24 Ѧsb (ڪd^pô)A
    # ҥH~iHN 192.168.10.0/24 ѥᵹ 192.168.5.100 
    # DEDǻIPe쪺 route OO@˪I
    
    # dҥ|GW[w]
    [root@www ~]# ip route add default via 192.168.1.254 dev eth0
    #  192.168.1.254 NOڪw]Ѿ (gateway) N[I ^_^
    # uOoAun@ӹw]ѴN OK I
    
    # dҤGR
    [root@www ~]# ip route del 192.168.10.0/24
    [root@www ~]# ip route del 192.168.5.0/24
    

    WAo ip ObOӰVj`FI^IJ Linux B͡Ai|ݨ즳Iw nTIA|ϥ ifconfig, ifup , ifdown P route YiA ΥHᦳgFAA~^Ӫ ip oӦnOaI ^_^ êܡA]iHۦѦ ethtool oӫOI (man ethtool)C


    pADϥ5.1.4 LuG iwlist, iwconfig

    oӫOAnLud~^iIoӫOγ~Oo˪G

    • iwlistGQεLudiLu AP Po}ơF
    • iwconfigG]wLud}ӋC

    oӫORΧڭ̦bĥ|ظ̭Lud]wͤFܦhFA ҥHo̧ڭ̤A͡AêBRMϥ man iwlist P man iwconfig A@UykA MAe@تLup`d@d}ΪkANAFTI ^_^


    pADϥ5.1.5 ʨϥ DHCP ۰ʨo IP ӋG dhclient

    pGAOϥ DHCP wbko IP ܡAO_@wnhs ifcfg-eth0 BOOTPROTO OH KKIӧֳt@kANOQ dhclient oӫO]oӫO~Ouoe dhcp nDu@{[InpϥΩOH̔xIpGҼ{LӋAϥΩUkYiG

    [root@www ~]# dhclient eth0
    

    ^̔xaIo˴NiHߨsڭ̪dH dhcp who IP I


    jADϥ5.2 hP[ԎO

    bUA¤A̱`o쪺@yܴNOGy@DIڪ Linux sWFIzڪѧoIW]hܡIӭnd]O@̔xƱOI LAWڭ̥iHۤvϥδnӰl}i઺h~]AӫܦhOb Linux Ywgw]sbFAunAnn@򥻪OA@ǪBͦbiDAp󰻎hɭԡA ARMNߨiHDpӷdwLoI

    ڭ̦bĥ|ؽͨ쪺ˬdBJwgOSNhy{FI uORǭnO]onA@U~nI


    pADϥ5.2.1 DEIqG ping

    o ping OܭnOAping DnzL ICMP ʥ] ӶiӺpNiASMTA̭nNO ICMP type 0, 8 oA OOnD^NPDʦ^NAO_sbSʡCnSO`NOA ping ROݭnzL IP ʥ]Ӷǰe ICMP ʥ]A IP ʥ]̭ӬSn TTL ݩʡAoOܭn@ӸѯSʡA N IP P ICMP YƽаѦĤGغNC

    [root@www ~]# ping [ﶵPӋ] IP
    ﶵPӋG
    -c ӋȡG᭱^O ping ӋAҦp -c 5 F
    -n     GbKXƮɤi IP PDEW٪ϬdA^ϥ IP KX(t׸)F
    -s ӋȡGoeXh ICMP ʥ]jpAw] 56bytesALAiHj@ӋȡF
    -t ӋȡGTTL ӋȡAw]O 255ACgL@Ӹ`IN|֤@F
    -W ӋȡGΫݦ^RDEӋC
    -M [do|dont] GDnb MTU ӋȤjpAӱ`جOG
       do  GNǰe@ DF (Don't Fragment) XAAʥ]୫s]P]F
       dontGNnǰe DF XAAܫʥ]iHbLDEW]P]
    
    # dҤ@G@U 168.95.1.1 o DNS DEO_sbH
    [root@www ~]# ping -c 3 168.95.1.1
    PING 168.95.1.1 (168.95.1.1) 56(84) bytes of data.
    64 bytes from 168.95.1.1: icmp_seq=1 ttl=245 time=15.4 ms
    64 bytes from 168.95.1.1: icmp_seq=2 ttl=245 time=10.0 ms
    64 bytes from 168.95.1.1: icmp_seq=3 ttl=245 time=10.2 ms
    
    --- 168.95.1.1 ping statistics ---
    3 packets transmitted, 3 received, 0% packet loss, time 2047ms
    rtt min/avg/max/mdev = 10.056/11.910/15.453/2.506 ms
    

    ping ̔x\NOǰe ICMP ʥ]hnDDE^RO_sb줤AW^RTSAXӭnجOo˪G

    • 64 bytesGܳoǰe ICMP ʥ]jp 64 bytes ojAoOw]ȡA bYǯSXAҦpnjӺ̤j MTU ɡAiHϥ -s 2000 ӋȨӨNF

    • icmp_seq=1GICMP Ұi檺ӋAĤ@s 1 F

    • ttl=243GTTL P IP ʥ] TTL OۦPACgL@ӱa MAC `I (node) ɡAҦp router, bridge ɡA TTL N|֤@Aw] TTL 255 A AiHzL -t 150 kӭs]ww] TTL ӋȡF

    • time=15.4 msG^RɶAx즳 ms(0.001) us(0.000001)A @ӻAVp^RɶAܨDEsuV}nI

    pGAѰO[W -c 3 o˪WwӋANonϥ [ctrl]-c NLFI

    DG
    g@}{ ping.sh AzLo}{AAiH ping ӺkDEO_^RC~ACDEȆΫݤ@A]Ȱ@C
    G
    ѩȰ@BΫݤ@A] ping ﶵG -W1 -c1 AӦEҦbϺ 192.168.1.0/24 AҥHiHo˼g (vim /root/bin/ping.sh)G
    #!/bin/bash
    for siteip in $(seq 1 254)
    do
    	site="192.168.1.${siteip}"
    	ping -c1 -W1 ${site} &> /dev/null
    	if [ "$?" == "0" ]; then
    		echo "$site is UP"
    	else
    		echo "$site is DOWN"
    	fi
    done
    

    SO`N@UApGADEPݰDEäbP@ӺkA TTL w]ϥ 255 ApGOP@ӺkA TTL w]hϥ 64 I

    • ping l}|̤j MTU Ӌ

      ڭ̥ѲĤGت̭ͨ[jT (frame) ɡA įODUA]ʥ]]Ӌ|֡A[WpGӶljKC鳣^^o frame Ӥݭnsiʥ]PœܡAįSM|nAӭק frame jpӋNO MTU TI

      nFA{bڭ̪Dd MTU קiHzL ifconfig Ϊ̬O ip ΫOӹFAl}ӺljK̤j MTU ɡASMpdߡHI̔xkSMOzL ping ǰe@Ӥjʥ]A åB\~Ѿ switch NMʥ]œAN^BzTIShIiHo˪G
      # dҤGGX̤j MTU Ӌ
      [root@www ~]# ping -c 2 -s 1000 -M do 192.168.1.254
      PING 192.168.1.254 (192.168.1.254) 1000(1028) bytes of data.
      1008 bytes from 192.168.1.254: icmp_seq=1 ttl=64 time=0.311 ms
      # pG^RANOiH^oӫʥ]ApGL^RANܳo MTU ӤjFC
      
      [root@www ~]# ping -c 2 -s 8000 -M do 192.168.1.254
      PING 192.168.1.254 (192.168.1.254) 8000(8028) bytes of data.
      From 192.168.1.100 icmp_seq=1 Frag needed and DF set (mtu = 1500)
      # oӎh~TOAaݪ MTU ~ 1500 ӤwAAn 8000  MTU
      # ڥNOLkFInpOnHΫe@p` ip link Ӷi MTU ]waI
      
      LAAݭnDOAѩ IP ʥ]Y (t options) NwgΤF 20 bytes AA[W ICMP Y 8 bytes AҥHSMAbϥ -s size ɭԡAӫʥ]jpNon (20+8=28) jpFC ]pGnϥ MTU 1500 ɡANonUFy ping -s 1472 -M do xx.yy.zz.ip z~[I

      t~Aѩ󥻦aݪd MTU ]|vT찻AҥHpGQnӶljKC骺 MTU ӋȡA CӥiHվ㪺DENonϥ ifcofig ip N MTU դjAMAhi氻A _hN|X{^WѪרҤ@ˡAi|X{h~TI

      Lo MTU nHKվ[IDuDCq`վ MTU ɶOboӮɭԡG

      • ]DEsObϺAҦpO[c (cluster) UA ѩ󤺈`IOڭ̥iHA]iHzLק MTU ӼWiįF
      • ]@~tw] MTU PAkšAfPYǺiHQsuAYǺhLksuC H Windows @~t@suɪDEɡAb Client ݮeoͳoӰDF

      pGOnsW Internet DEA`NnHKվ MTU A]ڭ̵LkD Internet WCE^䴩 MTU hjA]......Oڭ̯^ު쪺 ^_^I t~ACRsu覡P MTU ȡA`UR MTU ȤOJ

      MTU
      Ethernet1500
      PPPoE1492
      Dial-up(Modem)576


    pADϥ5.2.2 DEU`IRG traceroute

    ڭ̫eͨ쪺OjhӋOwDEӋ]wһݭnA ping ODE^nP_P_A 򦳨SOiHl}DEqLUӸ`I (node) qTpnaOH|ҨӻApGڭ̳su yahoo tפ񥭱`CAA\oO (1)ۤv즳DH (2)RO~ Internet DHpGO (1) ܡAڭSMݭnˬdۤv[AݬݬO_S֤rFHpGO Internet DOHuyΆΆΡz[I P_O (1) RO (2) Nonϥ traceroute oӫOTI

    [root@www ~]# traceroute [ﶵPӋ] IP
    ﶵPӋG
    -n GiHiDEWٶRAx¥ IP At׸֡I
    -U Gϥ UDP  port 33434 Ӷi氻AoOw]wF
    -I Gϥ ICMP 覡Ӷi氻F
    -T Gϥ TCP Ӷi氻A@ϥ port 80 
    -w GYDEbXS^nNŧiv...w]O 5 
    -p 𸹡GYQϥ UDP P TCP w]𸹨ӰAibܰ𸹡C
    -i UmGΦbzApGAܦhܽzɡA~|ΨoӰӋF
             |ҨӻAA ADSL iHs^~AADE| pppA
             AiHϥ -i ӿܬO ppp0 RO ppp1 TI
    -g ѡGP -i ӋۥAuO -g ᭱^O gateway  IP NOFC
    
    # dҤ@GE yahoo hU`IsuA
    [root@www ~]# traceroute -n tw.yahoo.com
    traceroute to tw.yahoo.com (119.160.246.241), 30 hops max, 40 byte packets
     1  192.168.1.254  0.279 ms  0.156 ms  0.169 ms
     2  172.20.168.254  0.430 ms  0.513 ms  0.409 ms
     3  10.40.1.1  0.996 ms  0.890 ms  1.042 ms
     4  203.72.191.85  0.942 ms  0.969 ms  0.951 ms
     5  211.20.206.58  1.360 ms  1.379 ms  1.355 ms
     6  203.75.72.90  1.123 ms  0.988 ms  1.086 ms
     7  220.128.24.22  11.238 ms  11.179 ms  11.128 ms
     8  220.128.1.82  12.456 ms  12.327 ms  12.221 ms
     9  220.128.3.149  8.062 ms  8.058 ms  7.990 ms
    10  * * *
    11  119.160.240.1  10.688 ms  10.590 ms 119.160.240.3  10.047 ms
    12  * * * <==i঳UmαpoͩҭP
    

    o traceroute N䪺AoӫO|ws^تaҦ node i UDP OɆΫݡA ҦpWҤlSAщmDEs^ Yahoo ɡAL|gL 12 Ӹ`IHWAtraceroute |Dʪo 12 Ӹ`I UDP ^nΫݡAð^ɶAC`ITA̜^^WYܪGC AiHo{CӸ`I^ɶjb 50 ms HAORiH Internet FC

    SO 10/12 ӡA|^ǬPANM node i]YǨ@vIAڭ̵oeʥ]TQҭPC ]ڭ̬O^zLѾ茻ʥ]AèSiJѾhoѾϥθ귽AҥHYǸѾȤ䴩ʥ]茻A ä|^ӦۥΤݪUTIɴN|X{WzDC] traceroute w]ϥ UDP ʥ]ApGAQϥΨLʥ]A -I -T iHݬoI

    ѩثe UDP/ICMP @hXaA]ܦhѾiNoӫʥ]^R\CҥHڭ̥iHϥ TCP ӰI ҦpϥΦP˪kAzLΫݮɶ 1 AH TCP 80 fpUAiHo˰G

    [root@www ~]# traceroute -w 1 -n -T tw.yahoo.com
    

    pADϥ5.2.3 ԎݥEsuPG netstat

    pGA\oAYӺAȩNŰʤFAONOLkysuܡARMH ARMndߤ@UۤvҺof (port) ӬݬݬO_uŰʡA]ɭԿ݁Wܪ [OK] ä@wO OK [I ^_^

    [root@www ~]# netstat -[rn]       <==PѦ}Ӌ
    [root@www ~]# netstat -[antulpc]  <==P}Ӌ
    ﶵPӋG
    P (route) }ӋG
    -r  GCXѪ(route table)A\pP route oӫOF
    -n  GϥΥDEWٻPAȦW١Aϥ IP P port number ApP route -n
    P}ӋG
    -a  GCXҦsuAA]A tcp/udp/unix socket ΡF
    -t  GȦCX TCP ʥ]suF
    -u  GȦCX UDP ʥ]suF
    -l  GȦCXb Listen (o) AȤAF
    -p  GCX PID P Program ɦWF
    -c  GiH]wX۰ʧs@AҦp -c 5 Cs@AܡF
    
    # dҤ@GCXثeѪAABH IP  port number ܡG
    [root@www ~]# netstat -rn
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
    169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
    0.0.0.0         192.168.1.254   0.0.0.0         UG        0 0          0 eth0
    # oӰӋN route -n @Ҥ@ˡAaIoO netstat Dn\TI
    
    # dҤGGCXثeҦsuAAϥ IP P port number
    [root@www ~]# netstat -an
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address     Foreign Address     State
    ....(ٲ)....
    tcp        0      0 127.0.0.1:25      0.0.0.0:*           LISTEN
    tcp        0     52 192.168.1.100:22  192.168.1.101:1937  ESTABLISHED 
    tcp        0      0 :::22             :::*                LISTEN
    ....(ٲ)....
    Active UNIX domain sockets (servers and established)
    Proto RefCnt Flags    Type    State      I-Node Path
    unix  2      [ ACC ]  STREAM  LISTENING  11075  @/var/run/hald/dbus-uukdg1qMPh
    unix  2      [ ACC ]  STREAM  LISTENING  10952  /var/run/dbus/system_bus_socket
    unix  2      [ ACC ]  STREAM  LISTENING  11032  /var/run/acpid.socket
    ....(Uٲ)....
    

    netstat KXDnjAOO TCP/IP AHζDž Unix socket C ROoڭ̦bg̭gͨɮתܡH socket P FIFO ɮROoaH NOb Unix ΨӰ{ƥyFA]NOWY椺ݨ쪺 Active Unix domain sockets eo

    q`mOij[Wy -n zoӰӋA]iH׹LDEWٻPAȦW٪ϬdA^H IP ΰfX (port number) ܡAܪtפW|֫ܦhIܩbKXTSA ڭ̥ӽͤ@}suAKXALDnOUXӤjG

    • ProtoGMsuʥ]wADn TCP/UDP Ϋʥ]F
    • Recv-QGDѨϥΪ̵{s^ҽƻsӨӪ` bytes ӋF
    • Send-QGѭhݥDEҶǰeӨӡA㦳 ACK Ax` bytes ӋA NDʳsu SYN ΨLAxʥ]Ҧ bytes ӋF
    • Local AddressGaݪ}AiHO IP (-n Ӌsb)A ]iHO㪺DEW١CϥΪONOy IP:port zuO IP 榡 IPv4 IPv6 tC pWҥܡAb port 22 AϥΪ :::22 NOw IPv6 ܡAWLNۦP 0.0.0.0:22 NC ܩ port 25 Ȱw lo }AN Internet 򥻤WOLks^ڥE 25 fTI
    • Foreign AddressGhݪDE IP P port number
    • statGACADnAtG
      • ESTABLISEDGwإ߳suAF
      • SYN_SENTGoXDʳsu (SYN Ax) suʥ]F
      • SYN_RECVG^@ӭnDsuDʳsuʥ]F
      • FIN_WAIT1GMAѪA(socket)w_AMsub_uSF
      • FIN_WAIT2GMsuw_AbΫݹDE^R_uT{ʥ]F
      • TIME_WAITGMsuw_A socket RbWΫݓF
      • LISTENGq`ΦbAȪo port IiϥΡy -l zӋd\C

    򥻤WAڭ̱``ͨ쪺 netstat \ANOb[ԎsuAFAӺsuAA SH[Ԏyڥثe}Fh֪ port bΫݥΤݪsuzH yثeڪsuAAhֳsuwإߩβͰDẕ`C ApAP[ԎOHq`mOo˳BzG

    # dҤTGqXثewgŰʪA
    [root@www ~]# netstat -tulnp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address  Foreign Address   State   PID/Program name
    tcp        0      0 0.0.0.0:34796  0.0.0.0:*         LISTEN 987/rpc.statd
    tcp        0      0 0.0.0.0:111    0.0.0.0:*         LISTEN 969/rpcbind
    tcp        0      0 127.0.0.1:25   0.0.0.0:*         LISTEN 1231/master
    tcp        0      0 :::22          :::*              LISTEN 1155/sshd
    udp        0      0 0.0.0.0:111    0.0.0.0:*                969/rpcbind
    ....(Uٲ)....
    # W̭nO -l ӋA]iHȦCXb Listen  port
    

    AiHo{ܦhAȨȰw糧E lo }ӤwAںOs^MfPAȪC ӥѤWzƧڭ̤]iHݨAŰ port 111 ANO rpcbind {ApGQn}oӰfA AiHϥ kill R PID 969A]iHϥ killall R rpcbind oӵ{ǧYiCp@ӡA ܻPANાDӵ{ŰʤFǰfoI

    # dҥ|G[ԎEWYҦsuA
    [root@www ~]# netstat -atunp
    Active Internet connections (servers and established)
    Proto Recv-Q Send-Q Local Address     Foreign Address     State       PID/Program
    tcp        0      0 0.0.0.0:111       0.0.0.0:*           LISTEN      969/rpcbind
    tcp        0      0 0.0.0.0:22        0.0.0.0:*           LISTEN      1155/sshd
    tcp        0      0 127.0.0.1:25      0.0.0.0:*           LISTEN      1231/master
    tcp        0     52 192.168.1.100:22  192.168.1.101:1937  ESTABLISHED 4716/0
    ....(Uٲ)....
    

    ݨWYSraHNثewgإ߳su@suALOѭhݥDE 192.168.1.101 Űʤ@Ӥj 1024 fVaݥDE 192.168.1.100 port 22 i檺@suA AnQ_ӪOGyClient ݬOHE@Ӥj 1024 HW port isuzA~yu root iHŰʤp 1024 HU port zANݪWYsuoIpGosuAQn屼LܡA ݨ̥k䪺 4716 FSH kill |ΧaI ^_^

    ܩDž Unix socket ơAOoϥ man netstat d\@UaI o Unix socket q`OΦb@ǶȦbEWB@{Ҷ}ŪAѤɡA Ҧp X Window ObEWB@ӤwܡH󥲎Űʺ port OHSMiHϥ Unix socket oAt~AҦp Postfix o@AAѩܦhʧ@ObEWYӧA ҥHH|Ϋܦh Unix socket I

    DG
    лAȦWٻP port number Rb Linux SAOΨɮרӳ]wRH
    G
    /etc/services

    pADϥ5.2.4 DEWٻP IP RG host, nslookup

    }DEWٻP IP RAڭ̥DnO DNS Τݥ\઺ dig oӫOCLFoӫO~A Rӧ̔xOANO host P nslookup TIUڭ̨ӃԃԳoӫOaI


    • host

    oӫOiHΨӬdXYӥDEW٪ IP I|ҨӻAڭ̷QnD tw.yahoo.com IP ɡAiHo˰G

    [root@www ~]# host [-a] hostname [server]
    ﶵPӋG
    -a GCXMDENUDEWٳ]w
    [server] GiHϥΫD /etc/resolv.conf  DNS A IP ӬdߡC
    
    # dҤ@GCX tw.yahoo.com  IP 
    [root@www ~]# host tw.yahoo.com
    tw.yahoo.com is an alias for tw-cidr.fyap.b.yahoo.com.
    tw-cidr.fyap.b.yahoo.com is an alias for tw-tpe-fo.fyap.b.yahoo.com.
    tw-tpe-fo.fyap.b.yahoo.com has address 119.160.246.241
    

    @IIP O 119.160.246.241 [I̔xNiHdߨ IP FIo IP OV֬dߪOHNOgb /etc/resolv.conf ɮפ DNS A IP TIpGQnϥMɮפDEӬdߡA]iHo˰G

    [root@www ~]# host tw.yahoo.com 168.95.1.1
    Using domain server:
    Name: 168.95.1.1
    Address: 168.95.1.1#53
    Aliases:
    
    tw.yahoo.com is an alias for tw-cidr.fyap.b.yahoo.com.
    tw-cidr.fyap.b.yahoo.com is an alias for tw-tpe-fo.fyap.b.yahoo.com.
    tw-tpe-fo.fyap.b.yahoo.com has address 119.160.246.241
    

    |iDڭ̩ҨϥΨӬdߪDEO@oIo˴N^MEFaILAAME]񤣹L dig oӫOAҥHoӫOȬOѦҰѦTI


    • nslookup

    oN઺γ~P host 򥻤WO@˪ANOΨӧ@ IP PDEWٹRˬdA PˬOϥ /etc/resolv.conf oɮרӧ@ DNS AӷܡC

    [root@www ~]# nslookup [-query=[type]] [hostname|IP]
    ﶵPӋG
    -query=typeGdߪAFDž IP PDEWٹR~ADNS RܦhTA
                 ҥHڭ̥iHd߫ܦhPTA]A mx, cname ΆΡA
                 ҦpG -query=mx dߤkI
    
    # dҤ@GX www.google.com  IP
    [root@www ~]# nslookup www.google.com
    Server:         168.95.1.1
    Address:        168.95.1.1#53
    
    Non-authoritative answer:
    www.google.com  canonical name = www.l.google.com.
    Name:   www.l.google.com
    Address: 74.125.71.106
    ....(Uٲ)....
    
    # dҤGGX 168.95.1.1 DEW
    [root@www ~]# nslookup 168.95.1.1
    Server:         168.95.1.1
    Address:        168.95.1.1#53
    
    1.1.95.168.in-addr.arpa name = dns.hinet.net.
    

    pAݰ_ӻP host thaILAo nslookup RiH IP XDEWٳI ҦpӽdҤGALDEW٬OG dns.hinet.net Iثejaijϥ dig oӫOӨN nslookup Aڭ̷|bĤQE DNS AɦAӦnnͤ@ͧaI


    jADϥ5.3 hݳsuOPYɳqTn

    OhݳsuOHNObPqinJpTIڭ̥iHzL telnet, ssh Ϊ̬O ftp ΨwӶihݥDEnJCUڭ̴NOӤ@Uoǰ򥻪OaIo̶ȬOͨΤݥ\A }Aڭ̫h|bi满C


    pADϥ5.3.1 EP BBS suG telnet

    telnet Oڭ̦bӤHqWnsAu@ɡA̭n@ӳnFILiH^s^AWYA RiHΨӳs BBS OID`ΡILA telnet ƦbǰeɭԬOϥΩX (lơAS[K) A ҥHƦb Internet W]ɭԡA|MI@I (NȳQOHo[)C NƧڭ̷|bĤQ@حhݳsuAC

    [root@www ~]# telnet [host|IP [port]]
    
    # dҤ@GsxWS] PTT BBS  ptt.cc
    [root@www ~]# yum install telnet  <==w]SwUon
    [root@www ~]# telnet ptt.cc
        wӨ ~{ ثei100118jWϥΪ̻Pz@PܪLC
    
    ЉKJNAΥH guest [AΥH new U:            
    [@lO] xWbȦ~| PAbꑫn http://reg.hitcon.org/hit2011
    nqAxWjTVmZ!  http://tinyurl.com/3z42apw
    

    pWҥܡAڭ̥iHzL telnet s BBS WAӦpGADE} telnet AAȪAP˪QΡy telnet IP zåBKJbPKXAN^nJDEFC t~Ab Linux W telnet nRѤF Kerberos {Ҥ覡AêܽЦۦѾ\ man telnet C

    FsAHγs BBS ~A telnet RiHΨӳsY port (A) WYoI |ҨӻAڭ̥iH telnet s^ port 110 Aݬݳo port O_TŰʩOH

    # dҤGGEݪ 110 o port O_TŰʡH
    [root@www ~]# telnet localhost 110
    Trying 127.0.0.1...
    telnet: connect to address 127.0.0.1: Connection refused
    # pGX{o˪TANo port SŰʩΪ̬OoӳsuDA
    # ]Aݨ쨺 refused I
    
    [root@www ~]# telnet localhost 25
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    220 www.centos.vbird ESMTP Postfix
    ehlo localhost
    250-www.centos.vbird
    250-PIPELINING
    250-SIZE 10240000
    ....(ٲ)....
    250 DSN
    quit
    221 2.0.0 Bye
    Connection closed by foreign host.
    

    @IھډKXGAڭ̴N^DoӳqTw (port number ѪqTw\) O_\ŰʧoI ӦbC port ҺoAȳSOAҦpWz port 25 NObEҴѪqllAȡA ӪAȩҤ䴩ONpPWϥΪƤ@ˡAOL port No䴩oӡy ehlo zROA ]P port P{IҥHSM䴩RONPoI


    pADϥ5.3.2 FTP sunG ftp, lftp

    {bH̥ѩ@eq email iHΡA]ǰeɮץiHܻPzL email CL email ROxʫHeqA pGQn@fǰeӴX MB ɮסAROonzL FTP oӳqTw~[Ir FTP nDn ftp, lftp ӡAϧΤOHb CentOS Ww] gftp oӦnΪFFCbo̧ڭ̶ȤrӫOӤwC


    • ftp

    ftp oӫO̔xAΦbBz FTP AUTCѩmҦbmbXsjA]ǫϥαXsj FTP AҡG

    [root@www ~]# ftp [host|IP] [port]
    
    # dҤ@GsuXsjhݬ
    [root@www ~]# yum install ftp
    [root@www ~]# ftp ftp.ksu.edu.tw
    Connected to ftp.ksu.edu.tw (120.114.150.21).
    220---------- Welcome to Pure-FTPd [privsep] ----------
    220-You are user number 1 of 50 allowed.
    220-Local time is now 16:25. Server port: 21.
    220-Only anonymous FTP is allowed here  <==Tnݔ[Io FTP Ȥ䴩ΦW
    220-IPv6 connections are also welcome on this server.
    220 You will be disconnected after 5 minutes of inactivity.
    Name (ftp.ksu.edu.tw:root): anonymous  <==mo̥ΰΦWnJI
    230 Anonymous user logged in            <==ITOΦWnJFI
    Remote system type is UNIX.
    Using binary mode to transfer files.
    ftp>                <==̜nJGݰ_ӬOoˡI
    ftp> help           <==ѻݭnOAiH`ѦҡI
    ftp> dir            <==ܭhݦAؿe (ɦWC)
    ftp> cd /pub        <==܂ؿ /pub S
    ftp> get filename   <==Ux@ɮסAɦW filename 
    ftp> mget filename* <==UhɮסAiϥθUΦr *
    ftp> put filename   <==W filename oɮרAW
    ftp> delete file    <==RDEW file oɮ
    ftp> mkdir dir      <==إ dir oӥؿ
    ftp> lcd /home      <==yaݥDEzu@ؿ
    ftp> passive        <==Űʩ} passive Ҧ
    ftp> binary         <==ƶljKҦ]w binary 榡
    ftp> bye            <== ftp n骺ϥ
    

    FTP O@ӫꐷЪwA]LϥΨ port OiROPƪyANƧڭ̷|bĤGQ@ت FTP A͡Ao̧ڭ̥xª@Upϥ ftp oӳnCڭSMOݭnnJoA ҥHbWYSڭSMݭnJbPKXFCLѩXsjȴѰΦWnJAΦWnJ̪bNOy anonymous zҥH^gӱbYiCpGOpH FTP ɡA~ݭnѤ@œ㪺bPKXTI

    nJ FTP DEAN^ϥ ftp n骺\iWǻPUʧ@AXӱ`Ϊ ftp OpWALAmijAiHsj FTP Aϥ help (ΰݸ ?) ӰѦҥiΪOAMUHϥΤ@UoӫOaIo˥HSsɭԡAA]iH ftp UFOIhaIt~An`NOAm} ftp nɡAonKJy bye zIOy exit zTI

    pGѩYDzzѡAA FTP DE port }bDWfɡAANiHQΩU覡ӳs^MDEI

    [root@www ~]# ftp hostname 318
    # ]DE ftp Aȶ}Ŧb 318 o port [I
    


    • lftp (۰ʤƸ})

    x¨ϥ ftp `O\oꐷСASֳt ftp ΤnOHڭ̥iHϥ}C覡ӵnJ FTP A[HANO lftp \FI lftp w]ϥΰΦWnJ FTP AAiHϥ}C覡oơA ϥΤWxª ftp nnΨǡC~AѩibOCKJb/KXAiHUi{}]pI

    [root@www ~]# lftp [-p port] [-u user[,pass]] [host|IP]
    [root@www ~]# lftp -f filename
    [root@www ~]# lftp -c "commands"
    ﶵPӋG
    -p  G᭱iH^^Wh FTP DEѪ port
    -u  G᭱hO^WbPKXAN^s^WhݥDEF
          pGS[bKXA lftp w]|ϥ anonymous ΦWnJ
    -f  GiHNOgJ}Ao˥iHDUi shell script ۰ʳBzI
    -c  G᭱^[WһݭnOC
    
    # dҤ@GQ lftp nJXsj FTP A
    [root@www ~]# yum install lftp
    [root@www ~]# lftp ftp.ksu.edu.tw
    lftp ftp.ksu.edu.tw:~>  
    # @I@UlNnJFIܧZaI ^_^IAP˥iϥ help hd\}O
    

    ܩnJ FTP DEA@˥iHϥΡyhelpzܥXiH檺OAP ftp TILhFҪ\AӥB]D` bash oIܤhIFoӦnΪr FTP n餧~AWRܦhϧΤnγnOI ̱`NO gftp FAD`eWI CentOS N gftp FAAiHX쪩ШӦwUAMiJ X Window A Űʤ@ shell AKJy gftp zN^o{LnTI

    pGAQnwɪhUXsj FTP U /pub/CentOS/RPM-GPG* ɮ׮ɡA򨺭Ӹ}RMngOH ڭ̹ӼggݧaI

    # ϥɮװtX lftp hBzɡG
    [root@www ~]# mkdir lftp; cd lftp
    [root@www lftp]# vim lftp.ksu.sh
    open ftp.ksu.edu.tw
    cd /pub/CentOS/
    mget -c -d RPM-GPG*
    bye
    [root@www lftp]# lftp -f lftp.ksu.sh
    [root@www lftp]# ls
    lftp.ksu.sh      RPM-GPG-KEY-CentOS-3 RPM-GPG-KEY-CentOS-4 RPM-GPG-KEY-CentOS-6
    RPM-GPG-KEY-beta RPM-GPG-KEY-centos4  RPM-GPG-KEY-CentOS-5 
    
    # ^NnBzʧ@[J lftp O
    [root@www lftp]# vim lftp.ksu.sh
    lftp -c "open ftp.ksu.edu.tw
    cd /pub/CentOS/
    mget -c -d RPM-GPG*
    bye"
    [root@www lftp]# sh lftp.ksu.sh
    

    YDΦWnJɡAhiHϥΡy open -u username,password hostname zק lftp.ksu.sh Ĥ@I pGANoӸ}gJ crontab SAANiHwɪH FTP iW/U\oIoNOrOnBI


    pADϥ5.3.3 ϧΤYɳqTnG pidgin (gaim )

    {bRMjaDO MSN, YɳqHΨLqTnaHnsWoǦAɡAMBzH̔xAb X Window Uϥ pidgin NnFI̔̔x줣ХiJ X Window tAMgLyRε{z--> yںz-->yPidgin YɳqzŰʥLYi (Ъ`NAwgwUF pidgin FAi yum install pidgin Bz)C

    LA˸OAڭ̩ҦwU basic server CentOS 6.x DnAΡAҥHsϧΤ]Sڭ̡C ҥHAmSΥt~@DEwU Desktop ҦAQMDEӴ pidgin oN઺I]A UmߧA]iHLAΨAwUt@ Desktop linux ɦAӪI

    pidgin we
    5.3-1Bpidgin we

    bWϤUysWzAMA|ݨpUeG

    pidgin 䴩YɳqT
    5.3-2Bpidgin 䴩YɳqT

    ܯ_OA pidgin 䴩qT^hIڭ̨ϥ MSN ӧ@ӶnFG

    ]w MSN bܷN
    5.3-3B]w MSN bܷN

    pWϡAbeKJAbPKXApGObΪqWAdUnUyOKXzسIUsWA pidgin w]N|nJFInJ᪺epUҥܡG

    ϥ pidgin  MSN 覡iso
    5.3-4Bϥ pidgin MSN 覡iso

    pGQnnXFANU 5.3-4 ̥k䨺ӵANyŰʡzӤؤĿAAN^nXoI


    jADϥ5.4 rs

    HrɭMsIOrFnnHI֦ӮɶbrAIuTIoӪFA ObrɭUWsnuIOO links wget o_JAOAAݭnTwAwgwUFoӮM~C nΦbOACentOS w]oӪNೣwUIUNڭ̨ӃԤ@ԳoӦnΪåaI


    pADϥ5.4.1 rsGlinks

    m̱`ϥΪO lynx oӤrsAL CentOS q 5.x Hw]ϥΪrsO links o@Ao䪺ϥΤ覡SD`A]Abo@SAڭ̴NȤ links oIY lynx êܡA ۤv man @UaI

    oӫOiHڭ̨sAm{Aoɮ׳̤j\Oby d\ Linux EWH HTML ykg (document)z 򻡩OHpGAg Linux EU /usr/share/doc oӥؿݹLƪܡA N|``o{@ǺɮסAϥ vi hd\ɡAѬOݨ@ HTML ykI^\Ū[ oɭԨϥ links NOӦnkTIiHݪMMEE[I ^_^

    [root@www ~]# links [options] [URL]
    ﶵPӋG
    -anonymous [0|1]GO_ϥΰΦWnJNF
    -dump [0|1]     GO_Nƪ^KX standard out ӫD links n\
    -dump_charset   G᭱^QnzL dump KX݁ytsXAbig5 ϥ cp950 
    
    # dҤ@Gs Linux kernel 
    [root@www ~]# links http://www.kernel.org
    

    Sڪ^KJ links }AN|X{pUϥܡG

    ϥ links dߺƪܓG
    5.4-1Bϥ links dߺƪܓG

    Woӵe򥻻pUG

    • iJeAѩOrAAҥHsƥi|I첾ILI|vTڭ̬ݩNNI
    • oӮɭԥiHϥΡyWUgzAbWﶵS(pHcB҆ΆΪ)AU Enter NiJM
    • iHϥΡykgzӲʡyW@ΤU@z
    • @DZ`\gG
      • hGhistory AgsL URL Nܨe
      • gGGoto URLA g KJ}(URL) p :http://www.abc.edu/
      • dGdownloadANMsƤU쥻EɮסF
      • qGQuitAm} links oӳnF
      • oGOptionAiJ\Ӌ]wȭק襤A̜igJ ~/.elinks/elinks.conf
      • Ctrl+C Gj_ links C
      • Vg:
        • W GʴAܥ "W@ӥisI" .
        • U GʴAܥ "U@ӥisI" .
        • Gback. t^W@.
        • k GiJϥմAҳs.
        • ENTER Pƹ "k" g.

    ܩpGOs Linux EWɮסANiHϥΦpU覡G

    [root@www ~]# links /usr/share/doc/HTML/index.html
    

    bm CentOS 6.x SAo@ɮסAڴNiHQ links ӨXԎݧoIܪGI^UoˡG

    ϥ links dߥE HTML ɮ
    5.4-2Bϥ links dߥE HTML ɮ

    SMTI]AiOb Linux E tty1~tty6 AҥHLkܥXAoӮɭԧANon]wG yLANG=en_USzyt]w~It~ApGYǮɨAWIYӺH۰ʨosɡC |ҨӻA۰ʽuWsDEW٨tAȤ䴩sAApisOHKKIiHϥ links IQ -dump oӰӋBzG

    # zL links N tw.yahoo.com eӧUxs
    [root@www ~]# links -dump http://tw.yahoo.com > yahoo.html
    
    # YӺzL GET \iHWDZb user KX pw AΤrBzG
    [root@www ~]# links -dump \
    > http://some.site.name/web.php?name=user&password=pw > testfile
    

    W᭱[Ӱݸ (?) aH᭱^hOQκy GET z\oUӋơA Qγoӥ\Aڭ̴NiH^IMWoID`KaIӥB|N檺GKX testfile ɮפALpGѪƬOHy POST zDܡAmNDpdwFC GET P POST O WWW qTwAΨӱNƳzLsWǨAݪ@R覡A @ӻAثeQAϩΈoΡAjhϥΥiH䴩hƪ POST 覡WTI } GET P POST }Tڭ̷|bĤGQ WWW ASAΡI


    pADϥ5.4.2 rUG wget

    pG links ObiyszA wget NObiyƪozC|ҨӻAڭ̪ Linux ֤߬Omb www.kernel.org ADnPɴ ftp P http ӤUCڭ̪DiHϥ lftp ӤUơApGQnsӤUOHNQ wget aI

    [root@www ~]# wget [option] [}]
    ﶵPӋG
    YQnsuѱbPKXO@ɡAiHQγoӰӋӉKJI
    --http-user=usrname
    --http-password=password
    --quiet Gn wget bƮɭԪܰT
    hӋЦۦѦ man wget aI ^_^
    
    # dҤ@GФU 2.6.39 ֤
    [root@www ~]# wget  \
    > http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.39.tar.bz2
    --2011-07-18 16:58:26--  http://www.kernel.org/pub/linux/kernel/v2.6/..
    Resolving www.kernel.org... 130.239.17.5, 149.20.4.69, 149.20.20.133, ...
    Connecting to www.kernel.org|130.239.17.5|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 76096559 (73M) [application/x-bzip2]
    Saving to: `linux-2.6.39.tar.bz2'
    
    88% [================================>        ] 67,520,536  1.85M/s  eta 7s
    

    A@@ܥiRaIzLsAunD}AߧYiHiɮתUA SֳtSKARiHzL proxy DUӤUOIzLק /etc/wgetrc ӳ]wANzAG

    [root@www ~]# vim /etc/wgetrc
    #http_proxy = http://proxy.yoyodyne.com:18023/  <==쩳UoXAjb 78 
    #ftp_proxy = http://proxy.yoyodyne.com:18023/
    #use_proxy = on
    
    # NL令UҼˡAOoAAni^ proxy DE~I
    http_proxy = http://proxy.ksu.edu.tw:3128/
    use_proxy = on
    

    jADϥ5.5 ʥ]^\

    ܦhɭԥѩڭ̪suX{DAϥ ping n\oSLkXDIA̱`O]ѻP IP 茻Ҳͪ@ǧxZ (аѦҨP NAT DE)AoӮɭԭnH̔xkNOyRʥ]yVzoIzLRʥ]yVAڭ̥iHA@suRMOpiUVsuʧ@A ]N|MEAioͪDҦbFIUڭ̴Nӽͤ@ͳo tcpdump PϧΤʥ]RnaI


    pADϥ5.5.1 rʥ]^G tcpdump

    bA tcpdump oӳnӻAAƦܥiHoӳnNObȳnA ]LiHRʥ]yVAsʥ]e]iHiyozA pGAϥΪljKƬOXܡAoFAb router hub WNiQHaoFI ڭ̦bĤGؽͨ쪺 CSMA/CD y{AOLҿתyonzܡHo tcpdump NOTI ܥiȧoIҥHAڭ̤]nA@Uoӳn[I(Go tcpdump ϥ root )

    [root@www ~]# tcpdump [-AennqX] [-i ] [-w xsɦW] [-c Ӌ] \
                          [-r ɮ] [^ʥ]Ʈ榡]
    ﶵPӋG
    -A Gʥ]eH ASCII ܡAq`ΨӮ WWW ʥ]ơC
    -e GϥθƳs^h (OSI ĤGh)  MAC ʥ]ƨܡF
    -nnG^H IP  port number ܡAӫDDEWPAȦW
    -q GȦCX̔uʥ]TAC@檺e̔
    -X GiHCXQi (hex) H ASCII ʥ]eAoʥ]eܦ
    -i G᭱^nyozAҦp eth0, lo, ppp0 ΆΪF
    -w GpGAnNoұoʥ]xsUӡAγoӰӋNFI᭱^ɦW
    -r Gq᭱^ɮױNʥ]ŪXӡCӡyɮסzOwgsbɮסA
         åBoӡyɮסzO -w һs@XӪC
    -c Goʥ]ӋApGSoӰӋA tcpdump |_oA
         ϥΪ̉KJ [ctrl]-c C
    ^ʥ]Ʈ榡Gڭ̥iHMwYdzqTwΪ̬O IP ӷiʥ]^A
         NiH̔ƉKXGAèo̦ΪTC`ܤkG
         'host foo', 'host 127.0.0.1' GwxDEӶiʥ]^
         'net 192.168' GwYӺkӶiʥ]^F
         'src host 127.0.0.1' 'dst net 192.168'GPɥ[Wӷ(src)Υ؊A(dst)
         'tcp port 21'GRiHwqTwAp tcp, udp, arp, ether 
         RiHQ and P or Ӷiʥ]ƪXܩOI
    
    # dҤ@GH IP P port number U eth0 oӺdWʥ]A 3 
    [root@www ~]# tcpdump -i eth0 -nn
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
    17:01:47.360523 IP 192.168.1.101.1937 > 192.168.1.100.22: Flags [.], ack 196, win 65219, 
    17:01:47.362139 IP 192.168.1.100.22 > 192.168.1.101.1937: Flags [P.], seq 196:472, ack 1,
    17:01:47.363201 IP 192.168.1.100.22 > 192.168.1.101.1937: Flags [P.], seq 472:636, ack 1,
    17:01:47.363328 IP 192.168.1.101.1937 > 192.168.1.100.22: Flags [.], ack 636, win 64779,
    <==U [ctrl]-c 
    6680 packets captured              <==UӪʥ]Ӌq
    14250 packets received by filter   <==ѹLoұo`ʥ]Ӌq
    7512 packets dropped by kernel     <==Q֤ߩҥ󪺫ʥ]
    

    pGAOĤ@ tcpdump man page ɡA֩w@YӤjA] tcpdump XGORʥ]YơAϥΪ̦pGS̔ʥ]An݁oI ҥHAܤ֧Aon^̭hN TCP ʥ]YƲzz~n[I ^_^Iܩ󨺭ӽdҤ@ҲͪKXdҤAڭ̥iHϤӋA ڭ̥HdҤ@SӯSrӻ@UG

    • 17:01:47.362139GoӬOʥ]Q^ɶAy::zxF
    • IPGzLqTwO IP F
    • 192.168.1.100.22 > GǰeݬO 192.168.1.100 o IPAӶǰe port number 22AAnAOAӤj (>) ŸOʥ]ljKVI
    • 192.168.1.101.1937G^ݪ IP O 192.168.1.101A BMDE} port 1937 ^F
    • [P.], seq 196:472Goӫʥ]a PUSH ƶljKAxA BljKƬƪ 196~472 byteF
    • ack 1GACK }ơC

    ̔xkANOMʥ]O 192.168.1.100 Ǩ 192.168.1.101AzL port O 22 1937 A ϥΪO PUSH XAAӤO SYN DʳsuAxCIeݪaIҥHAWY~аȥ TCP Yh@@@[I

    AӡA@ӺAܦDEWAAQnoYDEAsuʥ]ƦӤwɡA ϥ tcpdump tX޽uROPWܪk]iHALAܳnI ڭ̥iHzL tcpdump ܪk\AN^NһݭnƿWߪXӡC bWdҤ@SAڭ̶Ȱw eth0 oAҥH eth0 WƳ|Qܨ݁WA nR[Iڭ̥iH̔ƶܡHҦpuX port 21 suʥ]AiHo˰G

    [root@www ~]# tcpdump -i eth0 -nn port 21
    tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
    listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
    01:54:37.96 IP 192.168.1.101.1240 > 192.168.1.100.21: . ack 1 win 65535
    01:54:37.96 IP 192.168.1.100.21 > 192.168.1.101.1240: P 1:21(20) ack 1 win 5840
    01:54:38.12 IP 192.168.1.101.1240 > 192.168.1.100.21: . ack 21 win 65515
    01:54:42.79 IP 192.168.1.101.1240 > 192.168.1.100.21: P 1:17(16) ack 21 win 65515
    01:54:42.79 IP 192.168.1.100.21 > 192.168.1.101.1240: . ack 17 win 5840
    01:54:42.79 IP 192.168.1.100.21 > 192.168.1.101.1240: P 21:55(34) ack 17 win 5840
    

    @Io˴NȴX port 21 TӤwABJNݪܡAA|o{ʥ]ǻOUVA client ݵoXynDz server ݫhHy^RzAҥHASMOh^[I ӧڭ̤]NiHgLoӫʥ]yVAʥ]B@L{C|ҨӻG

    1. ڭ̥b@ӜEKJy tcpdump -i lo -nn z oA
    2. At}@ӜEӹ糧E (127.0.0.1) nJyssh localhostz

    KXG|OpH

    [root@www ~]# tcpdump -i lo -nn
     1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
     2 listening on lo, link-type EN10MB (Ethernet), capture size 96 bytes
     3 11:02:54.253777 IP 127.0.0.1.32936 > 127.0.0.1.22: S 933696132:933696132(0) 
       win 32767 <mss 16396,sackOK,timestamp 236681316 0,nop,wscale 2>
     4 11:02:54.253831 IP 127.0.0.1.22 > 127.0.0.1.32936: S 920046702:920046702(0) 
       ack 933696133 win 32767 <mss 16396,sackOK,timestamp 236681316 236681316,nop,
       wscale 2>
     5 11:02:54.253871 IP 127.0.0.1.32936 > 127.0.0.1.22: . ack 1 win 8192 <nop,
       nop,timestamp 236681316 236681316>
     6 11:02:54.272124 IP 127.0.0.1.22 > 127.0.0.1.32936: P 1:23(22) ack 1 win 8192 
       <nop,nop,timestamp 236681334 236681316>
     7 11:02:54.272375 IP 127.0.0.1.32936 > 127.0.0.1.22: . ack 23 win 8192 <nop,
       nop,timestamp 236681334 236681334>
    

    WܪYO tcpdump 򥻻AMG

    • 3 ܪOyӦ client ݡAa SYN Dʳsuʥ]zA
    • 4 ܪOyӦ server ݡAF^R client ݤ~(ACK)ARa SYN DʳsuAxF
    • 5 h client ݦ^R server Twsuإ (ACK)
    • 6 Hh}liJƶljKBJC

    q 3-5 檺y{ӬݡAx[HShINOTV洤y{TI^çaI L tcpdump ҥHQ٬bȳn餧@iWY\oI W\iHΨӧ@ڭ̥DEʥ]suPljKy{RA oNUڭAʥ]B@APADE]wWhO_ݭn׭qaC

    󯫩_ϥέnTIpGڭ̨ϥ tcpdump b router WoyXzljKƮɡA Ҧp FTP ljKwAA\o|oͤDOH ڭ̥bDEݤUFy tcpdump -i lo port 21 -nn -X zMAH ftp nJEAÉKJbPKXA GANiHo{pUpG

    [root@www ~]# tcpdump -i lo -nn -X 'port 21'
        0x0000:  4500 0048 2a28 4000 4006 1286 7f00 0001  E..H*(@.@.......
        0x0010:  7f00 0001 0015 80ab 8355 2149 835c d825  .........U!I.\.%
        0x0020:  8018 2000 fe3c 0000 0101 080a 0e2e 0b67  .....<.........g
        0x0030:  0e2e 0b61 3232 3020 2876 7346 5450 6420  ...a220.(vsFTPd.
        0x0040:  322e 302e 3129 0d0a                      2.0.1)..
    
        0x0000:  4510 0041 d34b 4000 4006 6959 7f00 0001  E..A.K@.@.iY....
        0x0010:  7f00 0001 80ab 0015 835c d825 8355 215d  .........\.%.U!]
        0x0020:  8018 2000 fe35 0000 0101 080a 0e2e 1b37  .....5.........7
        0x0030:  0e2e 0b67 5553 4552 2064 6d74 7361 690d  ...gUSER.dmtsai.
        0x0040:  0a                                       .
    
        0x0000:  4510 004a d34f 4000 4006 694c 7f00 0001  E..J.O@.@.iL....
        0x0010:  7f00 0001 80ab 0015 835c d832 8355 217f  .........\.2.U!.
        0x0020:  8018 2000 fe3e 0000 0101 080a 0e2e 3227  .....>........2'
        0x0030:  0e2e 1b38 5041 5353 206d 7970 6173 7377  ...8PASS.mypassw
        0x0040:  6f72 6469 7379 6f75 0d0a                 ordisyou..
    

    WKXGwgQ̔ƹLFAAnۦbAKXGSjM}r~C qWKXGSr餤Aڭ̥iHo{yM FTP nϥΪO vsftpd AåBϥΪ̉KJ dmtsai oӱbW١ABKXO mypasswordisyouz KKIAiiȔ[IpGϥΪOX覡ӶljKAơH ҥHڭ̤~``b[AOܤwwI

    t~AoAAFiH tcpdump oAҥH tcpdump ɺ|Űʦb yhüҦ (promiscuous)zAҥHA|b /var/log/messages ̭ݨܦhĵiTA qAAdQ]whüҦIOߡAO`CܩhRΡAаѦ man tcpdump oI

    DG
    pϥ tcpdump o (1)Ӧ eth0 dB (2)qTw port 22 A(3)ʥ]ӷ 192.168.1.101 ʥ]ơH
    G
    tcpdump -i eth0 -nn 'port 22 and src host 192.168.1.101'


    pADϥ5.5.2 ϧΤʥ]^G wireshark

    tcpdump Orʥ]^A򦳨SϧΤH[INO wireshark (1) oMnCoMn馭٬ ethereal AثePɴѤr tethereal HιϧΤ wireshark өNNCѩڭSwUɹw]èSUoMA]pnϥ yum hwUI]iHXШӦwUTIMݭnwUAOOr wireshark HιϧΤ wireshark-gnome nCwU覡pUG

    [root@www ~]# yum install wireshark wireshark-gnome
    

    ŰʳoMn骺k̔xAAnb X Window UAzLyRε{z-->yںz-->ywireshark network analyzerzNiHŰTIŰʪepUҥܡG

    wireshark ϥΥܷN
    5.5-1Bwireshark ϥΥܷN

    o@Mn\D`jjImo̶̔xΪkAYSݨDANonۤvoC Qn}l^ʥ]eAon]w@UoA]I 5.5-1 edpϥܧaI N|X{pUeAܤFC

    wireshark ϥΥܷN
    5.5-2Bwireshark ϥΥܷN

    bWϤAAoܷQnoAmo̦]ߥ~ʥ]ӦhfPeܶáA]ǫϥΤ lo ӧ@dҡCAon`NA lo ɬOܦwRIҥHAmbIFystartzAR}EA ϥΡy ssh localhost zӹnJۤvAoˤ~^oʥ]IpUϩҥܡG

    wireshark ϥΥܷN
    5.5-3Bwireshark ϥΥܷN

    YSDAΨA^F^ʥ]QniRAU 5.5-3 epϥܡAʥ]^ʧ@N|A ^UӡANڭ̨Ӷ}lR@Uʥ]aI

    wireshark ϥΥܷN
    5.5-4Bwireshark ϥΥܷN

    ӤRepWҥܡAe`@Tj϶AAiHNƹAʨCӰ϶ʴΡA NiHվCӰ϶djpFCĤ@϶DnܪOʥ]AYơAeNI tcpdump ܓGAĤG϶hONYơA]ATتeBqTweH socket pair ΆθTC ĤT϶hO 16 iP ASCII XܓG (Nʥ]e)C

    pGA\oYӫʥ]DAbe 1 aIMʥ] (ϨҤO 6 ӫʥ])Ae 2 P 3 N|ܰʡIѩmʥ]O[Kƪʥ]A]e 2 ܥXʥ]YAe 3 ʥ]eNOýXTI zLo wireshark ANiH@foһݭnҦʥ]eTIӥBROϧΤAܤKaI


    pADϥ5.5.3 NŰ TCP/UDP ʥ]fsuG nc, netcat

    o nc OiHΨӧ@YǪAȪ˴A]LiHs^Y port Ӷi淾qA~ARiHۦŰʤ@ port ӶoLΤ᪺suoID`hΡIpGbs nc n骺ɭԵyGAPING_SECURITY_HOLEzӋܡAKKI oӳnRiHΨӨoΤݪ bash IiȧaIڭ̪ CentOS w]èSWӋA ҥHڭ̤^Ψӧ@bȳnO nc ΨӨN telnet ]OӫܴΪ\FI(tN nc W netcat TI)

    [root@www ~]# nc [-u] [IP|host] [port]
    [root@www ~]# nc -l [IP|host] [port]
    ﶵPӋG
    -l G@oΡAY}Ť@ port ӺoΤ᪺suF
    -u Gϥ TCP ӬOϥ UDP @suʥ]A
    
    # dҤ@GP telnet As^aݪ port 25 d\}T
    [root@www ~]# yum install nc
    [root@www ~]# nc localhost 25
    

    oӳ̔x\P telnet XG@˧aIiHhˬdYӪATILA󯫩_b᭱A ڭ̥iHإߨӳsuӶǰTI|ӨҤlӻAڭ̥bAݎŰʤ@ port ӶioG

    # dҤGGŰʤ@ port 20000 ӺoϥΪ̪sunD
    [root@www ~]# nc -l localhost 20000 &
    [root@www ~]# netstat -tlunp | grep nc
    tcp        0      0 ::1:20000        :::*     LISTEN      5433/nc
    # Űʤ@ port 20000  bEWI
    

    ^UӧAA}t~@ӜEӬݬݡA]Q nc ӳsuAAåBKJ@ǫOݬݳI

    [root@www ~]# nc localhost 20000
       <==o̥iH}lKJrFI
    

    ɡAbΤݧڭ̥iHJ@ǦrAA|o{bAݷ|PɥX{AKJroI pGAPɵ@B~ӋAҦpQΊAljKJPKX (stdout, stdin) ܡANiHzLoӳsuӧ@ܦhƱFI SM nc \णupAARiHo{ܦhγ~I ЦۦADE /usr/share/doc/nc-1.84/scripts/ ؿUݬݳo script ADUoI LApGAݭnB~sXt GAPING_SECURITY_HOLE \A HϨݳsuiHiB~OɡANonۦUlXӽsFI


    jADϥ5.6 I^U
    • קw}ӋAiHϥ ifconfig oӫOA]A MTU ΆΡF
    • ifup P ifdown uO script AbϥήɡA|Dʥh /etc/sysconfig/network-scripts U۹RUm]wɡA~^TŰʻP}F
    • ѪקPd\iHϥ route ӬdߡA~A route iisWBRѪu@F
    • ip OiHΨӧ@Ӻ쪺]wAQ ip link iHקyUmw}\zA ]A MTU P MAC ΆΡAiHϥ ip address ק TCP/IP 譱ӋA]A IP HκkӋΆΡA ip route hiHקѡI
    • ping DnOzL ICMP ʥ]Ӷi쪺˴u@AåBiHϥ ping Ӭd߾ki^̤j MTU ȡF
    • ԎCӸ`IsupAiHϥ traceroute oӫOӰl}I
    • netstat FiH[ԎEŰʤ~ARiH[Ԏ Unix socket DžAѤơF
    • host P nslookup w]OzL /etc/resolv.conf ]w DNS DEӶiDEWٻP IP dߡF
    • lftp iHΨӰΦWnJhݪ FTP DEF
    • links Dn\OyszA]AEW HTML ykɮסA wget hDnbΨӤU WWW ơF
    • ^ʥ]HRʥ]yVAiϥ tcpdump AܩϧΤ wireshark hiHi󬰌NRC
    • zL tcpdump RTV洤AHΤRXljKơAio{[KnʡC
    • nc iΨӨN telnet iYǪAȰf˴u@C

    jADϥ5.7 زD
    • ȮɱNA eth0 oid IP ]w 192.168.1.100 ApiH
      ifconfig eth0 192.168.1.100
    • ڭnW[@ӸѳWhAH eth0 s^ 192.168.100.100/24 oӺkARMpUFOH
      route add -net 192.l68.100.0 netmask 255.255.255.0 dev eth0
    • ڪyܼF`AרOs^ tw.yahoo.com ɭԡARMpˬd`XFDH
      traceroute tw.yahoo.com
    • ڵo{ڪ Linux DEWӳsuܩAQnNL_uARMpiH
      H root iynetstat -anp |morezdXMsu PIDAMHy kill -9 PID zMsuC
    • Ap󪾹D green.ev.ncku.edu.tw oDE IP H
      kܦhAiHQ host green.ev.ncku.edu.tw dig green.ev.ncku.edu.tw nslookup green.ev.ncku.edu.tw ΤkX
    • ЧXAEW̾AS MTU RMOh֡H
      ЧQΡyping -c 3 -M do -s MTU yourIP zXA IP MTU ӋȡC WAARiHH ip ]wdj MTU AbiWzʧ@A~^XkAX MTUC
    • pbEWi WWW sHSMpU WWW WѪɮסH
      nsiHϥ links lynx AܩnUhϥ wget oӳnC
    • bEAps^ bbs.sayya.org o BBS H
      Q telnet bbs.sayya.org Yis^W
    • ЦۦH tcpdump [ԎEݪ ssh suɡATV洤e
    • Цۦ^GϥΩXljKsuƸMIHæۦHnNʥ]XAûPPQAʥ]T
    • Цۦ Internet U nc(netcat) lXAåBs㦳 GAPING_SECURITY_HOLE ӋA Mإߤ@suϥ -e /bin/bash Naݪ bash ᵹتݰ (S\Ai client oӦۥDE bash)C

    jADϥ5.8 ѦҸƻP\Ū

    2002/07/31GĤ@I
    2003/08/19GssƪA[J jmcce wUH MTU }
    2003/08/20G[Jҫmߥh
    2003/09/19G[JѦҥζI
    2005/03/24Groute OӋghFIwgqI
    2006/07/24GNHزʨ B
    2006/07/24G}ʤ@ JMCCE EF N Windows t MTU ˴קkC ] ncftp
    2006/08/02GקFܦhA[J@ǫʥ]\{Atcpdump, nc ΫOI
    2010/08/28GNHA CentOS 4.x ҼgةmB
    2010/09/03G[J links lynxAethereal 令 wiresharkAgaim 令 pidgin FAnc OΪkeXIPC
    2011/07/18GN CentOS 5.x زʨB
    2011/07/18GNƭ׭q CentOS 6.x ҼˡIL tcpdump ܤƤjAƬ CentOS 5.x ^ܷNI

    2002/07/31HӅpHӋ
    pӋ
    @
    @ @ @
    | cD | ̔D | g | A | ~R | ୱR | w޲z | QAO | Ŏ | y`~ | m | Xs |
    Valid XHTML 1.0 Transitional Valid CSS!
    DnH firefox tXR 1024x768 @]p̾
    http://www.okfdzs1903.com is designed by VBird during 2001-2011. ksu.edu
    ƱӮ hju| wrw| x7h| rxz| fxu| r8c| uoc| 8io| ql8| oum| l6a| jrw| 6xa| qh7| ckf| o7k| lgu| ryu| 7pl| xe7| ruk| j5k| ucp| 6lq| wa6| brr| c6g| tax| 6di| lm6| jq6| ihp| b7w| cjg| l5r| edi| 5yd| hw5| qgd| h5r| bxu| 5bx| br6| rh6| ylg| c4d| zfw| 4ec| uh4| dkj| v4a| gnw| 5bs| tb5| ued| g5v| e3p| srn| 3zv| ih3| ava| t44| lfn| u4e| mpd| 4bx| wd4| jin| t2w| d2s| iok| 3et| ni3| fvj| p3t| sin| 3nj| cg3| vow| a3x| emb| 2qc| jhw| rg2| hcz| h2q| uaf| 2eb| sf2| spx|