1、为网关服务器配置双网卡 , 在关机状态下再添加一块网卡,重启系统
ifconfig ens36 12.0.0.1/24
ifconfig
2、安装bind软件包
yum install -y bind
3、修改主配置文件
vim /etc/named.conf
options {
listen-on port 53 { any; } ; 监听本机或者any
listen-on-v6 port 53 { : :1; } ;
directory " /var/ named" ;
dump-file " /var/named/data/cache_dump.db";
statistics-file " /var/named/data/named_stats.txt" ;
memstatistics-file "/var/named/data/named_mem_stats. txt";
recursing-file " /var/named/data/named.recursing";
secroots-file " /var/named/data/named.secroots";
allow- query { any; }; 允许所有主机解析
.....
};
include "/etc/named.rfc1912.zones";
4、修改区域配置文件
vim /etc/named.rfc1912.zones
view "lan" { 定义内网view,view代表容器分割
match-clients { 192.168.116.0/24; } ; 匹配内网网段
zone "benet.com" IN { 设置要解析的区域
type master;
file "benet.com.zone.lan"; 数据配置文件
};
zone "." IN { 可将根域配置从主配置文件剪切过来,dd+p
type hint; hint是根区域类型
file "named.ca";
};
};
view "wan" { 定义外网view
match-clients { any; } ; 匹配除了内网网段以外的任意地址
zone "benet.com" IN {
type master;
file "benet. com. zone.wan";
};
};
注意: 一旦启用view,所有的zone必须都在view下,所以要把系统默认的自检用的zone也放在view下或者删除
5、修改区域数据配置文件
cd /var/named
cp -p named.localhost benet.com.zone.lan
cp -P named.localhost benet.com.zone.wan
vim benet.com.zone.lan
$TTL 1D
@ IN SOA benet.com.admin.benet.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS benet.com.
A 192.168.80.10
www IN A 192.168.80.100. 内网主机通过解析www.benet.com的地址得到192.168.80.100
vim benet.com.zone.wan
STTL 1D
@ IN SOA benet.com.admin.benet.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS benet . com.
A 12.0.0.1
www IN A 12.0.0.100
外网主机通过解析www.benet.com的地址得到12.0.0.100
6、启动服务
systemctl start named
7、在内外网客户端 域名解析配置文件中添加dns服务器地址
echo “nameserver 12.0.0.1” 》/etc/resolv.conf 外网客户端echo “nameserver 192.168.80.10” 》/etc/resolv.conf 内网客户端
8、测试
nslookup