#!/bin/bash
//修改添加网卡配置文件
//设置双网卡
sed -i '4s/dhcp/static/' /etc/sysconfig/network-scripts/ifcfg-ens33
sed -i '15aIPADDR=192.168.17.1\nNETMASK=255.255.255.0' /etc/sysconfig/network-scripts/ifcfg-ens33
cp -p /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i '13d' /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i '12s/ens33/ens36/' /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i '13s/ens33/ens36/' /etc/sysconfig/network-scripts/ifcfg-ens36
sed -i '15s/192.168.17.1/12.0.0.1/' /etc/sysconfig/network-scripts/ifcfg-ens36
systemctl restart network //重启网路服务
//修改主配置文件
sed -i '13s/127.0.0.1/any/' /etc/named.conf
sed -i '21s/localhost/any/' /etc/named.conf
sed -i '54,57d' /etc/named.conf //删除主配置文件的根域
//删除添加区域配置文件
sed -i '13,48d' /etc/named.rfc1912.zones //删除13到48行区域配置文件
cat >> /etc/named.rfc1912.zones <<-EOF //给区域配置文件添加外部网卡和内部网卡
view "wan" {
match-clients { 192.168.17.0/24; }; //内部网段
zone "kgc.com" IN {
type master;
file "kgc.com.wan";
};
zone "." IN {
type hint;
file "named.ca";
};
};
view "lan" {
match-clients { 12.0.0.0/24; }; //外部网段
zone "kgc.com" IN {
type master;
file "kgc.com.lan";
};
};
EOF
cd /var/named
cp -p named.localhost kgc.com.wan //复制模板到自己设置的区域数据配置文件
sed -i '2s/@/kgc.com./2' kgc.com.wan //把区域数据配置文件的第二行的@换成kgc.com
sed -i '2s/rname.invalid./admin.kgc.com./' kgc.com.wan
sed -i '8s/@/kgc.com./' kgc.com.wan
sed -i '9s/127.0.0.1/192.168.17.1/' kgc.com.wan
sed -i '10asmtp IN A 192.168.17.99\nwww IN A 192.168.17.88' kgc.com.wan
cp -p kgc.com.wan kgc.com.lan
sed -i '9s/192.168.17.1/12.0.0.1/' kgc.com.lan
sed -i '11s/192.168.17.99/12.0.0.1/' kgc.com.lan
sed -i '12s/192.168.17.88/12.0.0.1/' kgc.com.lan
systemctl stop firewalld.service //关闭防火墙
setenforce 0 //关闭增强功能
systemctl start named //开启服务
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。