Automating the installation of DHCP services _shell

Source: Internet
Author: User

Experimental environment: VMWARE12, Redhat 6.4, support Chinese

#!/bin/bash
#shell自动搭建DHCP服务
Rpm-q DHCP &>/dev/null
If [$?-eq 0];then
echo "DHCP service has been built"
Else
echo "DHCP service is not set up, start building now"
Yum Install dhcp-y &>/dev/null
If [$?-eq 0];then
echo "DHCP service builds successfully"
Else
echo "Yum source error, Exit Now"
Exit 10
Fi
Fi
if [!-f/etc/dhcp/dhcpd.conf];then
echo "configuration file does not exist, other errors may occur, exit immediately"
Exit 20
Fi
Cat << EOF >/etc/dhcp/dhcpd.conf
Option Domain-name "server.org";
Option Domain-name-servers 114.114.114.114;

Default-lease-time 3200;
Max-lease-time 7200;

Subnet 192.168.16.0 netmask 255.255.255.0 {
Range 192.168.16.100 192.168.16.200;
Option routers 192.168.16.254;
}
Eof
Ifconfig eth0 192.168.16.254/24 &>/dev/null
If [$?-eq 0];then
Service DHCPD start &>/dev/null
If [$?-eq 0];then
echo "DHCP service turned on successfully"
Else
echo "DHCP service failed to open"
Fi
Else
echo "NIC IP configuration error, exit immediately"
Exit 30
Fi

This article is from the "Sunny Rain" blog, please be sure to keep this source http://8776055.blog.51cto.com/8766055/1839810

Automating the installation of DHCP services _shell

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.