Skip to content

安装DHCP自动为内网分配IP地址

2009 十月 21
by 荒野无灯

假设 “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

喜欢这篇文章吗?

请订阅本站 RSS feed填写您的邮件地址,订阅我们的精彩内容:,欢迎点击这里捐赠以支持荒野无灯转播到腾讯微博 转播到腾讯微博

作者:荒野无灯
出处:Hacklog【Hacklog】

声明: 本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自Hacklog【荒野无灯weblog】

本文链接: http://ihacklog.com/?p=2737

2 Responses Post a comment
  1. 十月 22, 2009

    灯兄的linux用得很好哦~

  2. 十月 21, 2009

    原来又是Ubuntu

Leave a Reply

Allowed Tags - You may use these HTML tags and attributes in your comment.

<a href="" title=""> <abbr title=""> <acronym title=""> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <q cite=""> <strong>

 :wink:  :-|  :-x  :twisted:  :)  8-O  :(  :roll:  :-P  :oops:  :-o  :mrgreen:  :lol:  :idea:  :-D  :evil:  :cry:  8)  :arrow:  :-?  :?:  :!:

Note: You may use basic HTML in your comments. Your email address will not be published.

Subscribe to this comment feed via RSS