特殊:Badtitle/NS100:Dhcp3-server:修订间差异
小 新页面: {{From|https://help.ubuntu.com/community/dhcp3-server}} {{Languages|UbuntuHelp:dhcp3-server}} == Dynamic Host Configuration Protocol (DHCP) == The Dynamic Host Configuration Protocol (DHC... |
小无编辑摘要 |
||
第139行: | 第139行: | ||
</nowiki></pre> | </nowiki></pre> | ||
---- | ---- | ||
[[category:UbuntuHelp]] | [[category:UbuntuHelp]] |
2009年5月12日 (二) 16:24的最新版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/dhcp3-server }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/af | • {{#if: UbuntuHelp:dhcp3-server|Afrikaans| [[::Dhcp3-server/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ar | • {{#if: UbuntuHelp:dhcp3-server|العربية| [[::Dhcp3-server/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/az | • {{#if: UbuntuHelp:dhcp3-server|azərbaycanca| [[::Dhcp3-server/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/bcc | • {{#if: UbuntuHelp:dhcp3-server|جهلسری بلوچی| [[::Dhcp3-server/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/bg | • {{#if: UbuntuHelp:dhcp3-server|български| [[::Dhcp3-server/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/br | • {{#if: UbuntuHelp:dhcp3-server|brezhoneg| [[::Dhcp3-server/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ca | • {{#if: UbuntuHelp:dhcp3-server|català| [[::Dhcp3-server/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/cs | • {{#if: UbuntuHelp:dhcp3-server|čeština| [[::Dhcp3-server/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/de | • {{#if: UbuntuHelp:dhcp3-server|Deutsch| [[::Dhcp3-server/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/el | • {{#if: UbuntuHelp:dhcp3-server|Ελληνικά| [[::Dhcp3-server/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/es | • {{#if: UbuntuHelp:dhcp3-server|español| [[::Dhcp3-server/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/fa | • {{#if: UbuntuHelp:dhcp3-server|فارسی| [[::Dhcp3-server/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/fi | • {{#if: UbuntuHelp:dhcp3-server|suomi| [[::Dhcp3-server/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/fr | • {{#if: UbuntuHelp:dhcp3-server|français| [[::Dhcp3-server/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/gu | • {{#if: UbuntuHelp:dhcp3-server|ગુજરાતી| [[::Dhcp3-server/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/he | • {{#if: UbuntuHelp:dhcp3-server|עברית| [[::Dhcp3-server/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/hu | • {{#if: UbuntuHelp:dhcp3-server|magyar| [[::Dhcp3-server/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/id | • {{#if: UbuntuHelp:dhcp3-server|Bahasa Indonesia| [[::Dhcp3-server/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/it | • {{#if: UbuntuHelp:dhcp3-server|italiano| [[::Dhcp3-server/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ja | • {{#if: UbuntuHelp:dhcp3-server|日本語| [[::Dhcp3-server/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ko | • {{#if: UbuntuHelp:dhcp3-server|한국어| [[::Dhcp3-server/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ksh | • {{#if: UbuntuHelp:dhcp3-server|Ripoarisch| [[::Dhcp3-server/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/mr | • {{#if: UbuntuHelp:dhcp3-server|मराठी| [[::Dhcp3-server/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ms | • {{#if: UbuntuHelp:dhcp3-server|Bahasa Melayu| [[::Dhcp3-server/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/nl | • {{#if: UbuntuHelp:dhcp3-server|Nederlands| [[::Dhcp3-server/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/no | • {{#if: UbuntuHelp:dhcp3-server|norsk| [[::Dhcp3-server/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/oc | • {{#if: UbuntuHelp:dhcp3-server|occitan| [[::Dhcp3-server/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/pl | • {{#if: UbuntuHelp:dhcp3-server|polski| [[::Dhcp3-server/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/pt | • {{#if: UbuntuHelp:dhcp3-server|português| [[::Dhcp3-server/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ro | • {{#if: UbuntuHelp:dhcp3-server|română| [[::Dhcp3-server/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/ru | • {{#if: UbuntuHelp:dhcp3-server|русский| [[::Dhcp3-server/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/si | • {{#if: UbuntuHelp:dhcp3-server|සිංහල| [[::Dhcp3-server/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/sq | • {{#if: UbuntuHelp:dhcp3-server|shqip| [[::Dhcp3-server/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/sr | • {{#if: UbuntuHelp:dhcp3-server|српски / srpski| [[::Dhcp3-server/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/sv | • {{#if: UbuntuHelp:dhcp3-server|svenska| [[::Dhcp3-server/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/th | • {{#if: UbuntuHelp:dhcp3-server|ไทย| [[::Dhcp3-server/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/tr | • {{#if: UbuntuHelp:dhcp3-server|Türkçe| [[::Dhcp3-server/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/vi | • {{#if: UbuntuHelp:dhcp3-server|Tiếng Việt| [[::Dhcp3-server/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/yue | • {{#if: UbuntuHelp:dhcp3-server|粵語| [[::Dhcp3-server/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/zh | • {{#if: UbuntuHelp:dhcp3-server|中文| [[::Dhcp3-server/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/zh-hans | • {{#if: UbuntuHelp:dhcp3-server|中文(简体)| [[::Dhcp3-server/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:dhcp3-server | UbuntuHelp:dhcp3-server | {{#if: | :}}Dhcp3-server}}/zh-hant | • {{#if: UbuntuHelp:dhcp3-server|中文(繁體)| [[::Dhcp3-server/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:dhcp3-server|:Dhcp3-server|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :Dhcp3-server/zh | | {{#ifexist: Dhcp3-server/zh | | {{#ifeq: {{#titleparts:Dhcp3-server|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:Dhcp3-server|1|-1|}} | zh | | }}
Dynamic Host Configuration Protocol (DHCP)
The Dynamic Host Configuration Protocol (DHCP) is a network service that enables host computers to be automatically assigned settings from a server as opposed to manually configuring each network host. Computers configured to be DHCP clients have no control over the settings they receive from the DHCP server, and the configuration is transparent to the computer's user.
Installation
At a terminal prompt, enter the following command to install dhcpd:
sudo apt-get install dhcp3-server
You will probably need to change the default configuration by editing /etc/dhcp3/dhcpd.conf to suit your needs and particular configuration. You also need to edit /etc/default/dhcp3-server to specify the interfaces dhcpd should listen to. By default it listens to eth0.
Configuration
The error message the installation ends with might be a little confusing, but the following steps will help you configure the service: Most commonly, what you want to do is assign an IP address randomly. This can be done with settings as follows:
nano -w /etc/dhcp3/dhcpd.conf
# Sample /etc/dhcpd.conf # (add your comments here) default-lease-time 600; max-lease-time 7200; option subnet-mask 255.255.255.0; option broadcast-address 192.168.1.255; option routers 192.168.1.254; option domain-name-servers 192.168.1.1, 192.168.1.2; option domain-name "mydomain.example"; subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.10 192.168.1.100; range 192.168.1.150 192.168.1.200; }
This will result in the DHCP server giving a client an IP address from the range 192.168.1.10-192.168.1.100 or 192.168.1.150-192.168.1.200. It will lease an IP address for 600 seconds if the client doesn't ask for a specific time frame. Otherwise the maximum (allowed) lease will be 7200 seconds. The server will also "advise" the client that it should use 255.255.255.0 as its subnet mask, 192.168.1.255 as its broadcast address, 192.168.1.254 as the router/gateway and 192.168.1.1 and 192.168.1.2 as its DNS servers. If you need to specify a WINS server for your Windows clients, you will need to include the netbios-name-servers option, e.g.
nano -w /etc/default/dhcp3-server
option netbios-name-servers 192.168.1.1;
dhcp3-server and multiple interfaces
multiple interfaces example
Interface
nano -w /etc/network/interfaces
auto lo iface lo inet loopback mapping hotplug script grep map eth1 iface eth1 inet dhcp auto eth0 iface eth0 inet static address 10.152.187.1 netmask 255.255.255.0 auto wlan0 iface wlan0 inet static address 192.168.1.1 netmask 255.255.255.0 up /sbin/iwconfig wlan0 mode TTTTTT && /sbin/iwconfig wlan0 enc restricted && /sbin/iwconfig wlan0 key [Y] XXXXXXXX && /sbin/iwconfig wlan0 essid SSSSSSSS auto eth1
Select Interface card
nano -w /etc/default/dhcp3-server
INTERFACES="wlan0 eth0"
Configure Subnet
nano -w /etc/dhcp3/dhcpd.conf
ddns-update-style none; log-facility local7; subnet 192.168.1.0 netmask 255.255.255.0 { option routers 192.168.1.1; option subnet-mask 255.255.255.0; option broadcast-address 192.168.1.255; option domain-name-servers 194.168.4.100; option ntp-servers 192.168.1.1; option netbios-name-servers 192.168.1.1; option netbios-node-type 2; default-lease-time 86400; max-lease-time 86400; host bla1 { hardware ethernet DD:GH:DF:E5:F7:D7; fixed-address 192.168.1.2; } host bla2 { hardware ethernet 00:JJ:YU:38:AC:45; fixed-address 192.168.1.20; } } subnet 10.152.187.0 netmask 255.255.255.0 { option routers 10.152.187.1; option subnet-mask 255.255.255.0; option broadcast-address 10.152.187.255; option domain-name-servers 194.168.4.100; option ntp-servers 10.152.187.1; option netbios-name-servers 10.152.187.1; option netbios-node-type 2; default-lease-time 86400; max-lease-time 86400; host bla3 { hardware ethernet 00:KK:HD:66:55:9B; fixed-address 10.152.187.2; } }
Check Route
route -n
Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 wlan0 82.16.TT.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 10.152.187.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 0.0.0.0 82.16.TT.UU 0.0.0.0 UG 0 0 0 eth1