Implementation of shell separation parsing script

Time:2020-10-29

Detach parse script

Before running the script, we need VM virtual machine, centos7, two hosts, one win10 – 1 as Wan host and one win10 – 2 as LAN host.

I had a tutorial on my blog before

#!/bin/bash
//Modify and add network card configuration file
//Setting up dual network card
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 // restart the network service
//Modify master profile
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    //Delete the root domain of the master profile
//Delete add zone profile
sed -i '13,48d' /etc/ named.rfc1912 . zones // delete 13 to 48 lines of zone configuration file
cat >> /etc/ named.rfc1912 . zones < < - EOF // add external and internal network cards to the zone profile
view "wan" {
    Match clients {192.168.17.0 / 24;}; // internal network segment

    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;}; // external network segment

    zone "kgc.com" IN {
     type master;
     file "kgc.com.lan";
    };
};

EOF
cd /var/named
cp -p  named.localhost  kgc.com.wan   //Copy the template to the zone data profile you set
sed -i '2s/@/ kgc.com ./2'  kgc.com.wan  //Change the @ in the second line of the zone data profile to 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   //Turn off the firewall
Setenforce 0 // turn off enhancements
Systemctl start named // start the service

Finally, we use windows to try to resolve the domain name

The above is the whole content of this article, I hope to help you in your study, and I hope you can support developeppaer more.

Recommended Today

Kafka learning materials

Kafka 1、 Benefits of message middleware 1. Decoupling It allows you to extend or modify processes on both sides independently, as long as you make sure they comply with the same interface constraints. It would be a great waste to put resources on standby to handle such peak visits. The use of message queue can […]