Created
November 19, 2014 21:55
-
-
Save PiBa-NL/1e5f85db7b47b4ae961d to your computer and use it in GitHub Desktop.
pfSense, create alias VIPs from alias list
This file contains 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
<? | |
// target: pfSense | |
// script to create VIPs of type ipalias from a alias list of ip addresses on | |
// fill the 3 variables below | |
include_once("config.inc"); | |
$aliasToConvert = "MyHostAliasList"; | |
$interfaceToSet = "wan"; | |
$subnetsize = 24; | |
foreach($config['aliases']['alias'] as $ali) { | |
if ($ali['name'] == $aliasToConvert){ | |
$address = explode(" ",$ali['address']); | |
foreach($address as $ip) { | |
if (is_ipaddr($ip)){ | |
print "<br/>Create IPalias for IP: ".$ip; | |
$new = array(); | |
$new['mode']='ipalias'; | |
$new['interface']=$interfaceToSet; | |
$new['descr']='Automatically Created'; | |
$new['type']='single'; | |
$new['subnet_bits']=$subnetsize; | |
$new['subnet']=$ip; | |
$config['virtualip']['vip'][] = $new; | |
} | |
} | |
} | |
} | |
write_config("IP aliasses added from alias list"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment