Gheek.net

January 27, 2008

ipvpnconfig_cgi

Filed under: cgi, perl — Tags: , — lancevermilion @ 11:19 pm
#!/usr/local/bin/perl
#Written By: Lance Vermilion
#Purpose: Create a IPVPN config for MCI IPVPN
###########################################################################

use CGI qw(:standard);

sub usage () {
print
  "Content-type: text/html\n\n" .
  "\n\n" .
  "IPVPN Config Generator\n" .
  "\n" .
  "\n" .
  "

ERROR

\n" . "

\n" . "\n

"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n
\nYOU MUST FILL OUT EVERY FIELD\n
Size = $size
Iata = $iata
OU = $ou
Rtrnum = $rtrnum
tunnelnum = $tunnelnum
needdlsw = $needdlsw
networkaddress = $networkaddress
MCIenetnetwork = $mcienetnetwork
" . "
\n\n"; exit 0; } #### # Question for the user #### $size = param('size'); $iata = param('iata'); $ou = param('ou'); $rtrnum = param('rtrnum'); $tunnelnum = param('tunnelnum'); $needdlsw = param('needdlsw'); $networkaddress = param('networkaddress'); $MCIenetnetwork = param('mcienetnetwork'); #if ( $size eq "" ) { #&usage; #} elsif ( $iata eq "" ) { #&usage; #} elsif ( $ou eq "" ) { #&usage; #} elsif ( $rtrnum eq "" ) { #&usage; #} elsif ( $tunnelnum eq "" ) { #&usage; #} elsif ( $needdlsw eq "" ) { #&usage; #} elsif ( $networkaddress ne "") { #&usage; #} elsif ( $MCIenetnetwork ne "") { ######################################## #### DO NOT CHANGE BELOW THIS POINT #### ######################################## ##### # MCI ENET IP MASSAGING ##### my (@MCIenet) = split(/\./, $MCIenetnetwork); $MCIenet4thoctet = $MCIenet[3] + 1; $MCIrtrenet4thoctet = $MCIenet[3] + 2; $MCIenetIP = "$MCIenet[0].$MCIenet[1].$MCIenet[2].$MCIenet4thoctet"; $MCIrtrenetIP = "$MCIenet[0].$MCIenet[1].$MCIenet[2].$MCIrtrenet4thoctet"; ##### # LAN ENET IP MASSAGING ##### if ( $size eq '/24' ) { my (@ips) = split(/\./, $networkaddress); $ip3octets = "$ips[0].$ips[1].$ips[2]"; $dnetwork = $ip3octets . ".0"; $ip3octetsGRE = "$ips[0].$ips[1].$ips[2]"; $dsubnet = "255.255.255.192"; $subnet = "255.255.255.0"; } elsif ( $size eq '/23' ) { $dsubnet = "255.255.255.128"; my (@ips) = split(/\./, $networkaddress); $ip3octets = "$ips[0].$ips[1].$ips[2]"; $dnetwork = $ip3octets . ".0"; my $ip3rdoctet = $ips[2] + 1; $ip3octetsGRE = "$ips[0].$ips[1].$ip3rdoctet"; $ip3octetsLO = "$ips[0].$ips[1].$ip3rdoctet"; $subnet = "255.255.254.0"; } elsif ( $size eq '/22' ) { $dsubnet = "255.255.255.0"; my (@ips) = split(/\./, $networkaddress); $ip3octets = "$ips[0].$ips[1].$ips[2]"; $dnetwork = $ip3octets . ".0"; my $ip3rdoctet = $ips[2] + 3; $ip3octetsGRE = "$ips[0].$ips[1].$ip3rdoctet"; $ip3octetsLO = "$ips[0].$ips[1].$ip3rdoctet"; $subnet = "255.255.252.0"; } else { print print "\n\n\n" . print "\n\n\n" . print "\nERROR\n" . print "\n\n" . print "\n\n" . print "\n

ERROR

\n" . print "\n

\n" . print "\n\n"; print "\n

"; print "\n"; print "\n
YOU MUST TYPE: /22 or /23 or /24 NOT $size
\n\n"; exit 0; } print "Content-type: text/html\n\n" . "\n\n" . "IPVPN Config Generator\n" . "\n" . "\n" . "\n" . "\n"; if ( $needdlsw eq "yes" ) { if ( $rtrnum eq "1" ) { print "\n"; } else { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; if ( $needdlsw eq "yes" ) { print "\n"; print "\n"; } print "\n"; if ( $rtrnum eq "2" ) { print "\n"; } print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "

\n

“;
print “\n

IPVPN Config -- $iata-$ou
dlsw local-peer peer-id $ip3octets.2
dlsw local-peer peer-id $ip3octets.3
dlsw remote-peer 0 tcp 199.41.124.253 timeout 180
dlsw remote-peer 0 tcp 199.41.124.254 backup-peer 199.41.124.253 timeout 180 linger 3
dlsw icannotreach sap AA F0 FC
!
interface Tunnel$tunnelnum
&nbspdescription GRE Tunnel over MCI Network to us-phx-co01-ich-rt06
&nbspip address $ip3octetsGRE.242 255.255.255.252
&nbspdelay 200
&nbsptunnel source Ethernet0/0
&nbsptunnel destination 7.224.220.2
\!
router eigrp 75
&nbspnetwork 7.0.0.0
&nbspno auto-summary
&nbspno eigrp log-neighbor-changes
\!
ip route $dnetwork $subnet Null0
ip route 199.41.124.253 255.255.255.255 7.231.105.2
ip route 199.41.124.254 255.255.255.255 7.231.105.2
ip route 7.224.220.2 255.255.255.255 $MCIrtrenetIP
ip route $ip3octetsLO.254 255.255.255.255 $ip3octets.2
\!
router bgp 65196
&nbspno synchronization
&nbspbgp log-neighbor-changes
&nbspnetwork $dnetwork mask $subnet
&nbspneighbor $ip3octetsGRE.241 remote-as 65199
&nbspneighbor $ip3octetsGRE.241 next-hop-self
&nbspno auto-summary

\n
IPVPN Config -- us-phx-co01-ich-rt06
interface Tunnel$tunnelnum
&nbspdescription GRE Tunnel over MCI Network to us-$iata-$ou-ice-rt0$rtrnum
&nbspip address $ip3octetsGRE.241 255.255.255.252
&nbsptunnel source GigabitEthernet0/0
&nbsptunnel destination $MCIenetIP
\!
router bgp 65199
&nbspneighbor $ip3octetsGRE.242 remote-as 65196
&nbspneighbor $ip3octetsGRE.242 next-hop-self
&nbspneighbor $ip3octetsGRE.242 distribute-list Default-Only out

\n\n”;

exit 0;

#} else {
# &usage;
#}

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: