环境:
vim /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=172.25.254.116 ##配置
PREFIX=24
systemctl restart network
hostnamectl set-hostname dns-server.example.com
vim /eyc/yum.repos.d/rhel_dvd.repo
http://172.25.254.250/rhel7 ##
ssh root@172.25.254.116
yum repolist
高速缓存
116去114拿缓存
10去116拿缓存快 节省了dns访问速度,把外部的dns变成自己的高速缓存,一个网段只有一个去外网拿,其他的都从
server 里加网关250##可以上网的网关
systemctl restart network
dig www.baidu.com ##另一台 写连250的server的ip作为网关 dig 百度 不行 vim /etc/resolv.conf
yum install bind -y
vim /etc/named.conf
any any any 或者 改no
systemctl start named
systemctl stop firewalld
DNS
正向解析 : ip变为域名
vim /etc/named.rfc1912.zone
zone “westos.com” IN {
type master;
file “westos.com.zone”;
allow-update { none; };
cd /var/name
cp -p named.localhost westos.com.zonesystemctl restart named
测试:
在测试主机中
vim /etc/resolv.conf
nameserver 172.25.254.100
dig www.westos.com
bbs mail
1D ; refresh
5 1H ; retry
6 1W ; expire
7 3H ) ; minimum
8 NS dns.westos.com.
9 dns A 172.25.254.100
10 www A 172.25.254.100
11 bbs CNAME linux
12 linux A 172.25.254.111
13 linux A 172.25.254.222
14 westos.com. MX 1 172.25.254.250.
~
~
反向解析
zone “254.25.172.in-addr.arpa” IN {
type master;
file “westos.com.ptr”;
allow-update { none; };
};
[root@dns-server named]# cat /var/named/westos.com.ptr
$TTL 1D
@ IN SOA dns.westos.com. root.westos.com. (
0 ; serial
1D ; refresh
1H ; retry
1W ; expire
3H ) ; minimum
NS dns.westos.com.
dns A 172.25.254.100
111 PTR bbs.westos.com.
110 PTR www.westos.com.
双向解析¥
desktop
在正向解析的基础上
/etc/resolv.conf 116
集群
在一台主的上做改动,其他辅机器同步
之对比一个值,改变则同步
主:desktop
辅:server
配置网络216,更改yum源指向172.25.254.250/rhel7.0/x86_64/dvd
vim /etc/resolv.conf ##116
yum install bind -y ##下载bind
配置文件与主配置文件相同/etc/named.conf
网络更新dns
(设定ip号更新)
主dns机器配置(desktop 116 dns:116)
vim /etc/named.rfc1912.zones
zone “westos.com” IN {
type master;
file “westos.com.zone”;
allow-update { 172.25.254.16; }; ##接受16主机的更新
};
修改文件权限 chmod 770 /var/named/ (ll -d .)
cp -p /var/named/westos.com.zone /mnt
辅的真实主机16配置(dns:116)
[root@foundation16 ~]# nsupdate
server 172.25.254.116
update add hello.westos.com 86400 A 172.25.254.111
send
测试:
systemctl restart named
##刷新server出现文件westos.com.zone.jnl
dig hello.westos.com
还原:
16 发送删除的命令
把/var/named/westos.com.zone 还原回来
[root@foundation16 ~]# nsupdate
server 172.25.254.116
update delete hello.westos.com
send
企业7不用加
企业7之前要加:allow-transfer {}
才能主辅同步
有钥匙才能更新
[root@station named]# cd /mnt
[root@station mnt]# dnssec-keygen -a HMAC-MD5 -b 128 -n HOST westos
Kwestos.+157+58123
[root@station mnt]# ls
Kwestos.+157+58123.key Kwestos.+157+58123.private westos.com.zone
[root@station mnt]# cat Kwestos.+157+58123.private
Private-key-format: v1.3
Algorithm: 157 (HMAC_MD5)
Key: vS2MPL0PLQcxtFZeNnvrXw==
Bits: AAA=
Created: 20180809060257
Publish: 20180809060257
Activate: 20180809060257
[root@station mnt]# cat Kwestos.+157+58123.key
westos. IN KEY 512 3 157 vS2MPL0PLQcxtFZeNnvrXw==
[root@station mnt]# cp -p /etc/rndc.key /etc/westos.key
[root@station mnt]# vim /etc/westos.key
[root@station mnt]# vim /etc/named.conf
42行 include “/etc/westos.key”;
[root@station mnt]# vim /etc/named.rfc1912.zones
zone “westos.com” IN {
type master;
file “westos.com.zone”;
allow-update { key westos; };##修改为有钥匙更新
};
[root@station mnt]# ls
Kwestos.+157+58123.key Kwestos.+157+58123.private westos.com.zone
[root@station mnt]# scp Kwestos.+157+58123.* root@172.25.254.16:/mnt ##把钥匙给16的/mnt
辅16
[root@foundation16 ~]# cd /mnt
[root@foundation16 mnt]# ls
create_kz.sh Kwestos.+157+58123.key test.xml
create_vm.sh Kwestos.+157+58123.private vm.sh
[root@foundation16 mnt]#nsupdate -k Kwestos.+157+58123.key
server 172.25.254.116
update add hello.westos.com 86400 A 172.25.254.111
send
测试:
116:
systemctl restart named
cat /etc/named/westos.com.zone
dig hello.westos.com
dns动态域名解析
dhcpd服务分ip
dhcp更新dns
dns动态域名解析 (获取ip是自动的)(花生壳)
dhcp更新dns
主desktop
yum install dhcp -y
firewall-cmd –permanent –add-service=dhcp
firewall-cmd –reload
cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf ##删除2728行,36行以后的
systemctl restart dhcpd
测试:
在server中,
/etc/systemconfig/network-scripts/ifcfg-eth0改为dhcp自动获取ip,拔掉网线,
systemctl restart network,ifconfig-eth0 查看分配的ip,
cat /etc/resolv.conf 查看是谁(116)给的
超级用户
ifconfig enp0s25 172.25.254.116/24 ##临时网卡
网卡配置文件 ifcfg-enp025
/etc/sysconfig/network-scripts/ifcfg-eth0
时间同步 虚拟机和主机时间同步问题
86400秒
ping不通250 网卡问题
日志是个好东西
dig不了 火墙 网络 服务