Shell 스크립트는 간단한 DHCP 및 DNS 서비스를 원클릭으로 불러옵니다.

간단한 DHCP 서비스


이 스크립트 구성: 소속 서버의 정적 IP 주소: 192.168.100.100(이 점만 사용자 정의가 필요함)

#! /bin/bash
# DHCP

yum install dhcp -y 
wangka="/etc/sysconfig/network-scripts/ifcfg-ens33"
# 

sed -i -e '/BOOTPROTO/s/dhcp/static/g' -e '/ONBOOT/aIPADDR=192.168.100.100
NETMASK=255.255.255.0
GATEWAY=192.168.100.1' $wangka systemctl restart network # IP muban="/usr/share/doc/dhcp-4.2.5/dhcpd.conf.example" peizhi="/etc/dhcp/dhcpd.conf" [ ! -e "$peizhi.bak" ] && cp $peizhi $peizhi.bak # , , cp $muban $peizhi sed -i '29asubnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.120 192.168.100.150\;
option routers 192.168.100.1\;
}' $peizhi systemctl start dhcpd systemctl stop firewalld setenforce 0 # ,

간단한 DNS 정방향 분석 서비스


스크립트 구성: 소속 서버 IP 주소: 192.168.116.131

#!/bin/bash &>/dev/null
# DNS

rpm -q bind
if [ $? -ne 0 ];then
        yum install bind -y
        systemctl start named
fi
#DNS 

read -p " ( :test.com)" yu
quanju="/etc/named.conf"
quyu="/etc/named.rfc1912.zones"
[ ! -e $quanju.bak ] && cp $quanju $quanju.bak
  sed -i -e '13s/127.0.0.1/192.168.116.131/' -e '21s/localhost/any/' $quanju 
[ ! -e $quyu.bak ] && cp $quyu $quyu.bak
# 、 

grep "$yu" $quyu &> /dev/null
while [ $? -ne 0 ];do
  sed -i "18azone \"$yu\" IN {
type master\;
file \"$yu.dns\"\;
}\;
" $quyu peizhi="/var/named/$yu.dns" cp -p /var/named/named.localhost $peizhi done # , sed -i -e '2d' -e "1a@ IN SOA "$yu"\. admin\."$yu"\. (" /var/named/$yu.dns sed -i '8d' /var/named/$yu.dns sed -i '$d' /var/named/$yu.dns sed -i -e "7a\ NS $yu." -e "/A/s/127.0.0.1/192.168.116.131/" /var/named/$yu.dns # while [ 1 -ge 0 ];do read -p " A ( :www IN A 8.8.8.8)" zhen echo $zhen >> /var/named/$yu.dns read -p " (y/n)" a if [ $a != "y" ];then break fi done # systemctl restart named jieguo=`systemctl status named | grep "active" &>/dev/null` if [ $? -eq 0 ];then echo " " else echo " " fi # sed -i 's/116.2/116.131/g' /etc/resolv.conf #

좋은 웹페이지 즐겨찾기