Created
August 3, 2012 07:54
-
-
Save mjf/3245562 to your computer and use it in GitHub Desktop.
Add IPv4 default route to the output of sipcalc(1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/awk -f | |
# Add IPv4 default route to the output of sipcalc(1) | |
# Copyright (C) 2009 Matous Jan Fialka, <http://mjf.cz/> | |
# Released under the terms of The MIT License | |
# | |
# Parse output of sipcalc(1) and add default route value | |
# to the output stream if prefix length is less or equal to 30. | |
# If prefix length equals to 30 then the lower usable address | |
# is added as default route, the highest usable address is | |
# added otherwise. | |
# | |
# Usage: sipcalc <net>[/<mask>] | sipcalc-add-ipv4-default-route.awk | |
{ print } | |
/^Network mask \(bits\)/ { | |
prefix_length = $5 | |
} | |
/^Usable range/ { | |
if(prefix_length > 30) | |
next | |
printf("Default route (gateway)\t- %s\n", | |
prefix_length == 30 ? $4 : $6) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment