Dhcp_install.sh
#! /Bin/bash
# Install Yum Source
# Configuration
# Start
# Mount-o loop/dev/CDROM/mnt
# Echo "Mount-o loop/dev/CDROM/mnt">/etc/rc. Local
Cat>/etc/yum. Repos. d/DVD. Repo <ENDF
[Autoyum]
Baseurl = file: // mnt
Gpgcheck = 0
ENDF
Yum clean all & Yum list all &>/dev/null & Echo "yum is OK"
Yum install-y DHCP &>/dev/null & Echo "DHCP is installed"
Dhcp_configure.sh
#! /Bin/bash
Read-P "Please input your IP:" ip
Read-P "Please input your netmask:" Net
Read-P "Please input your gateway:" GW
Read-P "Please input your dns1:" dns1
Read-P "Please input your dns2:" dns2
Sam =/usr/share/doc/dhcp-4.1.1/DHCPD. conf. Sample
Itr = $ (ifconfig eth0 | grep-EO '([0-9] {1, 3} \.) {2} [0-9] {1, 3}' | head-1)
Mask = $ (ifconfig eth0 | grep-EO '([0-9] {1, 3 }\.) {3} [0-9] {255}) '| grep ^)
Bor_add = $ (ifconfig eth0 | grep-EO '([0-9] {1, 3 }\.) {3} [0-9] {255}) '| grep $)
MAC = $ (ifconfig eth0 | grep-EO '([0-9 A-Z A-Z] {1, 2} :) {5} [0-9 A-Z A-Z] {1, 2 }) ')
Export Sam itr mask bor_add Mac
Cat>/etc/sysconfig/network-scripts/ifcfg-eth0 <ENDF
Device = "eth0"
Bootproto = "NONE"
Hwaddr = "00: 0C: 29: 23: 15: 40"
Onboot = "yes"
Ipaddr = $ IP
Netmask = $ Net
Gateway = $ GW
Dns1 = $ dns1
Dns2 = $ dns2
ENDF
Read-P "Please input your hostname:" HN
Cat>/etc/sysconfig/Network <ENDF
Networking = Yes
Hostname = $ HN
ENDF
Echo "$ IP $ HN">/etc/hosts &>/dev/null & Echo "hostname is OK"
\ CP-p $ SAM/etc/DHCP/DHCPD. conf &>/dev/null & Echo "copy is OK"
Cat>/etc/DHCP/DHCPD. conf <ENDF
Option domain-name "$ HN ";
Option domain-name-servers $ dns1, $ dns2;
Default-lease-time 600;
Max-lease-time 7200;
Subnet $ itr.0 netmask $ mask {
Range $ itr.100 $ itr.200;
Option routers $ GW;
Option broadcast-address $ bor_add;
Default-lease-time 600;
Max-lease-time 7200;
}
Host Fantasia {
Hardware Ethernet $ MAC;
Fixed-address $ GW;
}
ENDF
# Check whether the DHCPD syntax is correct
# DHCPD-D &>/dev/null & Echo "DHCPD grammer is OK"
Service DHCPD restart &>/dev/null & Echo "DHCPD is OK"
Chkconfig DHCPD on
DHCP configuration simple script