Monday, July 13, 2015

Remove Leading Zeros from IP Address

I was working on some automation where I'd need to translate an IP address that was always represented as 3 digits per octet - like 001.002.003.004 instead of 1.2.3.4.

Since I didn't want to reinvent the wheel I went to Google and to my surprise found no examples that worked well - some would only remove 1 leading zero.

So, after some testing and code borrowing, here are two solutions:

Using sed:
sed -r 's/^0*([0-9]+)\.0*([0-9]+)\.0*([0-9]+)\.0*([0-9]+)$/\1.\2.\3.\4/'

Using awk:
awk -F'[.]' '{w=$1+0; x=$2+0; y=$3+0; z=$4+0; print w"."x"."y"."z}'

POC:
$ echo 001.002.003.004 | sed -r 's/^0*([0-9]+)\.0*([0-9]+)\.0*([0-9]+)\.0*([0-9]+)$/\1.\2.\3.\4/'
1.2.3.4
$ echo 001.002.003.004 | awk -F'[.]' '{w=$1+0; x=$2+0; y=$3+0; z=$4+0; print w"."x"."y"."z}'
1.2.3.4

Wednesday, May 20, 2015

Level 3 DNS Hijacking - 4.2.2.2 and others

I posted about Verizon's DNS servers and how some of them perform DNS hijacking for domains which don't resolve. While troubleshooting a problem today I found out to my surprise that Level 3's DNS severs do the same thing, one of which has some notoriety.

Level 3 DNS Servers:
4.2.2.1
4.2.2.2
4.2.2.3
4.2.2.4
4.2.2.5
4.2.2.6

The odd ones (.1, .3, .5) will correctly reply with NXDOMAIN for FQDNs which don't exist. The even ones (.2, .4, .6) will instead resolve to two "SearchGuide" IPs:
~]$ dig @4.2.2.2 domain-i-just-made-up.fake +short
198.105.244.11
198.105.254.11
Any hosts that may have been configured to use these Level 3 DNS servers will have some interesting outgoing connections when trying to connect to internal hosts that aren't externally resolvable. Hopefully this will save a few minutes when investigated unusual connections to 198.105.244.11 or 198.105.254.11.

Sunday, March 29, 2015

Offline Dell PowerEdge Firmware Updates Using the LifeCycle Controller

Dell's FTP servers they host firmware updates on aren't the best - especially when being accessed from the Dell USC Lifecycle Controller. Usually things work fine, but every now and again things go south and you end up seeing a screen like this:
"A network error occurred while trying to connect to the FTP server. Check your network connections, cables, settings, and configuration..."
...or sometimes like this:
"The update packages that you selected to install failed during download or installation. Retry the operation or provide an alternate repository."
Both results can make your day sour fast if you scheduled downtime or are working in a maintenance window. The second error above gives the suggestion to "...provide an alternate repository" and the menu used when launching the the Platform Update has the options of using a Local Drive. I never gave this much thought until I needed to do some updates outside of the OS and couldn't connect to Dell's FTP server. Enter Dell Repository Manager.

I'm not going to walk through the steps since they are well documented on Dell's site, but this should be all you need (for : Lifecycle Controller with Dell Repository Manager

This document outlines how to create a local USB or ISO repository that you can then use to perform these updates offline. You could even have it output to a directory on an FTP server accessible by all your servers.

I always assumed that tools like these weren't that useful unless I was managing hundreds of servers, but it turns out they're great even if you need to update just one.

Tuesday, January 27, 2015

Verizon FiOS Regional DNS Servers

Verizon provides their FiOS customers with 2 regional DNS servers via DHCP that are geographically close to their install location. The default address given out is a ".12" address which utilizes DNS Hijacking to serve you ads from Verizon. Each region has a corresponding ".14  DNS server which does not hijack DNS. Changing to this ".14" address is the method Verizon utilizes for allowing customers to opt-out of their "DNS Assistance".

I couldn't find a complete list of these online, so with a little digging I put this together.

Regional DNS Servers, opt-in/opt-out are listed below. There are many other valid Verizon DNS servers, but these are the ones given out to customers via DHCP. If you are aware of any additional DNS servers given out via DHCP to FiOS customers, please let me know in the comments.

Boston, MA:
nsbost01.verizon.net - 71.243.0.12
nsbost02.verizon.net - 71.243.0.14

New York, NY:
nsnyny01.verizon.net - 68.237.161.12
nsnyny02.verizon.net - 68.237.161.14

Newark, NJ:
nsnwrk01.verizon.net - 71.250.0.12
nsnwrk02.verizon.net - 71.250.0.14

Philadelphia, PA:
nsphil01.verizon.net - 71.242.0.12
nsphil02.verizon.net - 71.242.0.14

Reston, VA:
nsrest01.verizon.net - 71.252.0.12
nsrest02.verizon.net - 71.252.0.14

Atlanta, GA:
nsatla01.verizon.net - 68.238.120.12
nsatla01.verizon.net - 68.238.120.14

Tampa, FL:
nstamp01.verizon.net - 68.238.112.12
nstamp02.verizon.net - 68.238.112.14

Dallas, TX:
nsdall01.verizon.net -  68.238.96.12
nsdall02.verizon.net -  68.238.96.14

Los Angeles, CA:
nslala01.verizon.net - 68.238.64.12
nslala02.verizon.net - 68.238.64.14

Seattle, WA:
nsseat01.verizon.net - 68.238.128.12
nsseat02.verizon.net - 68.238.128.14

(Added 5/5/2016)
Chicago, IL:
nschic01.verizon.net - 68.238.0.12
nschic02.verizon.net - 68.238.0.14