Unbuntu12.04系统安装配置DHCP服务器

1、DHCP服务器两种配置方法:

  地址池:指定了一个用来动态的提供给第一个访问网络的DHCP客户端的IP地址池。当DHCP客户端离开网络超过一定时间后,IP地址就会被回收到地址池以供其它DHCP客户端使用。

  MAC地址:这种方法强制使用DHCP来区别每一块连接上网络的网卡的硬件地址,之后这块网卡每次连上网络请求DHCP服务时都为它提供这个固定的IP地址。

2、在ubuntu中安装DHCP服务

  sudo apt-getinstall isc-dhcp-server

  完成安装了。

3、配置DHCP服务器

  如果你的Ubuntu服务器上用友2块网卡,你需要选择一块网卡用来监听DHCP服务。默认监听的是eth0。可以通过编辑 /etc/default/isc-dhcp-server来改变监听的网卡。

sudo vi /etc/default/isc-dhcp-server

  

[plain] view plain copy
  1. <span style="font-size:18px;">#Defaults for dhcp initscript  
  2.  #sourced by /etc/init.d/dhcp  
  3.  #installed at /etc/default/isc-dhcp-server by the maintainer scripts  
  4.  #  
  5.  #This is a POSIX shell fragment  
  6.  #  
  7.  #On what interfaces should the DHCP server (dhcpd) serve DHCP requests?  
  8.  #Separate multiple interfaces with spaces, e.g. “eth0 eth1?.  
  9.  INTERFACES=“etho”</span>  

  INTERFACES=”eth0″

  使用下面这行替代它

  INTERFACES=”eth1″

  保存并退出。

  接下来你需要为/etc/dhcp/dhcpd.conf文件创建一个备份:

  sudo cp/etc/dhcp/dhcpd.conf  /etc/dhcp/dhcpd.conf.back

  使用下面的命令编辑/etc/dhcp/dhcpd.conf文件

  sudo vi/etc/dhcp/dhcpd.conf

  使用地址池的方法

  你需要修改/etc/dhcp/dhcpd.conf这个配置文件的以下部分:

  1. <span style="font-size:18px;">ddns-update-style none;  
  2.  #option definitions common to all supported networks…  
  3.  option domain-name-servers ns1.example.org, ns2.example.org;  
  4.  option domain-name “yourdomainname.com”;  
  5.  default-lease-time 600;  
  6.  max-lease-time 7200;  
  7.  #If this DHCP server is the official DHCP server for the local  
  8.  #network, the authoritative directive should be uncommented.  
  9.  #authoritative;  
  10.  #Use this to send dhcp log messages to a different log file (you also  
  11.  #have to hack syslog.conf to complete the redirection).  
  12.  log-facility local7;  
  13.  #No service will be given on this subnet, but declaring it helps the  
  14.  #DHCP server to understand the network topology.  
  15.  #subnet10.152.187.0 netmask 255.255.255.0 {  
  16.  #}  
  17.  #This is a very basic subnet declaration.  
  18.  subnet 10.0.0.0 netmask 255.255.255.0 {  
  19.  range 10.0.0.150 10.0.0.253;  
  20.  option routers 10.0.0.2;  
  21.  option subnet-mask 255.255.255.0;  
  22.  option broadcast-address 10.0.0.254;  
  23.  option domain-name-servers 10.0.0.1, 10.0.0.2;  
  24.  option ntp-servers 10.0.0.1;  
  25.  option netbios-name-servers 10.0.0.1;  
  26.  option netbios-node-type 8;  
  27.  }</span>  

  保存并退出文件

  这会导致服务器提供一个从10.0.0.100 10.0.0.253这个范围的IP地址给客户端。如果客户端没有请求一个租期的话,服务器会默认提供600秒的地址租期给客户端。最大的(允许的)地址租期是7200秒。

  重启dhcp服务器

  sudo service isc-dhcp-server restart

  配置Ubuntu的DHCP客户端

  如果你想配置另一台ubuntu机子为DHCP客户机,使用以下步骤。打开/etc/network/interface文件

  sudo vi/etc/network/interfaces

  进行如下配置,这里为etho网卡设置动态获取ip:

[plain] view plain copy
  1. <span style="font-size:18px;"> auto lo eth0  
  2.  iface eth0 inet dhcp  
  3.  iface lo inet loopback</span>  

  保存并退出文件

  客户机配置完interfaces需重启网络服务

  sudo /etc/init.d/networking restart

       或sudo service networking restart

  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值