About Martijn

Say hi

Converting DIG output to JSON

DIG is one powerful tool, mostly used to troubleshoot DNS queries.

However, sometime we want to achieve a task in another field of expertise and collect dns data. For example when one needs to limit access to content which is hosted on different servers from time to time but we can’t utilize FQDN in our firewall rulebase because the reverse dns isn’t acurate.

Now with DIG we can collect the ip addresses that is returned from a DNS request. For example for google.com.

martijn@monitoring:~$ dig google.com

; <<>> DiG 9.9.5-9+deb8u17-Debian <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16736
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;google.com.                    IN      A

;; ANSWER SECTION:
google.com.             36      IN      A       172.217.17.78

;; Query time: 1 msec
;; SERVER: 195.8.195.8#53(195.8.195.8)
;; WHEN: Tue Mar 10 10:38:02 CET 2020
;; MSG SIZE  rcvd: 55

martijn@monitoring:~$

But manually scraping the default output and maintaining a list is time consuming. We can make the output cleaner by adding some additional parameters. For example the following command:

martijn@monitoring:~$ dig google.com +nocomments +noquestion +noauthority +noadditional +nostats

; <<>> DiG 9.9.5-9+deb8u17-Debian <<>> google.com +nocomments +noquestion +noauthority +noadditional +nostats
;; global options: +cmd
google.com.             288     IN      A       172.217.168.238
martijn@monitoring:~$

While this is already much cleaner, we still would have to manually process this output, or perform some screen scraping to continue with the output. We can however pipe the output of dig through the powerful awk command and skip the first three lines.

martijn@monitoring:~$ dig aaaa google.com +nocomments +noquestion +noauthority +noadditional +nostats  | awk '{if (NR>3){print}}'
google.com.             53      IN      AAAA    2a00:1450:400e:80d::200e
martijn@monitoring:~$

And to be honest, yes, we could skip the first three lines with any other tool that provides these capabilities, but awk seems to be generally available. Now we only have the actual results of the query it is safe to continue with the data.

DNS data always consists of a fixed structure.

Query                  TTL      CLASS   TYPE    Content 
google.com.             53      IN      AAAA    2a00:1450:400e:80d::200e 

In my case i have a need to process this data in a structured way, and i am able to process either JSON or XML. for this example i will convert the structured data to JSON. Because the content is already by default separated by tabs we can pull the data through jq. However, we need to keep in mind that sometimes there are multiple tabs. So we need to squeeze them in to one.

martijn@monitoring:~$ dig aaaa google.com +nocomments +noquestion +noauthority +noadditional +nostats  | awk '{if (NR>3){print}}' | tr -s '\t' | jq -R 'split("\t") |{Name:.[0],TTL:.[1],Class:.[2],Type:.[3],IpAddress:.[4]}'
{
  "Name": "google.com.",
  "TTL": "76",
  "Class": "IN",
  "Type": "AAAA",
  "IpAddress": "2a00:1450:400e:80e::200e"
}
martijn@monitoring:~$

The output we have now seems to be valid JSON, however testing this further with dns queries returning multiple addresses will return slightly invalid JSON. An good example would be when we query the microsoft.com domain.

martijn@monitoring:~$ dig a microsoft.com +nocomments +noquestion +noauthority +noadditional +nostats  | awk '{if (NR>3){print}}'| tr -s '\t' |  jq -R 'split("\t")
 |{Name:.[0],TTL:.[1],Class:.[2],Type:.[3],IpAddress:.[4]}'
 {
   "Name": "microsoft.com.",
   "TTL": "3600",
   "Class": "IN",
   "Type": "A",
   "IpAddress": "104.215.148.63"
 }
 {
   "Name": "microsoft.com.",
   "TTL": "3600",
   "Class": "IN",
   "Type": "A",
   "IpAddress": "13.77.161.179"
 }
 {
   "Name": "microsoft.com.",
   "TTL": "3600",
   "Class": "IN",
   "Type": "A",
   "IpAddress": "40.76.4.15"
 }
 {
   "Name": "microsoft.com.",
   "TTL": "3600",
   "Class": "IN",
   "Type": "A",
   "IpAddress": "40.112.72.205"
 }
 {
   "Name": "microsoft.com.",
   "TTL": "3600",
   "Class": "IN",
   "Type": "A",
   "IpAddress": "40.113.200.201"
 }
 martijn@monitoring:~$

As already stated, the output isn’t yet valid JSON, we need to slurp it once more through the jq tooling.

 martijn@monitoring:~$ dig a microsoft.com +nocomments +noquestion +noauthority +noadditional +nostats  | awk '{if (NR>3){print}}'| tr -s '\t' | jq -R 'split("\t") |{Name:.[0],TTL:.[1],Class:.[2],Type:.[3],IpAddress:.[4]}' | jq --slurp .
 [
   {
     "Name": "microsoft.com.",
     "TTL": "3256",
     "Class": "IN",
     "Type": "A",
     "IpAddress": "104.215.148.63"
   },
   {
     "Name": "microsoft.com.",
     "TTL": "3256",
     "Class": "IN",
     "Type": "A",
     "IpAddress": "13.77.161.179"
   },
   {
     "Name": "microsoft.com.",
     "TTL": "3256",
     "Class": "IN",
     "Type": "A",
     "IpAddress": "40.76.4.15"
   },
   {
     "Name": "microsoft.com.",
     "TTL": "3256",
     "Class": "IN",
     "Type": "A",
     "IpAddress": "40.112.72.205"
   },
   {
     "Name": "microsoft.com.",
     "TTL": "3256",
     "Class": "IN",
     "Type": "A",
     "IpAddress": "40.113.200.201"
   }
 ]
 martijn@monitoring:~$

So, basically, to get the result of dig in an json valid output you could create one call in your bash script to

#!/bin/bash
recordtype="A"
fqdn="microsoft.com"
digjson=$( dig $recordtype $fqdn +nocomments +noquestion +noauthority +noadditional +nostats  | awk '{if (NR>3){print}}'| tr -s '\t' | jq -R 'split("\t") |{Name:.[0],TTL:.[1],Class:.[2],Type:.[3],IpAddress:.[4]}' | jq --slurp . )

Feel free to query your own domainname or specific record and adjust the recordtype, preferably by setting the variables.

Pursuing the Cisco Certified Network Professional Voice certification? Update your path!

Whenever you are pursuing a Cisco Certified Network Professional certification in the Voice section, you should update your certification path. As of augusth 15th you will nolonger be able to obtain your CCNP Voice certification. Even if you still have to achieve your CCNP Voice, i would recommend you to update your certification path and obtain the brand new Cisco Certified Network Professional Collaboration certification.

The new CCNP Collaboration exam consist for a large part of the existing CCNP Voice materials, but has some updated exams on Video topics. Also it consists out of less exams to take. So on a financial base it would even save you money.

So what changed, for a beginning you are no longer required to take and pass the CVOICE exam. The CIPT1, CAPPS and TVOICE exams will give some eemptions for the new CCNP Collaboration certification. So if you already did one or more exams have a look at the CCNP Collaboration Exam Migration Tool.

Have a look at the migration scheme.

CCNP Collaboration

If you are already CCNP Voice, take the new CIPTV2 exam and upgrade your certification to CCNP Collaboration.

Cisco’s Voice & Video certification becomes Collaboration

Recently i achieved my CCNA Voice certification, only a few days before Cisco announced it will be merging their CCNA Voice and CCNA Video into the new CCNA Collaboration.

The new Collaboration certification consists out of two exams, basicly the old ICOMM and VIVND exams renumbered. That makes it easier to update your certification to the brand new Collaboration certification.
If you have only one of the two exams there is the CCNA Collaboration Exam Migration Tool.

This means for me, with only the ICOMM 640-461, i have to achieve the old VIVND (200-001) exam before august 15th or i can do the new CIVND (210-065) exam.

A new task has been created on my certification roadmap. Soon i also will explain what this means for the CCNP Voice i am/was pursuing…

CCNA Voice to Collab

CCNA Voice behaald

In december 2013, op de valreep van het jaar, schreef ik dat ik voor het einde van 2014 mijn CCNA Voice wilde behalen.

Die deadline heb ik door het werk niet gehaald, wel heb ik een maand later alsnog deze certificering behaald.

De volgende die ik na streef is mijn Design Associate degree. Inmiddels begonnen aan een video en audio introductie, vervolgens het boek doorwerken.
De pre-course assesment liet drie jaar geleden al een positieve start doorschemeren.
De assesment zal ik binnenkort nog eens doen om te kijken waar ik sta.

Een nieuw jaar, een nieuwe certificering?

We hebben nog een paar dagen te gaan in 2013 en dat houdt in dat de meeste mensen nadenken over wat ze in het nieuwe jaar willen bereiken.

Goede voornemens noemen we ze meestal, maar ook carriere paden worden regelmatig onder de loop genomen.

Zelf heb ik al een tijd geleden opgeschreven wat ik graag zou willen, maar ben daar niet geheel aan toe gekomen. Het studieboek en bijbehorende instructie dvd liggen bijvoorbeeld al 4 maanden in huis. Met de start van 2014 wil ik mij graag gaan focussen op het behalen van mijn CCNA Voice certificering. Het verlengd namelijk mijn CCNA dat ik begin 2012 heb behaald. Daarnaast komt het goed van pas in mijn werk.

Een deadline is ook gesteld, al is het maar om mijn CCNA niet te laten verlopen, eind 2014.

Ik weet dat CCNA een zware beproeving was door de breedheid van de materie. Naast CCIE examens schijnt dit een van de lastigste te zijn. CCNA Voice is daarentegen specifiek op spraak gericht. Echter dit is een oude en complexe materie waar veel verschillende implementatie mogelijkheden voor zijn. Of dit een makkelijke certificering gaat worden valt nog maar te bezien.
image

Albert Heijn pickup point, niet zo snel als verwacht…

Vandaag, 27 juli, vieren we met familie en vrienden dat ik er weer een jaar bij heb mogen tellen.

Met de komst van onze kleine leek het verstandig om de spullen via het pick-up point op te halen. Zodoende staan we nu bij het pick-up point, maar niet al onze spullen zijn er. Nu maar hopen dat ze er zo zijn.

Na circa 30 minuten gewacht te hebben, kwam daar de bestelwagen van Albert aan. Ze kwamen de ontbrekende gekoelde spullen brengen, zodat samen met mij 5 partijen zeer gelukkig hun boodschappen in ontvangst konden nemen.

Als de gekoelde boodschappen voorhanden waren geweest, was het winkelen via Appie stukken sneller geweest, jammer dat dit fout is gelopen. Volgende keer meer geluk?

Het genot van thuiswerken

Iedereen heeft er wel eens van gehoord. Mensen die thuiswerken of werken conform ‘het nieuwe werken’.

Niet voor iedereen weg gelegd en vereist een zekere discipline. Zeker als je van uit huis werkt.

Tussen twee locatie bezoeken vandaag had ik de mogelijkheid om in de tuin mijn email bij te werken.

image

Ook weleens een keer lekker!

I’m with stupid -> Spammer met niet werkende linkjes…

Soms vraag je jezelf af, waarom al die bergen spam worden verstuurd.

Menig partij investeert in een goede oplossing om al die onzin buiten de deur te houden. Echter eens in de zoveel tijd schiet een spam-email wel eens door het filter heen.

Zo ook vandaag, een email dat ik Adobe CS4 zou hebben aangekocht.

Maar als je dan echt mensen naar je malware wilt trekken. Zorg dan dat het linkje werkt… 😉

Pre-course Cisco Certified Design Associate (CCDA) Assessment Results

Just did a pre-course assessment for my next certification track. I am aiming on the Cisco Certified Design Associate as it is for now the most relevant certification in my job-area.

Below my personal results. Cisco partners can do their own free pre-course assessment through the Partner Education Center (PEC).

Student Name:  Martijn
Total # Assessment Questions:  78
Total # Questions Answered:  78
Total # Questions Correct:  51
Overall Score:  65.4%

Scores By Unit:

Applying a Methodology to Network Design
Number Answered: 12
Number Correct: 9
Unit Score: 75.0%

Structuring and Modularizing the Network
Number Answered: 9
Number Correct: 7
Unit Score: 77.8%

Designing Basic Campus-Switched Networks
Number Answered: 6
Number Correct: 5
Unit Score: 83.3%

Designing an Enterprise WAN
Number Answered: 6
Number Correct: 4
Unit Score: 66.7%

Designing IP Addressing for the Network
Number Answered: 6
Number Correct: 5
Unit Score: 83.3%

Selecting Routing Protocols for a Network
Number Answered: 9
Number Correct: 4
Unit Score: 44.4%

Evaluating Security Solutions for the Network
Number Answered: 9
Number Correct: 6
Unit Score: 66.7%

Designing Networks for Voice Transport
Number Answered: 12
Number Correct: 6
Unit Score: 50.0%

Applying Basic Network Management Design
Number Answered: 9
Number Correct: 5
Unit Score: 55.6%

Percentage Correct Per Topic:
66.7% Identifying Organizational Network Policies and Procedures
66.7% Examining Organizational Network Requirements
100.0% Characterizing the Existing Network
66.7% Completing the Network Design
66.7% Designing the Network Hierarchy
66.7% Using a Modular Approach in Network Design
100.0% Evaluating Network Services and Solutions Within Modular Networks
100.0% Reviewing the Campus Design Methodology
66.7% Selecting Campus Design Models
66.7% Reviewing the Enterprise Edge Design Methodology
66.7% Selecting Enterprise Edge Technologies
66.7% Designing IP Addressing
100.0% Introducing IPv6
100.0% Evaluating Routing Protocol Selection Criteria for a Network
0.0% Assessing Routing Protocol Features
33.3% Designing a Routing Protocol Deployment
100.0% Identifying Attacks and Selecting Countermeasures
33.3% Identifying Security Mechanisms for a Defined Security Policy
66.7% Selecting Security Solutions Within Network Modules
66.7% Reviewing Traditional Voice Architectures and Features
33.3% Integrating Voice Architectures
66.7% Identifying the Requirements of Voice Technologies
33.3% Planning Capacity Using Voice Traffic Engineering
66.7% Identifying Network Management Protocols and Features
33.3% Reviewing Functional Areas of Network Management
66.7% Managing Service Levels in a Network

CCDA is a complete different area next to CCNA…