Created
October 3, 2012 04:22
-
-
Save mizzy/3824987 to your computer and use it in GitHub Desktop.
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/env perl | |
| use strict; | |
| use warnings; | |
| my @networks = qw( 192.168.47 192.168.48 ); | |
| my $ifconfig = `ifconfig eth1|grep 192.168`; | |
| my ( $ipaddr ) = ( $ifconfig =~ /inet addr:([0-9\.]+)/ ); | |
| my $gw = $ipaddr; | |
| $gw =~ s/([0-9]+\.[0-9]+\.[0-9]+)\.[0-9]+/$1.1/g; | |
| for my $network ( @networks ) { | |
| if ( $ipaddr !~ /$network/ ) { | |
| `route add -net ${network}.0 netmask 255.255.255.0 gw $gw`; | |
| } | |
| } | |
| exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment