IPv4 conversion aliases

tags: bash  ipv4 

I made a couple of bash aliases to convert IPv4 addresses between integers and dotted decimals since I had to deal with both in a database. The Socket module that comes with Perl does most of the work:

alias ip_aton="perl -MSocket=inet_aton -le 'print unpack q(N), inet_aton(shift)'"
alias ip_ntoa="perl -MSocket=inet_ntoa -le 'print inet_ntoa(pack q(N), shift)'"

PostgreSQL has some network address types that would have made this simpler.