Centos7 でNSD 構築方法を記載します。
なお、環境はAWSでデプロイします。
[1]DNS 用Cloudformation
AWSTemplateFormatVersion: "2010-09-09" Description: dns Parameters: Subnet1: Type: String Description: Subnet IDs for VPC Default: 'subnet-xxxxxx' SecurityGroup: Type: String Default: 'sg-xxxxxx' Description: SecurityGroup Resources: gitlab: Type: "AWS::EC2::Instance" Properties: ImageId: "ami-0ddea5e0f69c193a4" # Centos7, 7.9.2009, ap-northeast-1 InstanceType: t2.medium KeyName: dev-key NetworkInterfaces: - AssociatePublicIpAddress: "true" DeviceIndex: "0" SubnetId: !Ref Subnet1 GroupSet: [ !Ref SecurityGroup ] Tags: - Key: "Name" Value: "dev-dns" UserData: Fn::Base64: | #!/bin/bash # hostname 設定 hostnamectl set-hostname dns echo "preserve_hostname: true" >> /etc/cloud/cloud.cfg sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config # install yum -y install epel-release yum -y install vim bind-utils nsd shutdown -r now
[2] 設定を入れる
server: server-count: 1 do-ip4: yes zonesdir: "/etc/nsd" database: "" logfile: "/var/log/nsd.log" pidfile: "/run/nsd/nsd.pid" round-robin: yes minimal-responses: yes refuse-any: yes include: "/etc/nsd/server.d/*.conf" include: "/etc/nsd/conf.d/*.conf" remote-control: control-enable: yes control-interface: /run/nsd/nsd.ctl zone: name: "example.com" zonefile: "example.com.zone"
- /etc/nsd/example.com.zone
$TTL 3600; @ IN SOA ns.example.com. root.example.com. ( 2021050702 ; Serial 3600 ; refresh 900 ; retry 3600000 ; expire 3600 ) ; minimum IN NS ns.example.com. example.com. IN MX 10 mail.example.com. @ IN A 192.168.1.1 mail IN A 192.168.1.2
[3] systemd start させてdig 打って確認
systemctl start nsd dig +noall +answer @localhost mail.example.com