NOC DNS sync guide¶
Build¶
In some distros cargo utility may be outdate. So, install it from site
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
Go to directory with NOCProject code and build dnssync package
cd /opt/noc/rust/dnssync
cargo build --release
Install¶
Copy binaries to /usr/local/bin/
sudo cp ../target/release/noc-dns-sync /usr/local/bin/
Create environment file for service
NOC_API_KEY - API key. Generate it in NOC web interface AAA -> Setup -> api keys. You must create row in table Access with next columns: API: datastream Role: *
NOC_HOST - DNS server name in NOC interface DNS -> Setup -> DNS Servers
NOC_URL - URL for NOCProject like https://noc.example.com/ (You may also replace noc.example.com with IP address)
NOC_ZONES_PATH - path for autogenerated zones
NOC_ZONES_CHROOT_PATH - prefix for generated zones path
sudo tee /usr/local/etc/noc-dns-sync.cfg << EOF
NOC_API_KEY=<API_KEY>
NOC_HOST=<DNS_SERVER_NAME_IN_NOC>
NOC_URL=<BASE_URL_FOR_NOC>
NOC_ZONES_CHROOT_PATH=/etc/bind/autozones/
NOC_ZONES_PATH=/etc/bind/autozones/
EOF
Create systemd unit
sudo tee /etc/systemd/system/noc-dns-sync.service << EOF
[Unit]
Description=NOC Datastream Syncronization (bind)
After=network.target
[Service]
ExecStart=/usr/local/bin/noc-dns-sync -d --allow-insecure
Type=simple
KillMode=process
Restart=always
RestartSec=10s
User=bind
Group=bind
EnvironmentFile=/usr/local/etc/noc-dns-sync.cfg
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
Prepare bind¶
Create directory for automatically generated zones
sudo mkdir -p /etc/bind/autozones
sudo chown bind:bind /etc/bind/autozones
Append include statement in bind config
sudo tee -a /etc/bind/named.conf << EOF
include "/etc/bind/autozones/zones.conf";
EOF
Start service¶
Info
After creating new zone you must execute rndc reconfig manually
sudo systemctl enable noc-dns-sync
sudo systemctl start noc-dns-sync