Generate Configurations for Syslog, User-Manager and DNS Servers

To configure syslog based mapping of MAC addresses to hostnames, User-Manager accounts for static DHCP and static DNS all just need a simple MAC ↔ IP ↔ hostname mapping.

This posting is about the basic step for these three tasks:

  1. For the syslog-ng configuration I want to replace known MAC addresses with <MAC/hostname> entries for convenient log reading.
  2. For the static DNS configuration I need IP ↔ hostname data.
  3. For the user-manager configuration to generate static IP addresses I need MAC ↔ IP data and hostnames for comments.

Step by Step

This is the whole guide for this setup to work:

  1. Generate Configuration for Syslog, User-Manager and DNS Servers (this part)
  2. Replace MAC Addresses With Labels Using Syslog-NG
  3. User-Manager Setup For Static DHCP
  4. DNS Names For Static DHCP Leases


At first I had a classic DHCP server running in my environment and for that setup I used to have a file named bootptab. This file originally contained the columns hostname, hwtype, hwaddr, ipaddr and bootfile.

Starting from that file, which contained all necessary information, I wanted an automated generator for the three data representations.

Create the Configuration

I reduced the bootptab file to the format hostname, hwaddr and ipaddr, which looks like this:

client-1 00:11:22:aa:bb:cc
client-2 33:44:55:dd:ee:ff
# router-if1 66:77:88:99:00:aa

I also added the syntax for comments, which can contain hostnames and MAC addresses which will only show up in the syslog-ng configuration. This is helpful for not really visible interfaces but occasionally those MAC addresses might show up in some debug logs one day. This way the logs show those names even if they don’t belong to an actual host.

Run the Converter

The script to convert the above file into three formats is this:


cat ./bootptab | \
    grep -v "^#" | \
    grep -e "[a-z]" | \
    sort | \
    while read LINE; do
      echo ${LINE} | \
          awk '{ host=$2; gsub(":", "", host); host=toupper(host); print "/tool user-manager user add customer=\"LOGINNAME\" disabled=no ip-address=\"" $3 "\" name=\"" toupper($2) "\" password=\"\" shared-users=1;"; print ":global shost" host " \"" $1 "\"<"; print "  subst(\"" toupper($2) "\", \"\", value(\"MESSAGE\"), flags(ignore-case));"; }'
cat ./bootptab | \
    grep "^#" | \
    grep ":" | \
    sort | \
    while read LINE; do
      echo ${LINE} | \
          awk '{ print "  subst(\"" toupper($3) "\", \"<" toupper($3) "/" $2 ">\", value(\"MESSAGE\"), flags(ignore-case));"; }'
) | sort -k 3


The generated output are these lines, which I can copy/paste to the appropriate configurations and terminals later on.

:global shost001122AABBCC "client-1"
:global shost334455DDEEFF "client-2"
/tool user-manager user add customer="LOGINNAME" disabled=no ip-address="" name="00:11:22:AA:BB:CC" password="" shared-users=1;
/tool user-manager user add customer="LOGINNAME" disabled=no ip-address="" name="33:44:55:DD:EE:FF" password="" shared-users=1;
  subst("00:11:22:AA:BB:CC", "<00:11:22:AA:BB:CC/client-1>", value("MESSAGE"), flags(ignore-case));
  subst("33:44:55:DD:EE:FF", "<33:44:55:DD:EE:FF/client-2>", value("MESSAGE"), flags(ignore-case));
  subst("66:77:88:99:00:AA", "<66:77:88:99:00:AA/router-if1>", value("MESSAGE"), flags(ignore-case));

Configuration Lines for Syslog, User-Manager and DNS Servers

My next posts will handle the three processes where these generated lines will be used. Stay tuned!