安装DHCP自动为内网分配IP地址
2009 十月 21
假设 “eth0″ 是我们的网络卡的接口
IP Address Range: 192.168.1.3 to 192.168.1.253
Subnet Mask: 255.255.255.0
DNS Servers: 192.168.1.2, 61.234.254.6
Domains: phper.huangyewudeng.my
Gateway Address: 192.168.1.254
呵呵,其实这也不是假设,这就是我机子目前的配置。其中192.168.1.254是代理上网网关的地址,192.168.1.2是我本机的地址,而且本机充当DNS服务器(我机子安装了bind9 ).
先安装DHCP3:
1 | sudo apt-get install dhcp3-server |
1 2 | sudo cp /etc/default/dhcp3-server /etc/default/dhcp3-server_backup sudo vim /etc/default/dhcp3-server |
确保其内容为:
INTERFACES=”eth0″
保存编辑过的文件 。
接下来编辑dhcp配置文件:
1 2 | sudo cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf_backup sudo vim /etc/dhcp3/dhcpd.conf |
查找:
1 2 3 4 5 | # option definitions common to all supported networks... option domain-name "example.org"; option domain-name-servers ns1.example.org, ns2.example.org; default-lease-time 600; max-lease-time 7200; |
将这几行全部用#注释掉,变为:
1 2 3 4 5 6 | # option definitions common to all supported networks... #option domain-name "example.org"; #option domain-name-servers ns1.example.org, ns2.example.org; #default-lease-time 600; #max-lease-time 7200; |
搜寻这一段文字:
1 2 3 4 5 6 7 8 9 10 11 | # A slightly different configuration for an internal subnet. #subnet 10.5.5.0 netmask 255.255.255.224 { # range 10.5.5.26 10.5.5.30; # option domain-name-servers ns1.internal.example.org; # option domain-name "internal.example.org"; # option routers 10.5.5.1; # option broadcast-address 10.5.5.31; # default-lease-time 600; # max-lease-time 7200; #} |
修改为:
1 2 3 4 5 6 7 8 9 10 11 | # A slightly different configuration for an internal subnet. subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.3 192.168.1.253; option domain-name-servers 192.168.1.2, 61.234.254.6; option domain-name "internal.example.org"; option routers 192.168.1.254; option broadcast-address 192.168.1.255; default-lease-time 600; max-lease-time 7200; } |
保存后,重启dhcp服务:
1 | sudo /etc/init.d/dhcp3-server restart |
2 Responses
Post a comment






灯兄的linux用得很好哦~
原来又是Ubuntu