Ubuntu 12.04 安裝使用dhcp server

來源:互聯網
上載者:User

簡單的DHCP server

在建立HDFS叢集的時候,深感/etc/hosts中添加配置的不方便,容易不一致導致錯誤,工作量也大。

還是在區域網路內建立dhcp伺服器來的方便。官方文檔:https://help.ubuntu.com/community/isc-dhcp-server

先建立一台KVM虛擬機器,OS為Ubuntu 12.04.

然後安裝dhcp3 server

apt-get install isc-dhcp-server
編輯檔案/etc/default/isc-dhcp-server

填入eth0

INTERFACES="eth0"

編輯檔案:/etc/dhcp/dhcpd.conf

修改原來的example.org的設定為:

# option definitions common to all supported networks...                                                                                          option domain-name "hadoop.cn";option domain-name-servers dhcp.hadoop.cn, namenode1.hadoop.cn, namenode2.hadoop.cn, datanode1.hadoop.cn, datanode2.hadoop.cn, datanode3.hadoop.cn, datanode4.had\oop.cn, datanode5.hadoop.cn, datanode6.hadoop.cn;

增加租期時間:

default-lease-time 6000;                                                                                                                          max-lease-time 72000;

再添加下面的配置:

option routers 192.168.1.1;subnet 192.168.1.0 netmask 255.255.255.0 {       range 192.168.1.10 192.168.1.100;       option domain-name-servers 192.168.1.1;       option broadcast-address 192.168.1.255;}

包括router地址, IP位址範圍,DNS server IP, 廣播IP地址等。

服務命令:

service isc-dhcp-server start

注意,dhcp使用的地址必須是和eth0在一個網段。否則啟動會失敗。


基於Virutal IP建立

因為我實際上希望能夠在另一個網段用DHCP分配地址,所以在/etc/network/interfaces檔案中建立新的虛擬IP地址:

不用eth0:1 這種方式。

# The primary network interfaceauto eth0iface eth0 inet static        address 192.168.1.111        netmask 255.255.255.0        network 192.168.1.0        broadcast 192.168.1.255        gateway 192.168.1.1        # dns-* options are implemented by the resolvconf package, if installed        dns-nameservers 8.8.8.8        dns-search defaultdomainiface eth0 inet staticaddress 192.168.4.1netmask 255.255.255.0

然後在/etc/default/isc-dhcp-server裡面

INTERFACES="eth0"


然後將上面dhcpd.conf中的所有192.168.1.X都換成192.168.4.X即可。重新啟動,成功!



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.