Why should you learn Linux?
I've been asked and seen many posts about "Why should I learn Linux" or others telling folks to learn Linux with no guidance. In this article, I'm going to cover a few basic commands found in Linux
We will do a zone transfer from ioc2rpz.net using "dig" to get a list of all known DoH servers. All we need out of the zone transfer are either the IPs or domains from the data. We will use all the commands above to change the following output:
doh.nl.ahadns.net.doh.ioc2rpz. 900 IN CNAME.
to this
doh.nl.ahadns.net
Getting the Data
We will use "dig" to do a zone transfer from ioc2rpz.net; here is a screenshot of the command with the output:
The zone transfer gives us IP Addresses and domains as well. Now, in this example, we only want to get back the CNAMEs. We will use "grep" to accomplish this, and pipe( | ) the command to "grep CNAME":
Now, we want to print out just the first element in each line; we will use "awk":
Recommended by LinkedIn
Here, we added another pipe( | ) to the command "awk '{ print $1 }' ". The $1 is the first element that's passed from the "grep" output. We are so close to getting the data we need, now let's use "sed":
Now the IPs are showing fine because we used "sed 's/.rpz-ip.doh.ioc2rpz.//g' " but when we scroll down I notice the domains are not the way I wanted them
How are we going to clean this up? We are going to modify our "sed" command to remove two possible matches in each element: "sed 's/.rpz-ip.doh.ioc2rpz.//g;s/.doh.ioc2rpz.//g' "
As you can see, our output is clean, both IPs and domains. Here is the command I used:
dig @94.130.30.123 -y hmac-sha256 doh.ioc2rpz AXFR axfr | grep CNAME | awk '{ print $1 }' | sed 's/.rpz-ip.doh.ioc2rpz.//g;s/.doh.ioc2rpz.//g'
Conclusion
The above is one of many examples of why you should learn Linux. It's powerful, flexible, and has many, many uses in the “real world”. For those who are studying in the fields of Network Engineering, Security, and all things Cloudy, Linux can help.
Hey Sif, awk sed regex with vim, and then vim said What? Great post on becoming "one of us".
Awesome material for beginners, Also checkout manpagecards.com 😄.
Hey Sif Baksh This is great. Any thoughts on how we could get the actual IP from that list? 32.6.6.6.102 -> 102.6.6.6
Great tutorial!
great stuff Sid :)