安裝套件
$
sudo
apt-get
install
isc-dhcp-server -y
|
$
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;
}
|
$
sudo
vim
/etc/default/isc-dhcp-server
|
INTERFACES="eth2"
|
$
sudo
vim
/etc/network/interfaces
|
auto eth2
iface eth2 inet static
address 192.168.1.1
netmask 255.255.255.0
|
# Ubuntu 14.04
$
sudo
ifdown eth2;
sudo
ifup eth2
|
# Ubuntu 12.04
$
sudo
service networking restart
|
$
sudo
service isc-dhcp-server restart
|
$
sudo
service isc-dhcp-server start|stop|status
|
# 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
|
# 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
|
$
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;
}
|
$
sudo
vim
/etc/default/dhcp3-server
|
INTERFACES="eth2"
|
$
sudo
vim
/etc/network/interfaces
|
auto eth2
iface eth2 inet static
address 192.168.1.1
netmask 255.255.255.0
|
$
sudo
/etc/init
.d
/networking
restart
|
$
sudo
/etc/init
.d
/dhcp3-server
restart
|
$
sudo
/etc/init
.d
/dhcp3-server
start|stop|status
|
$
sudo
update-rc.d isc-dhcp-server disable
|
$
sudo
update-rc.d isc-dhcp-server
enable
|