Skip to content

Instantly share code, notes, and snippets.

@PiBa-NL
Created November 19, 2014 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PiBa-NL/1e5f85db7b47b4ae961d to your computer and use it in GitHub Desktop.
Save PiBa-NL/1e5f85db7b47b4ae961d to your computer and use it in GitHub Desktop.
pfSense, create alias VIPs from alias list
<?
// 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