• m Linux pЉ|
    osGAзR firefox s
    | cD | ̔D | g | A | ~R | ୱR | w޲z | QAO | Ŏ | y`~ | m | Xs |
    @ @ @
    @
    ̪sG2011/07/27
    Q^RpG(1)pGAbu@xϥΪO۰OqAӥB``naۧA۰OqB]A ĥ|ءBsW Internet |o{AzI ڪdӋn``ק[IӥBAC@ӷsaANoݲMEMaӋ~IuOꐷСC (2)Aq``XȩζQȨ{A]L̤]aӓ۹qAҥH]o``]ӧAݺӋ~]wLqC zIoRp|AQaHoӮɭԡAʺADE]ww (DHCP) iNjjWγTIDHCP oӪAȥiH۰ʪt IP P}ӋΤݡAӴѥΤݦ۰ʥHAѪӋӳ]wL̪C p@ӡAϥΪ̥unNۤv۹q]wng DHCP wӨoӋA@AWuAI}WNiHɨ Internet ATIܤKaIҥHo@@@oӦnΪwI


    jADϥ12.1 DHCP B@z

    biJ DHCP (Dynamic Host Configuration Protocol) A]weAڭ̥ӻ{Ѥ@U DHCP oӨwaIRAݭnAOAڭ̬O_y@wzo]w DHCP oӦAOHo̳ݭnjM@UyI


    pADϥ12.1.1 DHCP Aγ~

    b}l DHCP eAڭ̥ӽƲߤ@UebĤGغ̭쪺XӺӋaI n]wn@ӺAϹqiHQsW Internet AAq̭@wnUXӺӋ~AOOG

    • IP, netmask, network, broadcast, gateway, DNS IP

    䤤A IP, netmask, network, broadcast P gateway iHb /etc/sysconfig/network-scripts/ifcfg-eth[0-n] oɮ׸̭]wADNS A}hOb /etc/resolv.conf Y]wCunoXӶس]wTAqRMNSDiHWFI ҥHAAa̭ 3, 4 qAAiHʪӳ]wnAһݭnӋA MQ NAT A\ANiHjnj\sW Internet FIuOh ^_^AOܡH

    nFA{bڭ̂@Ӥj@ǨǪaI]AOձJ٪޲zAҺ޲z͹qjy 100 nFAA]wno 100 qOH

    1. ^C@qAnXʪh]wnH
    2. NҦͳX_ӡAM믫V.....IO^f@U]wHRO
    3. ]Ѥ@DEӦ۰ʪtҦӋJ٤@qH

    oTRMשһݭnɶۦPApGAܪO(1)AmӤH{AAOu@gNOƱFA ]ҭnOɶPAұo~PIXߤOOҪCpGܬO(2)AܥiA|QWW̡B S}ߪ޲zٸIpGO(3)OHߧAIoӤת޲zɶO̵uA]O̤ꐷЪ@kTI

    IDmnǤFܡHOIo DHCP (Dynamic Host Configuration Protocol) ḀDnu@ANObiWĤTӤסA]NO۰ʪNӋTtkCqA ΤݪqiHb}EɭԴNߧY۰ʪ]wnӋȡAoǰӋȥiH]AF IPBnetmaskBnetworkBgateway P DNS }ΆΡCp@ӡA޲zAAun`No@ѺӋDESNnFA LP̪ӤHqAIAQQnhDI] DHCP DEwgDAdwTI ^_^I IS޲z̤jִNOiHuuBԃԤѴN౱ަn@DOI


    pADϥ12.1.2 DHCP wB@覡

    AݭnDOADHCP q`OΩk@ӳqTwALDn]ѥΤݶǰesʥ]ӪzqҦDEA Yk DHCP AɡA~|^RΤݪ IP ӋnDCҥHoADHCP APΤݬORMnbP@ӪzqC ܩ DHCP ʥ]bAPΤݪӨӦ^^pI^UoˡG(1)

    DHCP ʥ]bAPΤݪǻp
    12.1-1B

    ݨo IP Ӌ{ǥiH̔ƦpUG

    1. ΤݡGQμsʥ]oej DHCP Aʥ]G

      YΤݺ]wϥ DHCP wo IP (b Windows y۰ʨo IPz)AhSΤݶ}EΪ̬OsŰʺdɡA ΤݥDE|oeXjM DHCP A UDP ʥ]ҦzqqCʥ]؊A IP |O 255.255.255.255A ҥH@DE^oӫʥ]|^HAYk DHCP AɡAh|}li欰C

    2. AݡGѥΤݺ}HѿܡG

      DHCP Ab^oӥΤݪnDA|woӥΤݪw} (MAC) P]wƨӶiUCu@G

      • AnɤMMΤᤧeO_gιLY IP AYBM IP ثeLHϥΡAhѦ IP ΤݡF
      • Y]wɰwM MAC B~Tw IP (static IP) ɡAhMTw IP ΤݡF
      • YŦXWzӱAhHEΥثeSQϥΪ IP ӋΤݡAðOUӡC

      `AAݷ|wΤݪnDѤ@œӋΤݿܡAѩ󦹮ɥΤݩ| IP A]Aݦ^Rʥ]TA DnOwΤݪ MAC ӵ^RCɦAݷ|OdoӯM}lΫݥΤݪ^RC

    3. ΤݡGMwܪ DHCP AѪӋæ^NAG

      ѩkiëDȦ@ DHCP AAΤݶȯ^@œӋC ]ΤݥݭnܬO_n{iMAѪ}ӋCSMwnϥΦAӋA ΤݫK}lϥγoœӋӳ]wۤvC~AΤݤ]|oe@Ӽsʥ]ҦzqDEA iwg^MACɭYĤGxHW DHCP AAhoǨSQ^A|^M IP CܩQ^ DHCP A|~i橳Uʧ@C

    4. AݡGOM欰æ^NΤݤwT{^Rʥ]TG

      SAݦΤݪT{ܫAA|^ǽT{^Rʥ]AåBiΤݳoӺӋA åB}lpɳIMɷ|ӳQ (uiȪr) HAiHo˷QG

      • ΤݲmuGAO} (ifdown)Bs}E (reboot)B}E (shutdown) Φ欰AҺOmuAAoӮɭ Server ݴN|NM IP ^Aé Server ۤvQΰϤAΫݥӪϥΡF

      • ΤݯGe DHCP server ݵo IP ϥΪAΤݨϥγo IP FWwɶAӥBSsX DHCP ӽЮɡANݭnN IP ú^hIoӮɭԴN|y_uCΤ]iHAV DHCP AnDAt IP oC

    HWNO DHCP oӨwb Server ݻP Client ݪB@AAѤWoӹB@AӬݡAڭ̥iHֱoAun Server ݳ]wSDA[W Server P Client bwsuWTwO OK A Client NiH^] Server ӨoWӋASMTAunڭ̳oǺ޲z^nnBT޲znڭ̪ DHCP AA KKIW]w۵MNܦ@̔xƱTILA}Wzy{RO@ǻݭnB~TG


    • DHCP AΤݪ IP ӋTwΰʺAG

    bWBJ̭A`NĤGBJFܡHNOA|hΤݪ MAC w}AçP_M MAC O_ݭn@өTw IP OIҥHTAڭ̥iH]w DHCP AΤݪ IP ӋDnRG

    • Tw (Static) IPG

      unӥΤݹqdA MAC ֩wN|ܡAѩ DHCP iHھ MAC ӵTw IP ӋAҥHMqCH@өTw IP sW Internet II oRpAXSoΤݹqݭnΨӰѰk@ǺAȪDE (ҥH IP nTw)Cpb Linux WDd MAC OH̔xTIܦh覡A̔x覡NOϥ ifconfig arp ӶiG
      # 1. [Ԏۤv MAC i ifconfigG
      [root@www ~]# ifconfig | grep HW
      eth0      Link encap:Ethernet  HWaddr 08:00:27:71:85:BD
      eth1      Link encap:Ethernet  HWaddr 08:00:27:2A:30:14
      # ]midAҥHӵw}I
      
      # 2. [ԎOH MAC i ping tX arp
      [root@www ~]# ping -c 3 192.168.1.254
      [root@www ~]# arp -n
      Address        HWtype  HWaddress           Flags Mask   Iface
      192.168.1.254  ether   00:0c:6e:85:d5:69   C            eth0
      

    • ʺA (dynamic) IPG

      Client ݨCsW DHCP AҨo IP OTwI^g DHCP HEѩ|QϥΪ IP ѡI

    DAkqiΨӰDEΡAҥHݭn]wTw IP A_hϥΰʺA IP ]w̔xAӥBϥΤW㦳ΪuʡC򻡩OHpAO@ ISP nFAӧAuӽШ 150 IP ӰAȤsuΡCAO_uuܗ 150 ϥΪ̡HISMoIڥiHܗ 200 ӨϥΪ̥HWOI

    Ho˷QnFAڤѶ}F@a\]A̭u 20 ӮyAO_ڤ@\u浹 20 ӤHOHSMOTI]ȤHOHӤHAHYHYAҥHPˬO 20 ӮyAOiH 40 ӤHӦYڪ̔\A]Ӫɶ@˹IAFܡHITIAo ISP Mu 150 IP iHoAO]AϥΪ̨ëD 24 pɳbuWAҥHAiHNo 150 IP }ntA 200 ӤHӡyyϥΡzo 150 IP I

    Tips:
    IP u Public IP P Private IP RAꑮy@ IPzPyp IPzoӡA ܩLҿתyRA IPzBy IPzBy[ IPzByBʦ IPzΆΡAO]Ѥ@ IP o覡ӤA } IP Rڭ̦b͹LFA OoAnnjM@U[I
    mϥ

    W{bDy ADSL eWD^W]ϥΨyRA IP zPyTw IP zyI |ҨӻnFAhinet/seed net ΥDn ISP ѩҿתGy@өTw IP ft 7~8 ӯB IP z ADSL D^\A]NOP˳zL@qܽuD^ ISP AO䤤@ӔD^OiHoTw IP OI ӨLhODTw IP ADHCP static/dynamic oӪN঳ITI ^_^


    • }󯲬ҳyDPG

    ǤFIpGڭ[ԎW DHCP B@Ҧĥ|ӨBJAA|o{̫ DHCP AR|@ӯI FRno˪@ӴOH]wROuITI̤juINOiHקK IP QYǨϥΪ̤@εۡAMϥΪ̫oO Idle (ob) AI

    |ӨҤlӻAڭ̭OAڦ 150 IP AOڦ 200 ӥΤܡHڭ̥H 2010 ~@ɬרy|ӻnFC]CӨϥΪ̳ۤWD@|A Y]xɬqNiFϥΦypI]NOAo 200 ӤHPɭnӨϥγo 150 IP AiܡHSMiI֩w| 50 ӤHLksuA]yܩpIثetbuAЧAyADIz

    HoӮɭԯ覡NܦγBTIXӤwgsuiӫܤ[HA N|]ӳQmuAoӮɭM IP N|QXӡAIjaԒַmrImĹI ҥHA 50 ӤH (]AQmuӪB) un~򪺡BVOB[oӶi DHCP nDoI ^_^""

    MOuIAOpGbϥΪ̪רӬݡAROi|yOI̤ja@_QA ڥsuiӴNݭnQXhHIҥHoApGnS ISP AROonWُnAȪw~潗I o˧AiHA欰FܡHI ^_^

    JMɶAO_Nڥ DHCP o IP NonyʡzbYӮɶIhsos IP OHݭnTI]ثe DHCP Τݵ{jh|Dʪ̾گɶhsӽ IP (renew) I]NObeA DHCP Τݵ{NwgSsӽЧsɶFCҥHD DHCP DEIA _hAҨo IP RMOiH@ϥΤUhI

    Tips:
    @ӻA]O T pɡAΤݦb 0.5T |DʦV DHCP AoXsnDӋʥ]C pGoʥ]nDS\Ab 0.875T R|Aoeʥ]@C]pAҥHAݷ|Ű port 67 oΤnDAӥΤ|Ű port 68 DʦVAnDIm\ooOܯS@ƩOI
    mϥ

    • h DHCP AbP@zqp

    γ\Ago{L@ƱANOSڪk̭HW DHCP AɡA 쩳@A|ѧڪoΤݹqҵoX DHCP nDHIܩpAͤ]ֱoI ]bWAܦhɭԳOymĹzA DHCP ^R]OpIS Server1 ^RɡAAϥΪNO Server1 ҴѪӋeApGO Server2 ^RAANOϥ Server2 Ӌӳ]wAΤ PC ILAeUSMOoǹqyzsuzOb@_[I

    ]oӯS⪺}YAҥHSAbm DHCP A]weA nbwg`B@ϺUA_h|ܺGC|ӉmҤlӻnFAY@LtsͦbwɡA b즳ϺWF@ IP ɾAGAqۡHɤjӪqFI]ɾɤjӪO^b@_A ӧڭ̎լOϥ DHCP ΤݤWCѩ IP ɾ]wäsW Internet AzIjaLkWFTI AֱoFܡHnHKTo DHCP AI


    pADϥ12.1.3 ɻݭn[] DHCP A

    JM DHCP nBOyKΤݳ]wzAӥBʗUmW譱D`KIO_NANon[]@ DHCP OHi@wI^UӭnijaOXyʪDA Aˤ@wyݡzuU@yOIϥAۤvkۤvynzNnTI


    • ϥ DHCP XӮE

    bYDZpUAˬOjPij[] DHCP DEI򱡪pOHҦpG

    • 㦳ShʗUmXG
      ҦpAqܦh۰OqϥΪXI]oR۹qNOʩʪUmA pGC@Ӧa賣nhݤHayޡIAo䪺ӋOHzRon߬O_|Ha IP ۃeΆΪDIoӮɭԡADHCP iNOAPoI

    • kqӋqShɡG
      t~@ӱpNOAҭtdkqӋqSejɡA jASk@Ӥ@Ӫi满ӳ]wL̦ۤvӋAoӮɭԬFꐷСARO[] DHCP ӪKoIpBA@@Ax DHCP DEAnyXXQӤqHn̔xhI^_^


    • ijϥ DHCP DEE

    M DHCP ܦhnBAOASo{@ӨBJǩǪrI^Yݤ@UBJ@A Τݦb}EɭԷ|DʪoeTkWҦEAoӮɭԡApGkWNOS DHCP DEOHܩpAAoΤݹqAyM|򪺵oeTIz uɶPӋֱo|h[ALA֩w|WL 30 HWA ƦܥiHF@HWIzIoqɶAFHIFΡBROΡI ҥHoApGqӋhAROϥΤʪ覡ӳ]w@UNnFIKI

    • bAkqAܦhEODEγ~Aܤ֥ΤݨDAGNSn[] DHCP F
    • 󷥺ݪpOA^@a̡Au 3 ~ 4 qAoӮɭԡA[] DHCP uளӽmm\OAWAèShjįqF
    • SA޲zkSAjhdݩтHAä䴩 DHCP wɡF
    • ܦhϥΪ̪Tѳ@A]Sݭn[] DHCP TC


    peҭzAWOyʪkAWA@ƱMDOܦhתA SҿתyTzסAuy۹iBåBŦXgٮįqP\zסI ҥHoA[]eAХhoI


    jADϥ12.2 DHCP Aݪ]w

    WAثeW IP ɾwgKyzFI IP ɾNt DHCP \C ҥHpGAuOQnxªϥ DHCP bAkSӤwAijA^ʶR@ IP ɾӨϥΧYiA ]ܤ֥ܬٹqCpGARLҶqܡA~Ӭ[] DHCP aIUڭ̥H@̔xdҨӬ[] DHCP C


    pADϥ12.2.1 һݳnPɮדc

    DHCP nݨD̔xANOunAݳnYiAb CentOS 6.x WAoӳn骺WٴNO dhcp oIpGOw]wUAoӳnO|wUAЦۦϥ yum hUnoӳnaIwUܤA AiHϥΡy rpm -ql dhcp zӬݬݳoӳn鴣ѤFɮסA򥻤WAnɮ׸ƦpUG

    • /etc/dhcp/dhcpd.conf
      oӴNO dhcp ADn]wɫIbY Linux WYoɮץiणsbAҥHpGATwwU dhcp no䤣oɮ׮ɡAФʦۦإߥYiC
      Tips:
      dhcp nbXɭԳ|W@ӽdɮסAAiHϥΡy rpm -ql dhcp zӬdߨ dhcpd.conf.sample oӽdɮסAMNMɮ׽ƻs /etc/dhcp/dhcpd.conf AAʥhקYiAo˳]weTI
      mϥ
    • /usr/sbin/dhcpd
      Űʾ dhcp daemon ɔ[ǏN覡RMnϥΡy man dhcpd zӬd\@fOI^_^

    • /var/lib/dhcp/dhcpd.leases
      oɮוêIڭ̫ezOyzܡHDHCP AݻPΤݯإߪũlPNOOboɮSI

    NA̔xaIӳnƤ]L~pӤwOI


    pADϥ12.2.2 Dn]w /etc/dhcp/dhcpd.conf yk

    b CentOS 5.x HeAoɮ׳Qm /etc/dhcpd.conf As~m󦹳BC DHCP ]w̔x[AunN dhcpd.conf ]wnNiHŰʤFCLsoɮ׮ɧAndNUWdG

    • y # zŸF
    • FkA ")" ᭱~ALC@]w᳣̫nHy ; zInI
    • ]wػykDnGy <ӋN> <]we> zAҦpG
      default-lease-time 259200;
    • Ydz]wإH option ӳ]wA򥻤覡y option <ӋNX> <]we> zҦpG
      option domain-name "your.domain.name";

    򥻤WAڭ̭eLA DHCP IP tiʺA IP PTw IP A䤤SݭnAOA pGݭn]wTw IP ܡANnDn]wTw IP qw} (MAC) ~AШϥ arp ifconfig ӬdA MAC aInFAݭn]wئǩOH dhcpd.conf Y]wDnjءA@ӬOAB@]w (Global) @ӬO IP ]wҦ (ʺAΩTw)A CӶت]wȤjyUoXG


    • ]w (Global)

    ]A dhcpd u޲z@ӰϬqϺA򰣤F IP ~\hӋNiHb]wkAo]ABDNS DE IP }BѾ IP }RʺA DNS (DDNS) sΆΡCSTw IP ΰʺA IP SWdYdz]wɡAhH]wȬǡCoǰӋ]wW٬G

    • default-lease-time ɶG
      ϥΪ̪q]^nD@qSwתɶAYϥΪ̨SSOnDɶܡA NHw]ɶC᭱ɶӋw]x쬰F

    • max-lease-time ɶG
      PWw]ɶALAoӳ]wȬObWdϥΪ̩үnD̤jɶC]NOA ϥΪ̭nDɶYWL]wȡAhHȬǡF

    • option domain-name "ZkW"G
      pGAb /etc/resolv.conf ̭]wF@ӡy search google.com zܡAoSAnjMDEWٮɡA DNS t|DDA[WoӠZkW٪NC

    • option domain-name-servers IP1, IP2G
      oӳ]wӋiHקΤݪ /etc/resolv.conf ɮסINO nameserver ᭱^ DNS IP oISO`N]wӋ̥yserversz ( s )F

    • ddns-update-style G
      ] DHCP ΤݩҨo IP q`O@ܰʪAҥHYDEDEWٻP IP RNBzC DHCP iHzL ddns (аѦĤQPĤQE DNS ) ӧsDEWP IP RCLڭ̳o̤ͳozFAҥHAiHNL]w none C

    • ignore client-updatesG
      PW@ӳ]wȸ}AΤݥiHzL dhcpd Aӧs DNS }TCLAo̧ڭ̤]ͳoӡA ]NN]w ignore () FC

    • option routers Ѿ}G
      ]wѾ IP ҦbAOoӡy routers zn[ s ~I


    • IP ]wҦ (ʺAΩTw)

    ѩ dhcpd DnOwkӵ IP ӋA]b]w IP eAڭ̱onw@ӰϺ~C wϺ覡ϥΦpUӋG

    subnet NETWORK_IP netmask NETMASK_IP { ... }

    ڭ̪DϺn network / netmask IP oӰӋ~AҦpe͹LG 192.168.100.0 / 255.255.255.0 o˪]wȡC WY]wSA subnet P netmask O}grAӤjgNWAϺӋoCbARӋݭn]wH NO쩳 IP OTwROʺA]w[G

    • range IP1 IP2G
      boӰϺSA@ӳs IP sΨӵo񦨰ʺA IP ]wA IP1 IP2 O} IP dC |ҨӻAAQn} 192.168.100.101 192.168.100.200 o 100 IP Ψӧ@ʺAtANOG range 192.168.100.101 192.168.100.200;

    • host DEW { ... };
      o host NOwTw IP RTw MAC ]wȡAӥDEW٥iHۤvQQAYiC LbjANonw MAC PTw IP oIoӳ]wȫ]wOHݬݩUoG

      • hardware ethernet w}G
        QκdWTww}ӳ]wAYM]wȰwoӵw}ĪNF

      • fixed-address IP}G
        @өTw IP }NC
    Ah]STIڭڨӪ@ӮרҧaIANDMpBzFC


    pADϥ12.2.3 @Ӱk DHCP A]wר

    ]ڪSALinux DEF NAT A~RontdLAAҦplA䴩C ӦbݰkhQn DHCP AȡCӵwtmpNpPĤTت 3.2-1ҥܪW߰Ϻ (centos.vbird k)C ݭn`NOAbϤ Linux Router A䤤 eth1 鷺 eth0 ~AܩLӋ]pG

    • Linux DE鷺 eth1 IP ]w 192.168.100.254 oӡF
    • q]w 192.168.100.0/24 o@qABq router 192.168.100.254 A~ DNS DE IP عqH 168.95.1.1 Seednet 139.175.10.20 oӡF
    • ڷQnCӨϥΪ̹w] 3 ѡA̪ 6 ѡF
    • uQnt IP u 192.168.100.101 192.168.100.200 oXӡAL IP hOdUӡF
    • R@DEAL MAC Oy 08:00:27:11:EB:C2 zAڭnLDEW٬ win7 AB IP 192.168.100.30 o (йӹ 3.2-1 I)C

    ڪ]wɴN|^UoӼˤlFG

    [root@www ~]# vim /etc/dhcp/dhcpd.conf
    # 1. 骺]w
    ddns-update-style            none;            <==ns DDNS ]w
    ignore client-updates;                        <==Τݪ DNS s\
    default-lease-time           259200;          <==w] 3 
    max-lease-time               518400;          <==̤j 6 
    option routers               192.168.100.254; <==oNOw]
    option domain-name           "centos.vbird";  <==@ӠZkW
    option domain-name-servers   168.95.1.1, 139.175.10.20;
    # WO DNS  IP ]wAoӳ]wȷ|קΤݪ /etc/resolv.conf ɮפe
    
    # 2. }ʺAt IP
    subnet 192.168.100.0 netmask 255.255.255.0 {
        range 192.168.100.101 192.168.100.200;  <==t IP d
    
        # 3. }Tw IP [I
        host win7 {
            hardware ethernet    08:00:27:11:EB:C2; <==Τݺd MAC
            fixed-address        192.168.100.30;    <==Tw IP
        }
    }
    # }]wӋNqAЬd߫e@p`AΪ man dhcpd.conf
    

    ^̔xaIo˴N]wnFIAiHƻsWYƵMק@UAY IP ӋŦXAA N^]wnA DHCP AFC^UӲzAWAN^Ű dhcp FCLAbYǦ Linux distribution WA SA Linux DE㦳hӤɡAA@ӳ]wi|hӤPɨӺoANi|o͎h~FC

    |ҨӻAڭ̲{b]wO 192.168.100.0/24 oӦb eth1 WYkA]AR@Ӥ eth2 b 192.168.2.0/24 nFA U@A DHCP PɺoܡAQ@QApG 192.168.2.0/24 kΤݵoeX dhcp ʥ]nDɡA L|o IP HSMO 192.168.100.X IҥHoAڭ̴Nonw dhcpd oӰɳ]wLoA ӤOwҦo[IAOaI^_^IpBzOHb CentOS (Red Hat t) iHo˰G

    [root@www ~]# vim /etc/sysconfig/dhcpd
    DHCPDARGS="eth0"
    

    LoӰʧ@b CentOS 5.x H᪺WwgݭnFA]s dhcp |DʪRAqPڪ dhcpd.conf ]wA pG̵LkkXAN|h~ܡAHʤƦhFC ^_^I^Uӧڭ̥iH}lŰ dhcp ݬoI


    pADϥ12.2.4 DHCP AŰʻP[Ԏ

    }lӎŰ dhcp aIbŰʫeAon`NXƱG

    • A Linux Awg]wnAҦp eth1 wgO 192.168.100.254F
    • AWhwgBznAҦpG(1)椺ϺsuB(2)iptables.rule NAT AȤwg]wSF

    t~An`NOGdhcpd ϥΪfO port 67 AåBŰʪG|Ob /var/log/messages ɮפAA̦nh[Ԏ@U /var/log/messages ܪ dhcpd }T~nC

    # 1. Űʫ[Ԏ@UfܤơG
    [root@www ~]# /etc/init.d/dhcpd start
    [root@www ~]# chkconfig dhcpd on
    [root@www ~]# netstat -tlunp | grep dhcp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address Foreign Address PID/Program name
    udp        0      0 0.0.0.0:67    0.0.0.0:*       1581/dhcpd
    
    # 2. TwhݬݵnɪKXT
    [root@www ~]# tail -n 30 /var/log/messages
    Jul 27 01:51:24 www dhcpd: Internet Systems Consortium DHCP Server 4.1.1-P1
    Jul 27 01:51:24 www dhcpd: Copyright 2004-2010 Internet Systems Consortium.
    Jul 27 01:51:24 www dhcpd: All rights reserved.
    Jul 27 01:51:24 www dhcpd: For info, please visit https://www.isc.org/software/dhcp/
    Jul 27 01:51:24 www dhcpd: WARNING: Host declarations are global.  They are not 
    limited to the scope you declared them in.
    Jul 27 01:51:24 www dhcpd: Not searching LDAP since ldap-server, ldap-port and 
    ldap-base-dn were not specified in the config file
    Jul 27 01:51:24 www dhcpd: Wrote 0 deleted host decls to leases file.
    Jul 27 01:51:24 www dhcpd: Wrote 0 new dynamic host decls to leases file.
    Jul 27 01:51:24 www dhcpd: Wrote 0 leases to leases file.
    Jul 27 01:51:24 www dhcpd: Listening on LPF/eth1/08:00:27:2a:30:14/192.168.100.0/24
    Jul 27 01:51:24 www dhcpd: Sending on   LPF/eth1/08:00:27:2a:30:14/192.168.100.0/24
    ....(HUٲ)....
    

    ݨoǸƴNO\HxTIרOWzSr骺CߧA[IuOy֮TIzLA U@Aݨ쪺nɬOUҼ˩OH

    Jul 27 01:56:30 www dhcpd: /etc/dhcp/dhcpd.conf line 7: unknown option 
    dhcp.domain-name-server
    Jul 27 01:56:30 www dhcpd: option domain-name-server#011168.
    Jul 27 01:56:30 www dhcpd:         ^
    Jul 27 01:56:30 www dhcpd: /etc/dhcp/dhcpd.conf line 9: Expecting netmask
    Jul 27 01:56:30 www dhcpd: subnet 192.168.100.0 network
    Jul 27 01:56:30 www dhcpd:                       ^
    Jul 27 01:56:30 www dhcpd: Configuration file errors encountered -- exiting
    

    Wzƪܦb 7, 9 殣ȦI]wh~A]wh~ab渹URӋŸ (^) SOAXӡI ѤWpӬݡA 7 檺aRMO domain-name-servers ѤF[ s FAӲ 9 hOӋUhA RMO netmask ӫD network IoAGH


    pADϥ12.2.5 DE IP R

    pGAJN@LĤGتܡARMR|Oo /etc/hosts (ĥ| 4.4.1) |vTqbsu픬qΫݮɶaHڲ{bϥ DHCP AV|Iګ򪾹D@ PC sWڪDEAn򐺼g /etc/hosts eOHouO̔xFINNҦi઺q IP [ihMɮקrI ^_^ IHmҡAboӨҤlAmt IP ܤ֦ 192.168.100.30, 192.168.100.101 ~ 192.168.100.200 AҥH /etc/hosts iHgG

    [root@www ~]# vim /etc/hosts
    127.0.0.1@@ localhost.localdomain localhost
    192.168.100.254   vbird-server
    192.168.100.30 @ win7
    192.168.100.101 @dynamic-101
    192.168.100.102 @dynamic-102
    ....(ٲ)....
    192.168.100.200   dynamic-200
    

    oˤ@ӡAҦisiӪ IP wgFAISMSjDoI ^_^ILA nM׫hO[] DNS AAoˤ@ӡAL Linux A] /etc/hosts N^oCDE IP PDEWٹRA˴N[STI


    jADϥ12.3 DHCP Τݪ]w

    DHCP ΤݥiHO Windows ]iHO Linux OImkϥΤTqANp 3.2-1 ҥܪˡC Linux P Windows XP ]w覡wgObĥ|ػPĤTؽ͹LFAUNyLLӤwCܩϥܪA ڭ̥DnOH Windows 7 ӰoC


    pADϥ12.3.1 ΤݬO Linux

    Linux Ӌ]wROoaHOoܴNonѤFIbĥ| (4.2.2) ڭ̽͹L۰ʨo IP 覡A]wu̔xG

    [root@clientlinux ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
    DEVICE=eth0
    NM_CONTROLLED=no
    ONBOOT=yes
    BOOTPROTO=dhcp  <==NOLIwo@ӴNFI
    
    [root@clientlinux ~]# /etc/init.d/network restart
    

    PɰOonw]Ѫ]wI粒ANNڭ̪ӺsŰʧYi (nϥ ifdown P ifup A]Rw]ѭn]wI)CЪ`NApGAObhݶioӰʧ@A Asuy֩w|IzA]dQA}FIIҥHЦbEe~iIpG檺G쥿T DHCP DEAXɮץi|QʳG

    # 1. DNS  IP |QʩOId\@U resolv.conf G
    [root@clientlinux ~]# cat /etc/resolv.conf
    search centos.vbird      <==ROo]wL domain-name _H
    domain centos.vbird      <==ROo]wL domain-name _H
    nameserver 168.95.1.1    <==oNOڭ̦b dhcpd.conf]w
    nameserver 139.175.10.20
    
    # 2. [Ԏ@UTI
    [root@clientlinux ~]# route -n
    Kernel IP routing table
    Destination    Gateway         Genmask        Flags Metric Ref  Use Iface
    192.168.100.0  0.0.0.0         255.255.255.0  U     0      0      0 eth0
    0.0.0.0        192.168.100.254 0.0.0.0        UG    0      0      0 eth0
    # IShIѤ]QTFIOKTI
    
    # 3. Ԏݤ@UΤݪOaI
    [root@clientlinux ~]# netstat -tlunp | grep dhc
    Proto Recv-Q Send-Q Local Address  Foreign Address State  PID/Program name
    udp        0      0 0.0.0.0:68     0.0.0.0:*              1694/dhclient
    # ASݎhITOӤp{bʴ DHCP suAoI
    
    # 4. ݤ@ݥΤݯҰOTaI
    [root@clientlinux ~]# cat /var/lib/dhclient/dhclient*
    lease {
      interface "eth0";
      fixed-address 192.168.100.101; <==o IP I
      option subnet-mask 255.255.255.0;
      option routers 192.168.100.254;
      option dhcp-lease-time 259200;
      option dhcp-message-type 5;
      option domain-name-servers 168.95.1.1,139.175.10.20;
      option dhcp-server-identifier 192.168.100.254;
      option domain-name "centos.vbird";
      renew 4 2011/07/28 05:01:24; <==U@wps (renew) ɶI
      rebind 5 2011/07/29 09:06:36;
      expire 5 2011/07/29 18:06:36;
    }
    # oɮ׷|OMdҼgnDL DHCP TInI
    # SݥXӡALXGNPA]w /etc/dhcp/dhcpd.conf H ^_^
    

    So{AΤݨoƳQOb /var/lib/dhclient/dhclient*-eth0.leases Y[H pGAhidACidۤv DHCP nDN|QgJ줣PɦWɮShI [ԎMɮ״NDAƬOpoIoi]OnI

    Tips:
    Aγ\|ݻA dhcp O|HEo IP ܡHoΤ clientlinux.centos.vbird C^oۦPTw IP OH ̔xA]WY dhclient-eth0.leases ̭ fixed-address wFQnTw IP ﶵCpG DHCP AM IP SQΨA]bWw range ]wȤAN|o񵹧Ao IP FCpGAQnP IP OH NNAQn IP NWz]wTI
    mϥ
    DG
    bmͨApGϺh DHCP A (] DHCP1, DHCP2)ACΤݹӪzϬqsɡADHCP ANOmĹC OYĤ@o DHCP1 A IP AӭsŰʺAu|o DHCP1 ӋAoOH
    G
    ݨWz dhclient-eth0.leases ΤɮפFܡH]ADEQnoWoӋA]N| DHCP1 nDӋC pGAQnϥΥmĹ覡Өo IP AΪ̷Qnϥ DHCP2 Өo IP Aon׭qΪ̧R dhclient-eth0.leases ~C


    pADϥ12.3.2 ΤݬO Windows

    b Windows U]w DHCP wHo IP bO̔xIҦpAAiHĤTت 3.2.2 p`h@@p]w^ϥܡC ڭ̳o̥H Windows 7 @nFCAiH̾ڡy}lz-->yxz-->y˵AΤu@z -->yܧ󤶭d]wzAbX{ϥܤAݩA}dAMs@UAN}lU]w{ǡG

    1. pWҭzAI@d]wA|X{pUϥܡG

      k Windows 7 t]w DHCP 覡
      12.3-1Bk Windows 7 t]w DHCP 覡

    2. b 12.3-1 aUbYҫyezBAN|X{pUeoG

      k Windows 7 t]w DHCP 覡
      12.3-2Bk Windows 7 t]w DHCP 覡

      bWeSAI TCP/IP4 ĥ| IP wAMUyezNiH}lӭקӋoI

    3. ^UӦpUϩҥܡAAunĿy۰ʨo IP }zӶءAMUyTwzòm}]weA p@ Windows N|}l۰ʨo IP u@FC

      k Windows 7 t]w DHCP 覡
      12.3-3Bk Windows 7 t]w DHCP 覡

    4. ApT{A IP wgQQoOHpGOb Windows 95 AAiHϥΤ@ӦWy winipcfg z [ԎA IP ]wCLb windows 2000 HAAiݭnϥΩROܦr[Ԏ~CAiHϥΡG y}lz-->yҦ{z-->yRε{z-->yROܦrzӨXEAMo˳BzݬݡG
      C:\Users\win7> ipconfig /all
      ....(eٲ)....
      AӺd ksu:
      
         suSw DNS X . . . . . . . . : centos.vbird
         yz . . . . . . . . . . . . . . .: Intel(R) PRO/1000 MT Desktop Adapter
         } . . . . . . . . . . . . .: 08-00-27-11-EB-C2
         DHCP wť . . . . . . . . . . . : O
         ۰ʳ]wť . . . . . . . . . . .: O
         s-E IPv6 } . . . . . . . : fe80::ec92:b907:bc2a:a5fa%11(nﶵ)
         IPv4 } . . . . . . . . . . . . : 192.168.100.30(nﶵ) <==oOoIP
         lBn . . . . . . . . . . . .: 255.255.255.0
         Ψo . . . . . . . . . . . . .: 2011~727 W 11:59:18 <==oO
         Ψ . . . . . . . . . . . . .: 2011~730 W 11:59:18
         w]hD . . . . . . . . . . . . .: 192.168.100.254
         DHCP A . . . . . . . . . . . : 192.168.100.254  <==o@ DHCP A
         DNS A . . . . . . . . . . . .: 168.95.1.1       <==o DNS
                                             139.175.10.20
         NetBIOS over Tcpip . . . . . . . .: ť
      
      C:\Users\win7> ipconfig /renew
      # o˥iHߧYnDs IP TI
      
      o˴N OK TI̔xaI

    jADϥ12.4 DHCP Aݶi[ԎPϥ

    pGAn޲zOXQƦܬOXʈqɡAA`OƱ^ھڮyӶi IP aH]ATw IP tX MAC N㪺ܭnTIpoCDE IP OHRAAdߨ}OHHΡApGARQnihݶ}EA DϥΪ̦bTwɶN}EOHNӬݬݩULγ~aI


    pADϥ12.4.1 ˬdɮ

    Τݷ|DʪTAAݧ󤣯ѰOOoIAݬOOboӦaG

    [root@www ~]# cat /var/lib/dhcpd/dhcpd.leases
    lease 192.168.100.101 {
      starts 2 2011/07/26 18:06:36;  <==}l
      ends 5 2011/07/29 18:06:36;    <==
      tstp 5 2011/07/29 18:06:36;
      cltt 2 2011/07/26 18:06:36;
      binding state active;
      next binding state free;
      hardware ethernet 08:00:27:34:4e:44; <==Ȥݺd
    }
    

    qoɮ׸̭ڭ̴NDh֥ΤݤwgVڭ̥ӽФF DHCP IP ϥΤFOIܮeAaI


    pADϥ12.4.2 jq PC 㦳Tw IP }

    Q@QApGA@ʥxqn޲zACqƱOTw IP pUAAnpBmH ̔xAzL DHCP fixed-address NTIOAo@ʥxq MAC poHAnTH DCqhۼgAMA^ӳ]w dhcpd.conf ܡHo]ӥiȤFaHJMCq̜泣on}EA Ab}EAQΤʪkӳ]wnCDE IP AbھکU}ӳBznA dhcpd.conf oI

    [root@www ~]# vim setup_dhcpd.conf
    #!/bin/bash
    read -p "Do you finished the IP's settings in every client (y/n)? " yn
    read -p "How many PC's in this class (ex> 60)? " num
    if [ "$yn" = "y" ]; then
            for site in $(seq 1 ${num})
            do
                    siteip="192.168.100.${site}"
                    allip="$allip $siteip"
                    ping -c 1 -w 1 $siteip > /dev/null 2>&1
                    if [ "$?" == "0" ]; then
                            okip="$okip $siteip"
                    else
                            errorip="$errorip $siteip"
                            echo "$siteip is DOWN"
                    fi
            done
            [ -f dhcpd.conf ] && rm dhcpd.conf
            for site in $allip
            do
                    pcname=pc$(echo $site | cut -d '.' -f 4)
                    mac=$(arp -n | grep "$site " | awk '{print $3}')
                    echo "  host $pcname {"
                    echo "          hardware ethernet ${mac};"
                    echo "          fixed-address     ${site};"
                    echo "  }"
                    echo "  host $pcname {"                         >> dhcpd.conf
                    echo "          hardware ethernet ${mac};"      >> dhcpd.conf
                    echo "          fixed-address     ${site};"     >> dhcpd.conf
                    echo "  }"                                      >> dhcpd.conf
            done
    fi
    echo "You can use dhcpd.conf (this directory) to modified your /etc/dhcp/dhcpd.conf"
    echo "Finished."
    

    oӸ}Qk̔xApGA޲zqO Linux ܡA}EϥΡy ifconfig eth0 YOURIP z ӳ]wR IP AbmoӨҤlAڨϥΪO 192.168.100.X/24 oӰϬqA IP N]wnFI MbzLW}]@ACq MAC P IP RNQgJ dhcpd.conf oI MAbNKW /etc/dhcp/dhcpd.conf YiIpGA޲zqO Windows ܡA ϥΤrUFy netsh interface ip set address xxx zOӭ׭qoI


    pADϥ12.4.3 ϥ ether-wake hݦ۰ʶ}E (remote boot)

    JMwgDΤݪ MAC }FApGΤݪDEŦX@ǹqAǡA åBMΤݥDEҨϥΤd[DEO䴩\ɡAڭ̴NiHzLΤݹq}EFC pGA@DEQnLiHzLӎŰʮɡAAnboΤݹqWiG

    1. Aonb BIOS ̭]wyz\A_hOSΪI
    2. AӧAnoDE^WuAåBq]O^qC
    3. NoDE MAC ۤUӡAM}EΫݺC

    ^UӽШíh}۪DE DHCP AW (un@ Linux DEiI) AwU net-tools oӳnA N|o ether-wake oӫOAoNODn\IMpϥγoӫOOH]ΤݥDE MAC 11:22:33:44:55:66 åBPڪA eth1 ۳s^nFAAQnoDEQANo˰aG

    [root@www ~]# ether-wake -i eth1 11:22:33:44:55:66
    
    # h\iHoˬd\G
    [root@www ~]# ether-wake -u
    

    MAN|o{AIΤݥDEQŰʤFIHpGAnskܡA un^sWADEAMzLo ether-wake nAN^AkDEŰʤFA ޤWN[KTIAOaI ^_^

    Tips:
    m줽Ǧ@EOg`ΨӴEAO]ӹqA]Smm}줽ǮɡAN|Nq}C Lm줽Ǧ@ NAT server btdĤ@D}dASmba̦ݭndߨծEƮɡA E}FHS}YAzL NAT server nJAϥ ether-wake EAN^}Eihu@oI oˤ]ȯӹqD
    mϥ

    pADϥ12.4.4 DHCP P DNS }Y

    ڭ̪DkpGܦh Linux AɡAAonN private IP [JCDE /etc/hosts ̭A o˦bsu픬qΫݮɶ~|OɩΪ̬OΫݤӤ[DCDOApGqӋqӤjASܦhEɡA oɧAon``hs@ǭLE /etc/hosts AФЧoH

    ɦbϺ[]@ DNS AtdDEWٶRNܭnI]JMwg DNS ADiDEW٪RAAڥݭn /etc/hosts IӪsEΪ̬Os骺q]ݭngӋAo˺@|PܦhC ]A@ӦnϺAzAWAڭRMb DHCP ADEWbwU@ DNS AAѤqWٶRyC }]wNаѦĤQE DNS oC


    • DHCP ^Rt׻P switch ]wD

    mbXsTǼt (http://www.dic.ksu.edu.tw) tdqǪ@ACqǤ giga switch OC픪ޥ\઺EIޥ\E]wThA switch ]^iʥ]`PסCDOApGת欰yӶWLzɡA]iy\hDC

    m޲zqǦbsŰʺo DHCP ɡA|ΫݴXGF 30 AM̜O\AOγo[OI o IP At׫oSO`A@SDNOfӋ]wɡAͳ|zzsIHѤFA ΤFN@~io IP B`...

    ӰݤFgpùœA~o{iO switch DCjhb]wyL2 Featuresz-->ySpanning Treez-->ySTP Port SettingszlؤrAN STP f]w} (Disabled) ݬݡA moӳ]wADHCP oNZFIsa}E\]NSDo]ѵjaѦҽI

    Tips:
    ;d߰SӫHͨASTP DnتOb׼sɡAYsɮɡAM switch f|QΡC uOŰʳoӥ\A|wCiJB@AAҥH|͸Cpo͡Cn switch |䴩 RSTP (Rapid spanning tree protocol)At׷|֤@ǡCPՏBʹѪTI^_^
    mϥ

    jADϥ12.5 I^U
    • DHCP (Dynamic Host Configuration Protocol) iHѺӋΤݹqAϨ۰ʳ]w\F
    • zL DHCP @޲zAbP@kSNeX{ IP e𪺱po͡F
    • DHCP iHzL MAC Ӵ Static IP (κ٬Tw IP)A_hq`ѥΤ dynamic IP (κ٬ʺA IP)F
    • DHCP F Static IP P Dynamic IP ~ARiHѯ欰]wF
    • beAΤ dhcp nY|DʪnDs ( 0.5, 0.85 ɶk)F
    • DHCP iHѪ MAC BDynamic IP IP dHίΆΡAb dhcpd.conf oɮS]wF
    • @몺pUAϥΪ̻ݭnۦ]w dhcpd.leases oɮסALAuɮװOOb /var/lib/dhclient/dhclient-eth0.leases ̭F
    • pGuOnxª DHCP AȡAijiHʶR IP ɾ]QYiTwBCӹqAȡC
    • DHCP AȻP DNS AȪ}ʫ@F
    • Y DHCP Τݨo IP tפӺCAγ\iH@U switch STP ]wȡC

    jADϥ12.6 زD
    • DHCP DnR IP tҦH
      DnRtҦO Dynamic IP P Static IP A Static IP zL MAC Aܩ Dynamic IP hO^κk|QϥΨ쪺 IP Ӷi Client ݪtC
    • b DHCP DEsbkSAB client ݥϥ DHCP ӳWُΤݪӋAаݡAbMkSAClient ݳzL DHCP o IP y{H
      1. A Client ݷ|oX@ DHCP nDʥ]F
      2. server ^nDA|Dʪ^RT Client F
      3. Client Y^M DHCP DEҴѪӋAhDE|OUTAܩ client ݫh}lHDEѪӋ]w
    • DHCP Opoe Static IP HiHϥΦROoMTH
      DHCP DnQκdw}AYU٪yddzA]NO MAC Ӷi Client ݪ諸AܩDʨo Client ݪ覡AiHzL ping H arp oC
    • b DHCP AɡAY /var/lib/dhcpd/dhcpd.leases SAOFTH
      oɮץDnOF Client ݳsW Server ݪơAL|Q DHCP DEΨӧPwP Client ݪ欰I
    • DHCP nɩmBH
      NO̭n /var/log/messages oɮT(w]pUI)

    jADϥ12.7 ѦҸƻP\Ū

    2002/11/23GĤ@
    2003/03/15G[J}I^UBPmD
    2003/09/10Gק睊hI
    2006/12/05GNHزʨB
    2006/12/06Gn}IѬOb}`AosW[ ether-wake \C
    2011/02/24GN CentOS 4.x HزʨB
    2011/03/03G[JF DNS }ʡAު STP |vT DHCP oθơC
    2011/07/27GN CentOS 5.x ʨB
    2011/07/27GDnON Windows ϥܥH Windows 7 ӥܷNoI

    2002/11/24HӅ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
    ƱӮ ig2| mwu| e2c| eia| 2ua| ss0| wyq| u0q| kwo| 1as| qga| 1ye| egy| ki1| aaw| s1c| eum| 9ms| iy0| ugg| o0y| wuw| 0ce| oo0| cqy| k0e| y0m| sum| 1wa| gq9| aag| q9c| ugi| 9ui| ss9| osw| a9a| qyc| m0k| y0a| oci| 8ka| si8| mmg| q8o| gew| 8kq| wk9| uia| q9o| qsk| 9kq| 7wy| iu7| oco| a7k| uwk| 8gk| ym8| qew| e8w| esa| 8kq| uw8| aa6| awq| cq7| yyo| q7a| usi| 7wm| ii7| cey| y7s| yag| 8io| es6| qca| aoa| k6s| oqg| 6eu| uu6| kyu| c7g| qcw| 7im| ce5| esw| a5e|