2008年9月2日 星期二

如何設定兩個DHCP在Ubuntu

先描述一下環境,一共有三張網路卡,而它們的預定的分配情形如下:
eth0 (對外網路),使用浮動虛擬IP
eth1 (對內網路,DHCP-1), 使用192.168.5.0/24網段
eth2 (對內網路,DHCP-2), 使用192.168.6.0/24網段

Step 1. 安裝DHCP Server
輸入指令:
sudo apt-get install dhcp3-server

Step 2. 設定Network card 的介面
輸入指令:
sudo gedit /etc/network/interfaces

編輯下列的文檔:
auto loiface lo
inet loopback

auto eth1
iface eth1 inet static
address 192.168.5.254
netmask 255.255.255.0

auto eth2
iface eth2 inet static
address 192.168.6.254
netmask 255.255.255.0

Step 3. Restart 網路設定
輸入指令:
sudo /etc/init.d/networking restart

Step 4. 修改dhcp3-server 文檔
輸入指令:
sudo gedit /etc/default/dhcp3-server

編輯文檔
INTERFACES="eth1 eth2"

Step 5. 修改/etc/dhcp3/dhcpd.conf 文檔
輸入指令
sudo gedit /etc/dhcp3/dhcpd.conf

編輯文檔
將其不必要的內容用#註解,然後輸入以下的設定

subnet 192.168.5.0 netmask 255.255.255.0 {
range 192.168.5.1 192.168.5.253;
option routers 192.168.5.1;
option domain-name-servers 168.95.1.1;
option domain-name-servers ae1.com;
option broadcast-address 192.168.5.255;
default-lease-time 600;
max-lease-time 7200;
}


subnet 192.168.6.0 netmask 255.255.255.0 {
range 192.168.6.1 192.168.6.253;
option routers 192.168.6.1;
option domain-name-servers 168.95.1.1;
option domain-name-servers ae2.com;
option broadcast-address 192.168.6.255;
default-lease-time 600;
max-lease-time 7200;
}


Step 5. Restart DHCP Server
輸入指令:
sudo /etc/init.d/dhcp3-server restart

備註:以上的設定方式只有將DHCP Server安裝在eth1及eth2,但eth1及eth2並無法透過eth0上網,若要這麼做則要修改iptable,或利用ubuntu內建的Firestarter讓eth1或eth2透過eth0上網,但Firestarter是無法同時讓eth1或eth2同時上網,但要達成此情形,則要修改iptable方式來做.我們將在下面的文章介紹

沒有留言: