Use shell scripts to quickly deploy DHCP servers!

Source: Internet
Author: User

Server address: 192.168.1.110

Network Segment: 192.168.1.0

Subnet Mask: 255.255.255.0

Gateway: 192.168.1.254

[[Email protected] ~] # Cat DHCP. Sh
#! /Bin/bash
# Auto deploy DHCP server for 192.168.1.0/24 netmask
# This script need you have you Yum Repository
Echo "____________ Mount-CDROM _____"
Umount/dev/CDROM &>/dev/null # uninstall the CD
Mount/dev/CDROM/mnt &>/dev/null & # Remount the System Disk
Touch/etc/yum. Repos. d/yum. Repo # create a yum configuration file named Yum. Repo
If [$? -EQ 0]
Then # determine whether the yum file is successfully created and write the following parameters
Cat <EOF>/etc/yum. Repos. d/yum. Repo
[Server]
Name = rehat server yum
Baseurl = file: // MNT/Server # URL access path
Enabled = 1 # Start the yum Repository

Gpgcheck = 0 # disable the software package Signature
EOF

Else # Otherwise, the yum installation error is printed!
Echo "_ ----- install Yum error ___"
Fi

# Installing the DHCP Software Package

Echo "___-install DHCP packet __"
Yum-y install DHCP &>/dev/null &&
If [-F/etc/DHCPD. conf] # determine whether the master configuration file/etc/DHCPD. conf exists.
Then # Run
MV/etc/DHCP. CONF/etc/DHCPD. conf. Save # Save the original configuration file
Fi
# Variable definition, mainly including network, subnet, address and other information
Net = 192.168.1.0
Mask = 255.255.255.0
Range = "192.168.1.50 192.168.1.100"
Domain_name = "breaklinux.com"
Router = 192.168.1.254
DNS = 8.8.8.8
# Create a new configuration file
Echo "______ create configuration file ______"
Cat <EOF>/etc/DHCPD. conf
Ddns-Update-style interim;
Ignore client-updates;

Subnet $ net netmask $ mask {

# --- Default Gateway
Option routers $ router;
Option subnet-mask $ mask;

Option Nis-domain "$ domain_name ";
Option domain-name "$ domain_name ";
Option domain-name-servers $ DNS;

Option time-offset-18000; # Eastern Standard Time
# Option NTP-servers 192.168.1.1;
# Option NetBIOS-name-servers 192.168.1.1;
# --- Selects point-to-point node (default is hybrid). Don't change this unless
# -- You understand NetBIOS very well
# Option NetBIOS-node-type 2;

Range dynamic-BOOTP $ range;
Default-lease-time 21600;
Max-lease-time 43200;

# We want the nameserver to appear at a fixed address
Host NS {
Next-server marvin.redhat.com;
Hardware Ethernet 12: 34: 56: 78: AB: CD;
Fixed-address 207.175.42.254;
}
}
EOF
Echo "_____________ DHCP configuration file correctly"
Service DHCPD restart # Start Dhcp Service
Chkconfig DHCPD on # Start upon startup

 

DHCP server set up

I hope you will pay more attention to the breaklinux.com studio. If there is any error, please point it out. Thank you!

--- New

This article is from the "rendering unchanged yesterday" blog, please be sure to keep this source http://breaklinux.blog.51cto.com/8193722/1531320

Related Article

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.