µ±Ç°Î»ÖãºLinux½Ì³Ì - LinuxÎÄ»¯ - ÖÐСÆóÒµ·þÎñÆ÷ÅäÖ÷½°¸ µÚÒ»ÕÂ(3)

ÖÐСÆóÒµ·þÎñÆ÷ÅäÖ÷½°¸ µÚÒ»ÕÂ(3)


¶ÔÓÚÄÇЩ²»Ì«Á˽âÍø·¼¼ÊõµÄÈËÀ´Ëµ£¬ÅäÖÃTCP/IP¿ÉÄÜÊÇÒ»¼þ·Ç³£¸´ÔӵŤ×÷£¬¶ÔÄÇЩ½«PCÁ¬½Óµ½¾ÖÓòÍøµÄÓû§À´ËµÖ»Äܽ«ÅäÖü¯Öе½·þÎñÆ÷¶Ë£¬ÕâÑù¿ÉÒÔ¼ò»¯Óû§¶ËµÄ¹¤×÷¸´ÔӶȡ£µ±È»£¬Õ⽫ÔÚÒ»¶¨³Ì¶ÈÉÏ£¬Ôö¼Ó¹ÜÀíÔ±µÄ¹¤×÷Á¿£¬µ«ÊÇ´ÓÕûÌ忼ÂÇ£¬ÕâÑùÊÇ×îÓŵġ£

±¾ÕÂÎÒ½«Ïò´ó¼Ò½éÉÜÈçºÎÅäÖö¯Ì¬IP·ÖÅäÒÔ¼°¹ÜÀí£¬²¢ÓÃͨË×Ò׶®µÄÓïÑÔ½âÊÍËüÊÇÈçºÎ¹¤×÷µÄ£¬Ï£Íû´ó¼Òͨ¹ýÔĶÁ±¾Õ£¬Ñ¸ËÙ³ÉΪһÃûºÏ¸ñµÄÍøÂç¹ÜÀíÔ±¡£DHCPµÄÈ«³ÆÊǶ¯Ì¬Ö÷»úÅäÖÃЭÒ飨Dynamic Host Configuration Protocol£©£¬ÓÉIETF£¨Internet ÍøÂ繤³ÌʦÈÎÎñС×飩Éè¼Æ£¬Ï꾡µÄЭÒéÄÚÈÝÔÚRFCÎĵµrfc2131ºÍrfc1541ÀĿµÄ¾ÍÊÇΪÁ˼õÇáTCP/IPÍøÂçµÄ¹æ»®¡¢¹ÜÀíºÍά»¤µÄ¸ºµ££¬½â¾öIPµØÖ·¿Õ¼äȱ·¦ÎÊÌâ¡£ÔËÐÐDHCPµÄ·þÎñÆ÷°ÑTCP/IPÍøÂçÉèÖü¯ÖÐÆðÀ´£¬¶¯Ì¬´¦Àí¹¤×÷Õ¾IPµØÖ·µÄÅäÖã¬ÓÃDHCP×âÔ¼ºÍÔ¤ÖõÄIPµØÖ·ÏàÁªÏµ£¬DHCP×âÔ¼ÌṩÁË×Ô¶¯ÔÚTCP/IPÍøÂçÉÏ°²È«µØ·ÖÅäºÍ×âÓÃIPµØÖ·µÄ»úÖÆ£¬ÊµÏÖIPµØÖ·µÄ¼¯ÖÐʽ¹ÜÀí£¬»ù±¾Éϲ»ÐèÒªÍøÂç¹ÜÀíÈËÔ±µÄÈËΪ¸ÉÔ¤¡£¶øÇÒ£¬DHCP±¾Éí±»Éè¼Æ³ÉBOOTP£¨×Ô¾ÙЭÒ飩µÄÀ©Õ¹£¬Ö§³ÖÐèÒªÍøÂçÅäÖÃÐÅÏ¢µÄÎÞÅ̹¤×÷Õ¾£¬¶ÔÐèÒª¹Ì¶¨IPµÄϵͳҲÌṩÁËÏàÓ¦Ö§³Ö¡£


3.2 ËùÐè×ÊÔ´

3.2.1 ËùÐè°ü
dhcp-2.0-5.i386.rpm

3.2.2 ËùÐèÅäÖÃÎļþ
/etc/dhcpd.conf ϵͳ×Ô´ø£¬¹ÜÀíÔ±ÅäÖÃ
/var/state/dhcp/dhcpd.leases ϵͳûÓУ¬¹ÜÀíÔ±´´½¨


3.3 ÅäÖ÷½°¸/etc/dhcpd.conf
˵Ã÷£ºdhcpÖ÷ÅäÖÃÎļþ
Ô´Îļþ£º
subnet 192.168.0.0 netmask 255.255.255.0 { # Ö¸¶¨Íø¶ÎºÍ×ÓÍøÑÚÂë
option routers 192.168.0.1;¡¡¡¡¡¡# Ö¸¶¨Ä¬ÈÏ·ÓÉ
option subnet-mask 255.255.255.0;¡¡¡¡# Ö¸¶¨dhcpµÄ×ÓÍøÑÚÂë
option domain-name "weboa.com.cn";¡¡ # Ö¸¶¨ÓòÃû
option domain-name-servers 192.168.0.1;¡¡# ĬÈÏDNS·þÎñÆ÷
range dynamic-bootp 192.168.0.10 192.168.0.250; # IP·ÖÅ䷶Χ
default-lease-time 1200;¡¡¡¡¡¡#Èç¹û¿Í»§¶Ë²»ÄÜÇëÇóÒ»¸öÖ¸¶¨µÄ×âÓÃÆÚ£¬¾Íʹ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ÓøòÎÊýÀ´¶¨Òå¸ÃµØÖ·×âÓõÄʱ¼ä³¤¶È
max-lease-time 87600;¡¡¡¡¡¡¡¡ #ÓÃÀ´Ö¸¶¨×âÓõÄ×ʱ¼ä£¬¾¡¹Ü×âÓõÄ
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ ʱ¼ä³¤¶ÈÊǸù¾Ý¿Í»§¶ËµÄÇëÇó¾ö¶¨µÄ¡£
# we want the nameserver to appear at a fixed address
# host ns {
# next-server marvin.redhat.com;
# hardware ethernet 12:34:56:78:AB:CD;
# fixed-address 207.175.42.254;
# }
}
# ÒÔÉϱ»×¢Ê͵IJ¿·ÖÓÃÀ´¸ø¿Í»§»ú·ÖÅäÒ»¸öÓÀ¾ÃµÄIP£¬Ò²¾ÍÊÇ¿ÉÒÔÀûÓÃËü
À´×öÍø¿¨ºÍIPµÄ°ó¶¨
/var/state/dhcp/dhcpd.leases
˵Ã÷£ºIP·ÖÅä¼Ç¼Îļþ
¡¡¡¡¡¡Í¨¹ýÖ´ÐÐ touch /var/state/dhcp/dhcpd.leasesÉú³É
Ô´Îļþ£º
¡¡¡¡¡¡¿Õ

3.4 ²âÊÔ¼°¹ÜÀí°ì·¨

3.4.1 ²âÊÔ·½·¨
1£® ¹ÜÀíÔ±ÐÞ¸ÄÍêÅäÖÃÎļþÖ®ºóÐèÒªÖ´ÐÐ/etc/rc.d/init.d/dhcpd restart
À´Ê¹¸ü¸ÄÉúЧ¡£
2£®ÔÚWindows 98µÄ¿Í»§¶Ë£¬Óû§ÐèÒª½«TCP/IPÅäÖóÉΪ×Ô¶¯ËÑË÷IP¡£
3£®ÔÚWindows 98µÄ¿Í»§¶Ë¿ÉÒÔÔËÐÐwinipcfgÀ´¶¯Ì¬ÉêÇëIP¡£
4£®¹ÜÀíÔ±¿ÉÒÔͨ¹ý²é¿´/var/state/dhcp/dhcpd.leasesÎļþÀ´¼à¶½IP×Ê
Ô´µÄ·ÖÅäÇé¿ö¡£

3.4.2 ¹ÜÀí·½·¨
1. ¿ÉÒÔͨ¹ýÖ´ÐÐ tail -f /var/state/dhcp/dhcpd.leasesÀ´¼àÊÓIPµÄ·ÖÅäÇé¿ö¡£


3.5 ÆäËû²Î¿¼×ÊÁÏ

1. ÔÚLinux¼¸ºõ¶¼²ÉÓõÄÊÇPaul Vixie/ISC DHCPd£¬À´ÊµÏÖDHCP·þÎñÆ÷¶Ë¹¦ÄÜ¡£¿ÉÒÔ·ÃÎÊ: http://www.isc.org/isc


3.6 С½á

ͨ¹ýѧϰ±¾Õ£¬¸÷λһ¶¨ÓÐÒ»¸ö¸Ð¾õ£¬¾ÍÊÇDHCPµÄÅäÖÃÊ®·ÖµÄ¼òµ¥¡£ÔÚÒ»¶¨³Ì¶ÈÉÏÊÇÕâÑùµÄ£¬ÒòΪÎÒÏò´ó¼Ò½éÉܵÄÊÇһ̨Ö÷·þÎñÆ÷´øÒ»¸ö×ÓÍø£¬ÕâÊÇ×î¼òµ¥µÄÒ»ÖÖÍøÂçÍØÆ˽ṹ£¬ÒªÊǸü¼Ó¸´ÔӵĶà×ÓÍøÇé¿ö£¬ÄÇÅäÖÃÆðÀ´¾ÍÒª¸ü¼ÓÂé·³Ò»µã£¬Õâ¾ÍÐèҪΪÿ¸ö×ÓÍøÅäÖÃÒ»¸öÖм̴úÀí£¨dhcrelay£©£¬ËüµÄÎĵµÔÚLinuxÖж¼¿ÉÒÔÕÒµ½£¬Ò»¿´¾ÍÄÜÃ÷°×ÁË¡£