您的位置:首页 > 运维架构 > Linux

How to build DHCP&NTP server on Linux(Ubuntu)

2013-07-23 18:41 597 查看

1.    
DHCP Sever

1)     
Install Command: $apt-get install dhcp3-server

maybe need apt-get autoremove dhcp3-server firstly.

2)     
configure /etc/dhcp/dhcpd.conf as below:

    #sample /etc/dhcpd.conf

    # (add your comments here)

    default-lease-time 600;

    max-lease-time 7200;

    option subnet-mask 255.255.255.0;

    option broadcast-address 192.168.133.255;

    option routers 192.168.133.254;

    option domain-name-servers 192.168.133.1, 192.168.133.2;

    option domain-name "mydomain.example";

    option ntp-servers 192.168.133.130;

    subnet 192.168.133.0 netmask 255.255.255.0 {

    range 192.168.133.10 192.168.133.100;

    range 192.168.133.150 192.168.133.200;

}

Comment: The option “ntp-servers” is used to assign ntp-server ip address to client. When the client get ip address from DHCP server, the DHCP server will also give the ntp-server ip address to the client.

3)     
start/stop/restart dhcp server as below:

$/etc/init.d/isc-dhcp-server restart/start/stop

2.    
NTP Server

1)      Install Command:  apt-get install ntp

2)     
The client do not update time after receive date&time from ntp server.

a)     
Change the file /etc/ntp.conf as the “stratum” may be verified as illegal. So the firmware will not update the date&time. Maybe Change as below:

fudge 127.127.1.0
stratum 1 

Comment: If the stratum is 0, maybe the client will take the date&time it get as incredible so that it will not update date&time.

b)     
The time gap between the server and client is too big, maybe the firmware will not update date&time to avoid some risks.

3)     
If the system ip address changed, we should restart DHCP/NTP server. Or else it will not work properly.


3.    
Configure static ip address for linux.

1)     
The system use dhcp as default. Just check the configuration file /etc/network/interfaces:

# The primary network interface

auto eth0

iface eth0 inet dhcp

2)     
To edit the file as below to change the system from DHCP to static ip.

# The primary network interface

auto eth0

iface eth0 inet static

address 192.168.0.10

netmask 255.255.255.0

gateway 192.168.0.1

3)     
We need to  down/up to enable the configuration.

$ ifdown eth0

$ifup eth0

4.    
Set Time

1)     
Use command “date” to change the firmware date&time.

e.g.: $date –s “2012-12-12 12:12:12”

2)     
User should use the command below to check whether the time is UCT or not:

“date ”  /  “date -u”

5.    
Change Timezone

1)     
e..g.: $ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

2)     
Test: use command “date” to check the timezone.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  DHCP NTP Linux