From a68b47511531e123990074df6390e555a0ef006a Mon Sep 17 00:00:00 2001 From: Petru Paler Date: Thu, 18 Jan 2024 16:19:43 +0000 Subject: [PATCH] Update for new netbox setup. --- config.sh | 2 +- netbox-dhcp.sh | 4 ++-- netbox-dns.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config.sh b/config.sh index 17d3da0..0c5e88e 100644 --- a/config.sh +++ b/config.sh @@ -1,2 +1,2 @@ -NETBOX=192.168.1.56 +NETBOX=192.168.1.100 TOKEN=fd92ccbd826a3ef585688bb9b56ace7da512e965 diff --git a/netbox-dhcp.sh b/netbox-dhcp.sh index b3fde82..c123682 100755 --- a/netbox-dhcp.sh +++ b/netbox-dhcp.sh @@ -3,7 +3,7 @@ . ./config.sh do_curl() { - curl -s -k -H "Authorization: Token ${TOKEN}" -X GET $1 + curl -s -k -H "Host: netbox.v.paler.net" -H "Authorization: Token ${TOKEN}" -X GET $1 } echo "# generated by $0 at $(date)" @@ -11,7 +11,7 @@ echo cat dhcpd.conf.head do_curl "https://${NETBOX}/api/ipam/ip-addresses/?limit=10000" | \ -jq -r '.results[] | .assigned_object.device.name + .assigned_object.virtual_machine.name + " " + (.address / "/")[0] + " " + .assigned_object.url' | +jq -r ".results[] | .assigned_object.device.name + .assigned_object.virtual_machine.name + \" \" + (.address / \"/\")[0] + \" \" + (.assigned_object.url | sub(\"netbox.v.paler.net\"; \"${NETBOX}\"))" | while read name ip owner do mac=$(do_curl $owner | jq -r '.mac_address') diff --git a/netbox-dns.sh b/netbox-dns.sh index 9bee1b5..e924ec6 100755 --- a/netbox-dns.sh +++ b/netbox-dns.sh @@ -4,6 +4,6 @@ RPZ_FILE=/var/unbound/db/local.rpz -curl -s -k -H "Authorization: Token ${TOKEN}" -X GET "https://${NETBOX}/api/ipam/ip-addresses/?limit=10000" | \ +curl -s -k -H "Host: netbox.v.paler.net" -H "Authorization: Token ${TOKEN}" -X GET "https://${NETBOX}/api/ipam/ip-addresses/?limit=10000" | \ jq -r '.results[] | (.address / "/")[0] as $addr | (.assigned_object.device.name + .assigned_object.virtual_machine.name + ".home.paler.net") as $name | ($addr | split(".") | reverse | join(".") + ".in-addr.arpa") as $rev | $name + " A " + $addr, $rev + " PTR " + $name + "."' | \ tee ${RPZ_FILE}