Static DHCP/zh cn

From DD-WRT Wiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 12:55, 8 January 2011 (edit)
Leangjia (Talk | contribs)
(New page: {{languages|Static_DHCP}} Static [http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol DHCP] (aka DHCP reservation) is a useful feature which makes the DHCP server on your rout...)
← Previous diff
Revision as of 13:20, 8 January 2011 (edit) (undo)
Leangjia (Talk | contribs)

Next diff →
Line 1: Line 1:
{{languages|Static_DHCP}} {{languages|Static_DHCP}}
-Static [http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol DHCP] (aka DHCP reservation) is a useful feature which makes the DHCP server on your router always assign the '''same''' [http://en.wikipedia.org/wiki/IP_address IP address] to a specific computer on your [http://en.wikipedia.org/wiki/LAN LAN]. To be more specific, the DHCP server assigns this static IP to a '''unique''' [http://en.wikipedia.org/wiki/MAC_address MAC address] assigned to each [http://en.wikipedia.org/wiki/Network_Interface_Controller NIC] on your LAN. Your computer boots and requests its IP from the router's DHCP server. The DHCP server recognizes the MAC address of your device's NIC and assigns the static IP address to it. (Note also that, currently, each reserved IP address must also be unique. Therefore, e.g., one cannot reserve the same IP address for both the wired and wireless interfaces of a device, even though the device may be configured such that only one interface is active at any given time.)+静态 [http://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol DHCP] (又名 DHCP 保留) 是个相当有用处的功能,它可使您的DHCP服务器分配IP时给[http://en.wikipedia.org/wiki/LAN 局域网]内特定的计算机分配固定的[http://en.wikipedia.org/wiki/IP_address IP地址]。 具体就是说,DHCP服务器分配固定IP给指定的[http://en.wikipedia.org/wiki/MAC_address MAC地址] 。DHCP服务器确认您网卡的MAC地址并将静态IP地址分配给它。(还要注意的是,目前,每个保留的IP地址也必须是唯一的。因此,如不能保留有线和无线设备的接口相同的IP地址,即使该设备可进行配置,只有一个接口在任何特定时间内启动。)
-Static DHCP will be needed if you want an interface to always have the same IP address. Sometimes required for certain programs, this feature is useful if other people on your LAN know your IP and access your PC using this IP. Static DHCP should be used in conjuction with [[Port_Forwarding|Port Forwarding]]. If you forward an external WAN TCP/UDP port to a port on a server running inside your LAN, you have to give that server a static IP, and this can be achieved easily through Static DHCP. +静态DHCP将需要一个接口,如果你想总是有相同的IP地址。有时需要对某些程序,这个功能是有用的,如果你的局域网上的其他人知道你的IP和访问您的电脑使用此IP。 静态DHCP一起选择应使用与[Port_Forwarding|端口转发]]。 如果您转发外部广域网的TCP/ UDP端口上的一个局域网内正在运行的服务器端口,你必须给该服务器一个静态的IP,这可以通过静态DHCP容易。
 +[[Image:DD-WRT_Static_DHCP.jpg|center|DD-WRT v24-sp2 (10/10/09) mega(SVN revision 13064)静态DHCP设置页面,leangjia截图]]
-[[Image:DD-WRT_Port_Forward_Web_GUI_v24.gif|center|v23 Port Forwarding section in the Web GUI]]+=设置=
- +# 登陆 DD-WRT的 Web管理界面
-=Configuration=+# 找到【服务】标签项
-# Log into the DD-WRT Web GUI+# 找到【DHCP 服务器】项
-# Go to the Services tab+# 刚开始项下的【永久租用】应该是尚未有数据的,单击【添加】,填写【MAC地址】【 主机名】【 IP地址】 三项数据,即可达到目的了
-# DHCP Daemon should be enabled+# 切记:滚动条拉到底部,【保存设置】,【应用】。
-# If there is no blank slot under "Static Leases", click Add+'''注意: 您必须保存每个页面或应用,填补您添加了一个新的静态租用时间。点击添加按钮刷新不保存你输入的页面。如果您尝试将多个空白租约,并填写他们都撵出去一次,那么你将遇到一个错误,认为他们是在GUI重复的条目。'''
-# Enter the MAC address of the client interface, the hostname of the machine, and the desired IP address for this machine. Note that you cannot reserve the same IP address for two different MAC addresses (e.g. both the wired and wireless interfaces of a device).+
-# Scroll to the bottom of the page and save your changes.+
-'''Note: You must either Save or Apply the page each time you've added and filled out a new static lease. Clicking the Add button refreshes the page without saving what you entered. If you try to add multiple blank leases and fill them all out at once then you will encounter a bug that the GUI thinks they are duplicate entries.'''+
[[Image:DHCP_Static_Lease_GUI_-_build_15704.png|center]] [[Image:DHCP_Static_Lease_GUI_-_build_15704.png|center]]
'''Note:''' A blank lease duration means it will be an infinite lease (never expires). Setting a lease duration will allow you to change the static lease information later on and have the host automatically get the new information without having to manually release/renew the lease on the host. '''Note:''' A blank lease duration means it will be an infinite lease (never expires). Setting a lease duration will allow you to change the static lease information later on and have the host automatically get the new information without having to manually release/renew the lease on the host.

Revision as of 13:20, 8 January 2011

静态 DHCP (又名 DHCP 保留) 是个相当有用处的功能,它可使您的DHCP服务器分配IP时给局域网内特定的计算机分配固定的IP地址。 具体就是说,DHCP服务器分配固定IP给指定的MAC地址 。DHCP服务器确认您网卡的MAC地址并将静态IP地址分配给它。(还要注意的是,目前,每个保留的IP地址也必须是唯一的。因此,如不能保留有线和无线设备的接口相同的IP地址,即使该设备可进行配置,只有一个接口在任何特定时间内启动。)

静态DHCP将需要一个接口,如果你想总是有相同的IP地址。有时需要对某些程序,这个功能是有用的,如果你的局域网上的其他人知道你的IP和访问您的电脑使用此IP。 静态DHCP一起选择应使用与[Port_Forwarding|端口转发]]。 如果您转发外部广域网的TCP/ UDP端口上的一个局域网内正在运行的服务器端口,你必须给该服务器一个静态的IP,这可以通过静态DHCP容易。

DD-WRT v24-sp2 (10/10/09) mega(SVN revision 13064)静态DHCP设置页面,leangjia截图

Contents

设置

  1. 登陆 DD-WRT的 Web管理界面
  2. 找到【服务】标签项
  3. 找到【DHCP 服务器】项
  4. 刚开始项下的【永久租用】应该是尚未有数据的,单击【添加】,填写【MAC地址】【 主机名】【 IP地址】 三项数据,即可达到目的了
  5. 切记:滚动条拉到底部,【保存设置】,【应用】。

注意: 您必须保存每个页面或应用,填补您添加了一个新的静态租用时间。点击添加按钮刷新不保存你输入的页面。如果您尝试将多个空白租约,并填写他们都撵出去一次,那么你将遇到一个错误,认为他们是在GUI重复的条目。

Note: A blank lease duration means it will be an infinite lease (never expires). Setting a lease duration will allow you to change the static lease information later on and have the host automatically get the new information without having to manually release/renew the lease on the host.

DHCP Options

The DHCP system assigns IP addresses to your local devices. While the main configuration is on the setup page you can program some nifty special functions here.

DHCP Daemon: Disabling here will disable DHCP on this router irrespective of the settings on the Setup screen.

Used domain: You can select here which domain the DHCP clients should get as their local domain. This can be the WAN domain set on the Setup screen or the LAN domain which can be set here.

LAN Domain: You can define here your local LAN domain which is used as local domain for DNSmasq and DHCP service if chosen above.

Static Leases: Assign certain hosts specific addresses here. This is also a way to add hosts to the router's local DNS service (DNSmasq).

Note: It is recommended but not necessary to set your static leases outside of your automatic DHCP address range. This range is 192.168.1.100-192.168.1.149 by default and can be configured under Setup -> Basic Setup : Network Address Server Settings (DHCP).

Example

To assign the IP address 192.168.1.12 and the hostname "mypc" to a PC with a network card having the MAC address 00:AE:0D:FF:BE:56 you should press Add then enter 00:AE:0D:FF:BE:56 into the MAC field, mypc into the HOST field and 192.168.1.12 into the IP field.

Remember: If you press the 'Add' button before saving the entries you just made, they will be cleared. This is normal behavior in v24.

How to add static leases into dhcp by command

nvram set static_leasenum=X (where X is the total number of static leases)
nvram set static_leases="00:11:22:33:44:55=name1=IP-Address1 00:11:22:33:44:56=name2=IP-Address2"


If more than two...just keep adding them to the static_leases variable with a space between each.

Don't forget the double quotes...if you have any spaces (more than one lease) you must include the quotes to the variable.

redhawk

NOTE: Starting with build 13832 the format has changed to the following:

nvram set static_leasenum=X (where X is the total number of static leases)
nvram set static_leases="00:11:22:33:44:55=name1=IP-Address1= 00:11:22:33:44:56=name2=IP-Address2="

or

nvram set static_leases="00:11:22:33:44:55=name1=IP-Address1= 00:11:22:33:44:56=name2=IP-Address2=1440"

Note the '=' sign at the end of each lease. If you want to set static lease time then put a number after the last '=' to set time in minutes...in the second cases above a blank after the = sign means its an indefinite lease, 1440=24 hours.

Troubleshooting

If you cannot ping a hostname, append a period to the end. I.e. instead of "ping server" try "ping server."

If the static reservations are visible, but your machines continue to get a normal DHCP IP try going to the Setup page. Hit Save and then Apply settings. The DHCP daemon should restart and you may lose connection briefly. Try renewing your DHCP lease and you should be getting the correct IP at this point.