AKAI TSUKI

System development or Technical something

systemd configuration for coredns

I refer to the page below.
https://github.com/coredns/deployment/blob/master/systemd/coredns.service

add coredns user

[root@cent7devops ~]# useradd coredns -s /sbin/nologin -c 'coredns user'

create service file for systemd

[root@cent7devops ~]# ls -l /etc/systemd/system/coredns.service
-rw-r--r-- 1 root root 464 Aug 16 08:27 /etc/systemd/system/coredns.service
[root@cent7devops ~]# 
[root@cent7devops ~]# cat /etc/systemd/system/coredns.service
[Unit]
Description=CoreDNS DNS server
Documentation=https://coredns.io
After=network.target

[Service]
PermissionsStartOnly=true
LimitNOFILE=1048576
LimitNPROC=512
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=true
User=coredns
WorkingDirectory=/home/coredns
ExecStart=/usr/bin/coredns -conf=/etc/coredns/Corefile
ExecReload=/bin/kill -SIGUSR1 $MAINPID
Restart=on-failure

[Install]
WantedBy=multi-user.target
[root@cent7devops ~]#

start coredns service

check status

[root@cent7devops ~]# systemctl is-active coredns
unknown
[root@cent7devops ~]#

start coredns service

[root@cent7devops ~]# systemctl start coredns
[root@cent7devops ~]# systemctl is-active coredns
active
[root@cent7devops ~]#