您好,登錄后才能下訂單哦!
#!/bin/bash
#配置雙網卡
#定義網卡配置文件位置
k=/etc/sysconfig/network-scripts
#復制網卡配置文件模板
cd /etc/sysconfig/network-scripts
cp -p ifcfg-ens33 ifcfg-ens36
#修改第1塊網卡配置文件
sed -i 's/dhcp/static/' $k/ifcfg-ens33
cat >>$k/ifcfg-ens33 <<-EOF
IPADDR=192.168.100.1
NETMASK=255.255.255.0
EOF
#修改第2塊網卡配置文件
sed -i 's/dhcp/static/' $k/ifcfg-ens36
sed -i 's/ens33/ens36/' $k/ifcfg-ens36
sed -i '/UUID/d' $k/ifcfg-ens36
cat >>$k/ifcfg-ens36 <<-EOF
IPADDR=12.0.0.1
NETMASK=255.255.255.0
EOF
#重啟網絡服務
systemctl restart network
#安裝dns服務
yum install bind -y
#修改主配置文件
sed -i '/listen-on/s/127.0.0.1/any/' /etc/named.conf
sed -i '/allow-query/s/localhost/any/' /etc/named.conf
sed -i '54,57d' /etc/named.conf
#修改區域配置文件
sed -i '12,$d' /etc/named.rfc1912.zones
cat >>/etc/named.rfc1912.zones <<-EOF
view "lan" {
match-clients { 192.168.100.0/24; };
zone "kgc.com." IN {
type master;
file "kgc.com.lan";
};
zone "." IN {
type hint;
file "named.ca";
};
};
view "wan" {
match-clients { 12.0.0.0/24; };
zone "kgc.com." IN {
type master;
file "kgc.com.wan";
};
};
EOF
#復制區域數據配置文件模板
cp -p /var/named/named.localhost /var/named/kgc.com.lan
cp -p /var/named/named.localhost /var/named/kgc.com.wan
#修改lan區域數據配置文件
sed -i '2s/@/kgc.com/2' /var/named/kgc.com.lan
sed -i '2s/rname.invalid./admin.kgc.com/' /var/named/kgc.com.lan
sed -i '8,10d' /var/named/kgc.com.lan
cat >>/var/named/kgc.com.lan <<-EOF
NS kgc.com.
A 192.168.100.1
www IN A 192.168.100.99
ftp IN A 192.168.100.88
EOF
#修改wan區域數據配置文件
sed -i '2s/@/kgc.com/2' /var/named/kgc.com.wan
sed -i '2s/rname.invalid./admin.kgc.com/' /var/named/kgc.com.wan
sed -i '8,10' /var/named/kgc.com.wan
cat >>/var/named/kgc.com.wan <<-EOF
NS kgc.com.
A 12.0.0.1
www IN A 12.0.0.1
ftp IN A 12.0.0.1
EOF
#開啟服務
systemctl start named
#關閉防火墻
systemctl stop firewalld.service
setenforce 0
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。