Install and use dhcp server in Ubuntu 12.04

Source: Internet
Author: User

Simple DHCP server

When creating an HDFS cluster, I deeply feel that it is inconvenient to add the configuration in/etc/hosts. inconsistency may cause errors and heavy workload.

It is also convenient to create a dhcp server in the LAN. Official documents: https://help.ubuntu.com/community/isc-dhcp-server

First, create a KVM virtual machine. The OS is Ubuntu 12.04.

Then install the dhcp3 server

apt-get install isc-dhcp-server
Edit the/etc/default/isc-dhcp-server File

Enter eth0

INTERFACES="eth0"

Edit the file:/etc/dhcp/dhcpd. conf

Modify the original example.org settings:

# 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;

Added lease period:

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

Add the following Configuration:

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;}

Including the router address, IP address range, DNS server IP address, and broadcast IP address.

Service command:

service isc-dhcp-server start

Note that the IP address used by dhcp must be in the same CIDR block as eth0. Otherwise, the startup will fail.


Create Based on Virutal IP

Because I actually want to assign an IP address using DHCP in another network segment, create a new virtual IP address in the/etc/network/interfaces file:

Eth0: 1 is not required.

# 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

Then in/etc/default/isc-dhcp-server

INTERFACES="eth0"


Replace all 192.168.1.X in dhcpd. conf with 192.168.4.X. Restarted successfully!



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.