分离解析脚本
在运行脚本之前,需要VM虚拟机,Centos7,两台主机一台win10 -1 作为广域网的主机, 一台win10 -2作为区域网的主机。
之前我的博客有教程
#!/bin/bash//修改添加网卡配置文件//设置双网卡sed -i '4s/dhcp/static/' /etc/sysconfig/network-scripts/ifcfg-ens33sed -i '15aIPADDR=192.168.17.1/nNETMASK=255.255.255.0' /etc/sysconfig/network-scripts/ifcfg-ens33cp -p /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens36sed -i '13d' /etc/sysconfig/network-scripts/ifcfg-ens36sed -i '12s/ens33/ens36/' /etc/sysconfig/network-scripts/ifcfg-ens36sed -i '13s/ens33/ens36/' /etc/sysconfig/network-scripts/ifcfg-ens36sed -i '15s/192.168.17.1/12.0.0.1/' /etc/sysconfig/network-scripts/ifcfg-ens36systemctl restart network //重启网路服务//修改主配置文件sed -i '13s/127.0.0.1/any/' /etc/named.confsed -i '21s/localhost/any/' /etc/named.confsed -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"; };};EOFcd /var/namedcp -p named.localhost kgc.com.wan //复制模板到自己设置的区域数据配置文件sed -i '2s/@/kgc.com./2' kgc.com.wan //把区域数据配置文件的第二行的@换成kgc.comsed -i '2s/rname.invalid./admin.kgc.com./' kgc.com.wansed -i '8s/@/kgc.com./' kgc.com.wansed -i '9s/127.0.0.1/192.168.17.1/' kgc.com.wansed -i '10asmtp IN A 192.168.17.99/nwww IN A 192.168.17.88' kgc.com.wancp -p kgc.com.wan kgc.com.lansed -i '9s/192.168.17.1/12.0.0.1/' kgc.com.lansed -i '11s/192.168.17.99/12.0.0.1/' kgc.com.lansed -i '12s/192.168.17.88/12.0.0.1/' kgc.com.lansystemctl stop firewalld.service //关闭防火墙setenforce 0 //关闭增强功能systemctl start named //开启服务
最后我们用WINDOW去试一试解析域名
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持武林网。
新闻热点
疑难解答