安裝Ubuntu DHCP Server

 
安裝環境Ubuntu 12.04, 14.04 或 16.04
安裝套件
$ sudo  apt-get install  isc-dhcp-server -y
配置DHCP Server
$ sudo  vim /etc/dhcp/dhcpd .conf
新增下面內容:
default-lease-time 600;
max-lease-time 7200;
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;
   option subnet-mask 255.255.255.0;
   option broadcast-address 192.168.1.255;
   option routers 192.168.1.1;
   option domain-name-servers 192.168.1.1, 192.168.1.2;
}
修改/etc/default/isc-dhcp-server
$ sudo  vim /etc/default/isc-dhcp-server
找到INTERFACES=""這行並修改,指定DHCP Server所使用的網路卡:
INTERFACES="eth2"
修改/etc/network/interfaces
$ sudo  vim /etc/network/interfaces
配置eth2網路卡,新增下面內容:
auto eth2
iface eth2 inet static
     address 192.168.1.1
     netmask 255.255.255.0
讓eth2網路卡設定生效
# Ubuntu 14.04
$ sudo  ifdown eth2; sudo  ifup eth2
# Ubuntu 12.04
$ sudo  service networking restart
重新啟動DHCP Server
$ sudo  service isc-dhcp-server restart
DHCP Server 啟動|停止|狀態
$ sudo  service isc-dhcp-server start|stop|status
開機不要啟動DHCP Server
# Ubuntu 16.04
$ sudo  update-rc.d isc-dhcp-server disable
# Ubuntu 14.04 與 Ubuntu 12.04
$ echo  manual | sudo  tee  -a /etc/init/isc-dhcp-server .override
開機啟動DHCP Server
# Ubuntu 16.04
$ sudo  update-rc.d isc-dhcp-server enable
# Ubuntu 14.04 與 Ubuntu 12.04
$ sudo  rm  -f /etc/init/isc-dhcp-server .override

安裝環境Ubuntu 10.04
安裝套件
$ sudo  apt-get install  dhcp3-server -y
配置DHCP Server
$ sudo  vim /etc/dhcp3/dhcpd .conf
新增下面內容:
default-lease-time 600;
max-lease-time 7200;
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;
   option subnet-mask 255.255.255.0;
   option broadcast-address 192.168.1.255;
   option routers 192.168.1.1;
   option domain-name-servers 192.168.1.1, 192.168.1.2;
}
修改/etc/default/dhcp3-server
$ sudo  vim /etc/default/dhcp3-server
找到INTERFACES=""這行並修改,指定DHCP Server所使用的網路卡:
INTERFACES="eth2"
修改/etc/network/interfaces
$ sudo  vim /etc/network/interfaces
配置eth2網路卡,新增下面內容:
auto eth2
iface eth2 inet static
     address 192.168.1.1
     netmask 255.255.255.0
讓eth2網路卡設定生效
$ sudo  /etc/init .d /networking  restart
重新啟動DHCP Server
$ sudo  /etc/init .d /dhcp3-server  restart
DHCP Server 啟動|停止|狀態
$ sudo  /etc/init .d /dhcp3-server  start|stop|status
開機不要啟動DHCP Server
$ sudo  update-rc.d isc-dhcp-server disable
開機啟動DHCP Server
$ sudo  update-rc.d isc-dhcp-server enable

你可能感兴趣的:(linux)