Skip to content

Instantly share code, notes, and snippets.

@pricejn2
Last active August 29, 2015 14:07
Show Gist options
  • Save pricejn2/310370f6f3210e6eb948 to your computer and use it in GitHub Desktop.
Save pricejn2/310370f6f3210e6eb948 to your computer and use it in GitHub Desktop.
Generate ifconfig entries. Useful for large IP blocks.
<?php
$vt = 21; // vt start
$ip = 48; // ip start
$vt_static = "eth2:";
$ip_static = "192.99.243.";
$ip_max = "55";
while ($ip <= $ip_max) {
$vt_full = '';
$vt_full .= $vt_static;
$vt_full .= $vt;
$ip_full = '';
$ip_full .= $ip_static;
$ip_full .= $ip;
echo "post-up /sbin/ifconfig ".$vt_full." ".$ip_full." netmask 255.255.255.255 broadcast ".$ip_full.PHP_EOL;
echo "post-down /sbin/ifconfig ".$vt_full." down".PHP_EOL;
$vt++;
$ip++;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment