• yum 、DHCP、DNS 服务脚本


    ================================================
    yum仓库构建
    ================================================
    #!bin/bash
    # name:elin
    # time:2019.08.24
    # title:create yum
    echo "挂载光盘..."
    mount | grep -q "/dev/sr0" && umount /dev/sr0
    mount /dev/sr0 /media/ &>/dev/null
    echo "构建yum仓库..."
    cd /etc/yum.r*
    [ -d a ]  ||  mkdir a/
    mv *.repo  a/
    cat <<END > locale.repo
    [cdrom]
    name="cdrom"
    baseurl=file:///media
    enabled=1
    gpgcheck=0
    END
    echo "清除yum缓存..."
    yum clean all &>/dev/null  && yum makecache &>/dev/null
    echo "yum仓库构建成功!!!"
    =================================================
    DHCP搭建
    =================================================
    #!bin/bash
    # name: elin
    # time: 2019.08.24
    # title: create dhcp service
    echo "安装dhcp安装包..."
    yum -y install dhcp &>/dev/null
    echo "修改配置文件..."
    cat << EOF  > /etc/dhcp/dhcpd.conf
    option domain-name "crushlinux.com";
    option domain-name-servers 202.106.0.20;
    default-lease-time 600;
    max-lease-time 7200;
    subnet 192.168.116.0 netmask 255.255.255.0 {
    range 192.168.116.100  192.168.116.200;
      option routers 192.168.116.1;
    }
    EOF
    echo "开启服务..."
    systemctl start dhcpd
    systemctl enable dhcpd
    echo "dhcp服务已搭建完成..."
    ===================================================
    DNS服务搭建
    ===================================================
    #!bin/bash
    # name:elin
    # time: 2019.08.24
    # title: create dns service
    #关闭防火墙和安全机制
    iptables -F
    systemctl stop firewalld
    setenforce 0
    echo "检测安装包并安装bind bind-utils bind-libs"
    rpm -qa | grep "bind"
    yum -y install bind bind-utils bind-libs &>/dev/null
    echo "安装成功"
    #修改/etc/resolv.conf配置文件
    cat << END> /etc/resolv.com
    # Generated by NetworkManager
    nameserver 202.106.0.20
    nameserver 192.168.116.10
    nameserver 192.168.116.20
    END
    echo "/etc/resolv.com配置成功"
    # 修改/etc/hosts配置文件
    cat << END > /etc/hosts
    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    192.168.116.10 ns1.study.com
    192.168.116.20 ns2.study.com
    END
    echo "/etc/hosts配置成功"
    #修改/etc/named.conf配置文件
    cat << END > /etc/named.conf
    options {
            directory "/var/nemed";
    };
    zone "study.com" IN {
            type master;
            file "elin.zheng";
            allow-transfer { 192.168.116.20; };
    };
    zone "116.168.192.in-addr.arpa" IN {
            type master;
            file "elin.fan";
            allow-transfer { 192.168.116.20; };
    };
    END
    echo "/etc/named.conf配置成功"
    #修改/var/named/elin.zheng配置文件
    cat <<END > /var/named/elin.zheng
    $TTL   86400  
    @       IN      SOA     study.com.      admin.study.com. (
                    20190824
                    3H
                    15M
                    1W
                    1D
    )
                    IN      NS      ns1.study.com.
                    IN      NS      ns2.study.com.
                    IN      MX 10   mail.study.com.
    ns1             IN      A       192.168.116.10
    ns2             IN      A       192.168.116.20
    mail            IN      A       192.168.116.123
    www             IN      A       192.168.116.124
    END
    echo "/var/named/elin.zheng配置成功"
    #修改/var/named/elin.fan配置文件
    cat <<END > /var/named/elin.fan
    $TTL    86400  
    @       IN      SOA     study.com.      admin.study.com. (
                    20190824
                    3H
                    15M
                    1W
                    1D
    )
                    IN      NS      ns1.study.com.
                    IN      NS      ns2.study.com.
                    IN      MX 10   mail.study.com.
    10              IN      PTR     ns1.study.com.
    20              IN      PTR     ns2.study.com.
    123             IN      PTR     mail.study.com.
    124             IN      PTR     www.study.com.
    END
    echo "/var/named/elin.fan配置成功"
    #给正反文件一些权限
    chown :named /var/named/elin.*  &> /dev/null
    #检测正向文件是否能被读取
    cd /var/named/
    named-checkzone study.com elin.zheng  &>/dev/null
    #检测反向文件是否能被读取
    named-checkzone 116.168.192.in-addr.arpa elin.fan &>/dev/null
    #启动服务
    systemctl start named
    systemctl enable named
    echo "DNS启动成功" 
  • 相关阅读:
    Junit初级编码(一)第一个Junit测试程序
    关于健身与健美
    spring入门(一)
    HTTP状态301、404、200、304分别表示什么意思
    预处理prepareStatement是怎么防止sql注入漏洞的?
    详解SESSION与COOKIE的区别
    Form表单中method为get和post的区别
    tomcat服务器配置及使用
    ubuntu 14.04 安装mysql server初级教程
    《电路学习第三天》 之 线性稳压电源的设计
  • 原文地址:https://www.cnblogs.com/elin989898/p/11410996.html
Copyright © 2020-2023  润新知