]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/ovpnmain.cgi
Forward Firewall: deleted configfile "nat" in ovpnmain.cgi for portfw check. File...
[people/teissler/ipfire-2.x.git] / html / cgi-bin / ovpnmain.cgi
old mode 100755 (executable)
new mode 100644 (file)
index 24bead3..899bf3e
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2007-2011  IPFire Team  <info@ipfire.org>                     #
+# Copyright (C) 2007-2013  IPFire Team  <info@ipfire.org>                     #
 #                                                                             #
 # This program is free software: you can redistribute it and/or modify        #
 # it under the terms of the GNU General Public License as published by        #
@@ -30,6 +30,7 @@ use File::Copy;
 use File::Temp qw/ tempfile tempdir /;
 use strict;
 use Archive::Zip qw(:ERROR_CODES :CONSTANTS);
+use Sort::Naturally;
 require '/var/ipfire/general-functions.pl';
 require "${General::swroot}/lang.pl";
 require "${General::swroot}/header.pl";
@@ -127,21 +128,6 @@ sub sizeformat{
     return("$newsize $units[$i]");
 }
 
-sub valid_dns_host {
-       my $hostname = $_[0];
-       unless ($hostname) { return "No hostname"};
-       my $res = new Net::DNS::Resolver;
-       my $query = $res->search("$hostname");
-       if ($query) {
-               foreach my $rr ($query->answer) {
-                       ## Potential bug - we are only looking at A records:
-                       return 0 if $rr->type eq "A";
-               }
-       } else {
-               return $res->errorstring;
-       }
-}
-
 sub cleanssldatabase
 {
     if (open(FILE, ">${General::swroot}/ovpn/certs/serial")) {
@@ -180,49 +166,29 @@ sub deletebackupcert
                unlink ("${General::swroot}/ovpn/certs/$hexvalue.pem");
        }
 }
-
 sub checkportfw {
-    my $KEY2 = $_[0]; # key2
-    my $SRC_PORT = $_[1]; # src_port
-    my $PROTOCOL = $_[2]; # protocol
-    my $SRC_IP = $_[3]; # sourceip
-
-    my $pfwfilename = "${General::swroot}/portfw/config";
-    open(FILE, $pfwfilename) or die 'Unable to open config file.';
-    my @pfwcurrent = <FILE>;
-    close(FILE);
-    my $pfwkey1 = 0; # used for finding last sequence number used 
-    foreach my $pfwline (@pfwcurrent)
-    {
-       my @pfwtemp = split(/\,/,$pfwline);
-
-       chomp ($pfwtemp[8]);
-       if ($KEY2 eq "0"){ # if key2 is 0 then it is a portfw addition
-               if ( $SRC_PORT eq $pfwtemp[3] &&
-                       $PROTOCOL eq $pfwtemp[2] &&
-                       $SRC_IP eq $pfwtemp[7])
-               {
-                        $errormessage = "$Lang::tr{'source port in use'} $SRC_PORT";
-               }
-               # Check if key2 = 0, if it is then it is a port forward entry and we want the sequence number
-               if ( $pfwtemp[1] eq "0") {
-                       $pfwkey1=$pfwtemp[0];
-               }
-               # Darren Critchley - Duplicate or overlapping Port range check
-               if ($pfwtemp[1] eq "0" && 
-                       $PROTOCOL eq $pfwtemp[2] &&
-                       $SRC_IP eq $pfwtemp[7] &&
-                       $errormessage eq '') 
-               {
-                       &portchecks($SRC_PORT, $pfwtemp[5]);            
-#                      &portchecks($pfwtemp[3], $pfwtemp[5]);
-#                      &portchecks($pfwtemp[3], $SRC_IP);
+       my $DPORT = shift;
+       my $DPROT = shift;
+       my %natconfig =();
+       my $confignat = "${General::swroot}/forward/config";
+       $DPROT= uc ($DPROT);
+       &General::readhasharray($confignat, \%natconfig);
+       foreach my $key (sort keys %natconfig){
+               my @portarray = split (/\|/,$natconfig{$key}[30]);
+               foreach my $value (@portarray){
+                       if ($value =~ /:/i){
+                               my ($a,$b) = split (":",$value);
+                               if ($DPROT eq $natconfig{$key}[12] && $DPORT gt $a && $DPORT lt $b){
+                                       $errormessage= "$Lang::tr{'source port in use'} $DPORT";
+                               }
+                       }else{
+                               if ($DPROT eq $natconfig{$key}[12] && $DPORT eq $value){
+                                       $errormessage= "$Lang::tr{'source port in use'} $DPORT";
+                               }
+                       }
                }
        }
-    }
-#    $errormessage="$KEY2 $SRC_PORT $PROTOCOL $SRC_IP";
-
-    return;
+       return;
 }
 
 sub checkportoverlap
@@ -254,32 +220,6 @@ sub checkportinc
                return 0; 
        }
 }
-# Darren Critchley - Duplicate or overlapping Port range check
-sub portchecks
-{
-       my $p1 = $_[0]; # New port range
-       my $p2 = $_[1]; # existing port range
-#      $_ = $_[0];
-       our ($prtrange1, $prtrange2);
-       $prtrange1 = 0;
-#      if (m/:/ && $prtrange1 == 1) { # comparing two port ranges
-#              unless (&checkportoverlap($p1,$p2)) {
-#                      $errormessage = "$Lang::tr{'source port overlaps'} $p1";
-#              }
-#      }
-       if (m/:/ && $prtrange1 == 0 && $errormessage eq '') { # compare one port to a range
-               unless (&checkportinc($p2,$p1)) {
-                       $errormessage = "$Lang::tr{'srcprt within existing'} $p1";
-               }
-       }
-       $prtrange1 = 1;
-       if (! m/:/ && $prtrange1 == 1 && $errormessage eq '') { # compare one port to a range
-               unless (&checkportinc($p1,$p2)) {
-                       $errormessage = "$Lang::tr{'srcprt range overlaps'} $p2";
-               }
-       }
-       return;
-}
 
 # Darren Critchley - certain ports are reserved for IPFire 
 # TCP 67,68,81,222,445
@@ -497,7 +437,6 @@ sub addccdnet
        my @ccdconf=();
        my $ccdname=$_[0];
        my $ccdnet=$_[1];
-       my $ovpnsubnet=$_[2];
        my $subcidr;
        my @ip2=();
        my $checkup;
@@ -532,29 +471,8 @@ sub addccdnet
                return;
        }
        
+       $errormessage=&General::checksubnets($ccdname,$ccdnet);
        
-       #check if we try to use same network as ovpn server
-       if (&General::iporsubtocidr($ccdnet) eq &General::iporsubtocidr($ovpnsubnet)) {
-                       $errormessage=$errormessage.$Lang::tr{'ccd err isovpnnet'}."<br>";
-       }
-               
-       #check if we use a name/subnet that already exists
-       &General::readhasharray("${General::swroot}/ovpn/ccd.conf", \%ccdconfhash);
-       foreach my $key (keys %ccdconfhash) {
-                       @ccdconf=split(/\//,$ccdconfhash{$key}[1]);
-                       if ($ccdname eq $ccdconfhash{$key}[0]) {$errormessage=$errormessage.$Lang::tr{'ccd err nameexist'}."<br>";}
-                       my ($newip,$newsub) = split(/\//,$ccdnet);
-                       if (&General::IpInSubnet($newip,$ccdconf[0],&General::iporsubtodec($ccdconf[1]))) {$errormessage=$errormessage.$Lang::tr{'ccd err issubnet'}."<br>";}
-                       
-       }
-       #check if we use one of ipfire's networks (green,orange,blue)
-       my %ownnet=();
-       &General::readhash("${General::swroot}/ethernet/settings", \%ownnet);
-       if (($ownnet{'GREEN_NETADDRESS'}        ne '' && $ownnet{'GREEN_NETADDRESS'}    ne '0.0.0.0') && &General::IpInSubnet($ownnet{'GREEN_NETADDRESS'},$ccdip,&General::iporsubtodec($subcidr))){ $errormessage=$Lang::tr{'ccd err green'};}
-       if (($ownnet{'ORANGE_NETADDRESS'}       ne '' && $ownnet{'ORANGE_NETADDRESS'}   ne '0.0.0.0') && &General::IpInSubnet($ownnet{'ORANGE_NETADDRESS'},$ccdip,&General::iporsubtodec($subcidr))){ $errormessage=$Lang::tr{'ccd err orange'};}
-       if (($ownnet{'BLUE_NETADDRESS'}         ne '' && $ownnet{'BLUE_NETADDRESS'}     ne '0.0.0.0') && &General::IpInSubnet($ownnet{'BLUE_NETADDRESS'},$ccdip,&General::iporsubtodec($subcidr))){ $errormessage=$Lang::tr{'ccd err blue'};}
-       if (($ownnet{'RED_NETADDRESS'}  ne '' && $ownnet{'RED_NETADDRESS'}      ne '0.0.0.0') && &General::IpInSubnet($ownnet{'RED_NETADDRESS'},$ccdip,&General::iporsubtodec($subcidr))){ $errormessage=$Lang::tr{'ccd err red'};}
-               
                
        if (!$errormessage) {
                my %ccdconfhash=();
@@ -635,7 +553,7 @@ sub getccdadresses
        my %ccdhash=();
        &General::readhasharray("${General::swroot}/ovpn/ovpnconfig", \%ccdhash);
        $iprange[0]=$ip1.".".$ip2.".".$ip3.".".2;
-       for (my $i=0;$i<=$count-1;$i++) {
+       for (my $i=1;$i<=$count;$i++) {
                my $tmpip=$iprange[$i-1];
                my $stepper=$i*4;
                $iprange[$i]= &General::getnextip($tmpip,4);
@@ -885,7 +803,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save-adv-options'}) {
     }
                
     if ($cgiparams{'DHCP_DOMAIN'} ne ''){
-       unless (&General::validfqdn($cgiparams{'DHCP_DOMAIN'}) || &General::validip($cgiparams{'DHCP_DOMAIN'})) {
+       unless (&General::validdomainname($cgiparams{'DHCP_DOMAIN'}) || &General::validip($cgiparams{'DHCP_DOMAIN'})) {
                $errormessage = $Lang::tr{'invalid input for dhcp domain'};
        goto ADV_ERROR;
        }
@@ -1004,7 +922,11 @@ unless(-d "${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}"){mkdir "${General
   print SERVERCONF "persist-key\n";
   print SERVERCONF "script-security 2\n";
   print SERVERCONF "# IP/DNS for remote Server Gateway\n"; 
+
+  if ($cgiparams{'REMOTE'} ne '') {
   print SERVERCONF "remote $cgiparams{'REMOTE'}\n";
+  }
+
   print SERVERCONF "float\n";
   print SERVERCONF "# IP adresses of the VPN Subnet\n"; 
   print SERVERCONF "ifconfig $ovsubnet.1 $ovsubnet.2\n"; 
@@ -1177,7 +1099,7 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'save'} && $cgiparams{'TYPE'} eq '' && $cg
     
     
     if ($cgiparams{'ENABLED'} eq 'on'){
-       &checkportfw(0,$cgiparams{'DDEST_PORT'},$cgiparams{'DPROTOCOL'},'0.0.0.0');
+       &checkportfw($cgiparams{'DDEST_PORT'},$cgiparams{'DPROTOCOL'});
     }
        
     if ($errormessage) { goto SETTINGS_ERROR; }
@@ -2123,20 +2045,20 @@ else
     print CLIENTCONF "#OpenVPN Client conf\r\n";
     print CLIENTCONF "tls-client\r\n";
     print CLIENTCONF "client\r\n";
-    print CLIENTCONF "nobind\n";
+    print CLIENTCONF "nobind\r\n";
     print CLIENTCONF "dev $vpnsettings{'DDEVICE'}\r\n";
     print CLIENTCONF "proto $vpnsettings{'DPROTOCOL'}\r\n";
 
     # Check if we are using fragment, mssfix or mtu-disc and set MTU to 1500
     # or use configured value.
     if ($vpnsettings{FRAGMENT} ne '' && $vpnsettings{DPROTOCOL} ne 'tcp' )
-       { print CLIENTCONF "$vpnsettings{'DDEVICE'}-mtu 1500\n"; }
+       { print CLIENTCONF "$vpnsettings{'DDEVICE'}-mtu 1500\r\n"; }
     elsif ($vpnsettings{MSSFIX} eq 'on')
-       { print CLIENTCONF "$vpnsettings{'DDEVICE'}-mtu 1500\n"; }
+       { print CLIENTCONF "$vpnsettings{'DDEVICE'}-mtu 1500\r\n"; }
     elsif (($vpnsettings{'PMTU_DISCOVERY'} eq 'yes') ||
            ($vpnsettings{'PMTU_DISCOVERY'} eq 'maybe') ||
            ($vpnsettings{'PMTU_DISCOVERY'} eq 'no' )) 
-       { print CLIENTCONF "$vpnsettings{'DDEVICE'}-mtu 1500\n"; }
+       { print CLIENTCONF "$vpnsettings{'DDEVICE'}-mtu 1500\r\n"; }
     else
        { print CLIENTCONF "$vpnsettings{'DDEVICE'}-mtu $vpnsettings{'DMTU'}\r\n"; }
 
@@ -2189,7 +2111,7 @@ else
         ($vpnsettings{'PMTU_DISCOVERY'} eq 'maybe') ||
         ($vpnsettings{'PMTU_DISCOVERY'} eq 'no' )) {
        if(($vpnsettings{MSSFIX} ne 'on') || ($vpnsettings{FRAGMENT} eq '')) {
-               print CLIENTCONF "mtu-disc $vpnsettings{'PMTU_DISCOVERY'}\n";
+               print CLIENTCONF "mtu-disc $vpnsettings{'PMTU_DISCOVERY'}\r\n";
        }
     }
     close(CLIENTCONF);
@@ -2361,6 +2283,9 @@ ADV_ERROR:
     if ($cgiparams{'LOG_VERB'} eq '') {
        $cgiparams{'LOG_VERB'} =  '3';
     }
+    if ($cgiparams{'PMTU_DISCOVERY'} eq '') {
+       $cgiparams{'PMTU_DISCOVERY'} = 'off';
+    }
     $checked{'CLIENT2CLIENT'}{'off'} = '';
     $checked{'CLIENT2CLIENT'}{'on'} = '';
     $checked{'CLIENT2CLIENT'}{$cgiparams{'CLIENT2CLIENT'}} = 'CHECKED';
@@ -2397,7 +2322,7 @@ ADV_ERROR:
     }
     &Header::openbox('100%', 'LEFT', $Lang::tr{'advanced server'});
     print <<END
-    <form method='post' enctype='multipart/form-data' disabled>
+    <form method='post' enctype='multipart/form-data'>
     <table width='100%' border=0>
     <tr>
        <td colspan='4'><b>$Lang::tr{'dhcp-options'}</b></td>
@@ -2458,7 +2383,7 @@ print <<END;
         <td><input type='text' name='MAX_CLIENTS' value='$cgiparams{'MAX_CLIENTS'}' size='10' /></td>
     </tr>      
        <tr>
-         <td class='base'>Keppalive <br />
+         <td class='base'>Keepalive <br />
            (ping/ping-restart)</td>
          <td><input type='TEXT' name='KEEPALIVE_1' value='$cgiparams{'KEEPALIVE_1'}' size='10' /></td>
          <td><input type='TEXT' name='KEEPALIVE_2' value='$cgiparams{'KEEPALIVE_2'}' size='10' /></td>
@@ -2588,7 +2513,7 @@ END
        }
        
        if ($cgiparams{'ACTION'} eq $Lang::tr{'ccd add'}) {
-               &addccdnet($cgiparams{'ccdname'},$cgiparams{'ccdsubnet'},$cgiparams{'DOVPN_SUBNET'});
+               &addccdnet($cgiparams{'ccdname'},$cgiparams{'ccdsubnet'});
        }
        if ($errormessage) {
            &Header::openbox('100%', 'LEFT', $Lang::tr{'error messages'});
@@ -3342,6 +3267,7 @@ if ($cgiparams{'TYPE'} eq 'host') {
                                                        goto VPNCONF_ERROR;
                                                }
                                                my ($ip1,$cidr1) = split (/\//, $val);
+                                               $ip1 = &General::getnetworkip($ip1,&General::iporsubtocidr($cidr1));
                                                my ($ip2,$cidr2) = split (/\//, $ccdroutehash{$key}[$oldiroute]);
                                                if (&General::IpInSubnet ($ip1,$ip2,$cidr2)){
                                                        $errormessage=$errormessage.$Lang::tr{'ccd err irouteexist'};
@@ -3519,21 +3445,36 @@ if ($cgiparams{'TYPE'} eq 'host') {
 ###
 
 if ($cgiparams{'TYPE'} eq 'net') {
-               
-    if ($cgiparams{'DEST_PORT'} eq  $vpnsettings{'DDEST_PORT'}) {
+       if ($cgiparams{'DEST_PORT'} eq  $vpnsettings{'DDEST_PORT'}) {
                        $errormessage = $Lang::tr{'openvpn destination port used'};
                        unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
            rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
       goto VPNCONF_ERROR;                      
                }
-    
-    if ($cgiparams{'DEST_PORT'} eq  '') {
+    #Bugfix 10357
+    foreach my $key (sort keys %confighash){
+               if ( ($confighash{$key}[22] eq $cgiparams{'DEST_PORT'} && $cgiparams{'NAME'} ne $confighash{$key}[1]) || ($confighash{$key}[29] eq $cgiparams{'DEST_PORT'} && $cgiparams{'NAME'} ne $confighash{$key}[1])){
                        $errormessage = $Lang::tr{'openvpn destination port used'};
                        unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
            rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
+      goto VPNCONF_ERROR;      
+               }
+       }
+    if ($cgiparams{'DEST_PORT'} eq  '') {
+                       $errormessage = $Lang::tr{'invalid port'};
+                       unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
+           rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
       goto VPNCONF_ERROR;                      
                }
 
+    # Check if the input for the transfer net is valid.
+    if (!&General::validipandmask($cgiparams{'OVPN_SUBNET'})){
+                       $errormessage = $Lang::tr{'ccd err invalidnet'};
+                       unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
+           rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
+                       goto VPNCONF_ERROR;
+               }
+
     if ($cgiparams{'OVPN_SUBNET'} eq  $vpnsettings{'DOVPN_SUBNET'}) {
                        $errormessage = $Lang::tr{'openvpn subnet is used'};
                        unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
@@ -3555,13 +3496,6 @@ if ($cgiparams{'TYPE'} eq 'net') {
            goto VPNCONF_ERROR;
     }
 
-    if (($cgiparams{'PMTU_DISCOVERY'} ne 'off') && ($cgiparams{'MTU'} ne '1500')) {
-       $errormessage = $Lang::tr{'ovpn mtu-disc and mtu not 1500'};
-       unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
-       rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
-       goto VPNCONF_ERROR;
-    }
-
     if ($cgiparams{'PMTU_DISCOVERY'} ne 'off') {
        if (($cgiparams{'FRAGMENT'} ne '') || ($cgiparams{'MSSFIX'} eq 'on')) {
                $errormessage = $Lang::tr{'ovpn mtu-disc with mssfix or fragment'};
@@ -3571,6 +3505,13 @@ if ($cgiparams{'TYPE'} eq 'net') {
        }
     }
 
+    if (($cgiparams{'PMTU_DISCOVERY'} ne 'off') && ($cgiparams{'MTU'} ne '1500')) {
+       $errormessage = $Lang::tr{'ovpn mtu-disc and mtu not 1500'};
+       unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
+       rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
+       goto VPNCONF_ERROR;
+    }
+
     if ( &validdotmask ($cgiparams{'LOCAL_SUBNET'}))  {
                  $errormessage = $Lang::tr{'openvpn prefix local subnet'};
                  unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
@@ -3617,34 +3558,38 @@ if ($cgiparams{'TYPE'} eq 'net') {
            }
        }
 
-       if (($cgiparams{'TYPE'} eq 'net') && (! $cgiparams{'REMOTE'})) {
+       # Check if a remote host/IP has been set for the client.
+       if ($cgiparams{'REMOTE'} eq '' && $cgiparams{'SIDE'} ne 'server') {
            $errormessage = $Lang::tr{'invalid input for remote host/ip'};
+
+           # Check if this is a N2N connection and drop temporary config.
            if ($cgiparams{'TYPE'} eq 'net') {
-      unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
-           rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
-      }
+               unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
+               rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
+           }
            goto VPNCONF_ERROR;
        }
 
-       if ($cgiparams{'REMOTE'}) {
+       # Check if a remote host/IP has been configured - the field can be empty on the server side.
+       if ($cgiparams{'REMOTE'} ne '') {
+
+           # Check if the given IP is valid - otherwise check if it is a valid domain.
            if (! &General::validip($cgiparams{'REMOTE'})) {
+
+               # Check for a valid domain.
                if (! &General::validfqdn ($cgiparams{'REMOTE'}))  {
                    $errormessage = $Lang::tr{'invalid input for remote host/ip'};
+
+                   # Check if this is a N2N connection and drop temporary config.
                    if ($cgiparams{'TYPE'} eq 'net') {
-        unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
-             rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
-        }
+                       unlink ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}/$cgiparams{'NAME'}.conf") or die "Removing Configfile fail: $!";
+                       rmdir ("${General::swroot}/ovpn/n2nconf/$cgiparams{'NAME'}") || die "Removing Directory fail: $!";
+                   }
                    goto VPNCONF_ERROR;
-               } else {
-                   if (&valid_dns_host($cgiparams{'REMOTE'})) {
-                       $warnmessage = "$Lang::tr{'check vpn lr'} $cgiparams{'REMOTE'}. $Lang::tr{'dns check failed'}";
-                       if ($cgiparams{'TYPE'} eq 'net') {
-
-      }
-                   }
                }
            }
        }
+
        if ($cgiparams{'TYPE'} ne 'host') {
             unless (&General::validipandmask($cgiparams{'LOCAL_SUBNET'})) {
                    $errormessage = $Lang::tr{'local subnet is invalid'}; 
@@ -3941,7 +3886,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
            }
        }
 
-        # Save the config
+    # Save the config
        my $key = $cgiparams{'KEY'};
        
        if (! $key) {
@@ -4001,12 +3946,13 @@ if ($cgiparams{'TYPE'} eq 'net') {
                        if ( -e "${General::swroot}/ovpn/ccd/$confighash{$key}[2]"){
                                unlink "${General::swroot}/ovpn/ccd/$cgiparams{'CERT_NAME'}";
                        }
+                       $confighash{$key}[2] =~ s/ /_/gi;
                        open ( CCDRWCONF,'>',"${General::swroot}/ovpn/ccd/$confighash{$key}[2]") or die "Unable to create clientconfigfile $!";
-                       print CCDRWCONF "# OpenVPN Clientconfig from CCD extension by Copymaster#\n\n";
+                       print CCDRWCONF "# OpenVPN clientconfig from ccd extension by Copymaster#\n\n";
                        if($cgiparams{'CHECK1'} eq 'dynamic'){
                                print CCDRWCONF "#This client uses the dynamic pool\n";
                        }else{
-                               print CCDRWCONF "#Ip address client and Server\n";
+                               print CCDRWCONF "#Ip address client and server\n";
                                print CCDRWCONF "ifconfig-push $ccdip ".&General::getlastip($ccdip,1)."\n";
                        }
                        if ($confighash{$key}[34] eq 'on'){
@@ -4015,7 +3961,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
                        }
                        &General::readhasharray("${General::swroot}/ovpn/ccdroute", \%ccdroutehash);
                        if ($cgiparams{'IR'} ne ''){
-                               print CCDRWCONF "\n#Client routes these Networks (behind Client)\n";
+                               print CCDRWCONF "\n#Client routes these networks (behind Client)\n";
                                foreach my $key (keys %ccdroutehash){
                                        if ($ccdroutehash{$key}[0] eq $cgiparams{'NAME'}){
                                                foreach my $i ( 1 .. $#{$ccdroutehash{$key}}){
@@ -4027,7 +3973,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
                        }
                        if ($cgiparams{'IFROUTE'} eq $Lang::tr{'ccd none'} ){$cgiparams{'IFROUTE'}='';}
                        if ($cgiparams{'IFROUTE'} ne ''){
-                               print CCDRWCONF "\n#Client gets routes to these Networks (behind IPFIRE)\n";
+                               print CCDRWCONF "\n#Client gets routes to these networks (behind IPFire)\n";
                                foreach my $key (keys %ccdroute2hash){
                                        if ($ccdroute2hash{$key}[0] eq $cgiparams{'NAME'}){
                                                foreach my $i ( 1 .. $#{$ccdroute2hash{$key}}){
@@ -4049,7 +3995,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
                        }
                        if(($cgiparams{'CCD_DNS1'} eq '') && ($cgiparams{'CCD_DNS1'} ne '')){ $cgiparams{'CCD_DNS1'} = $cgiparams{'CCD_DNS2'};$cgiparams{'CCD_DNS2'}='';}
                        if($cgiparams{'CCD_DNS1'} ne ''){
-                               print CCDRWCONF "\n#Client gets these Nameservers\n";
+                               print CCDRWCONF "\n#Client gets these nameservers\n";
                                print CCDRWCONF "push \"dhcp-option DNS $cgiparams{'CCD_DNS1'}\" \n";
                        }
                        if($cgiparams{'CCD_DNS2'} ne ''){
@@ -4160,6 +4106,9 @@ if ($cgiparams{'TYPE'} eq 'net') {
     $checked{'MSSFIX'}{'on'} = '';
     $checked{'MSSFIX'}{$cgiparams{'MSSFIX'}} = 'CHECKED';
 
+    if ($cgiparams{'PMTU_DISCOVERY'} eq '') {
+       $cgiparams{'PMTU_DISCOVERY'} = 'off';
+    }
     $checked{'PMTU_DISCOVERY'}{$cgiparams{'PMTU_DISCOVERY'}} = 'checked=\'checked\'';
 
 
@@ -4265,7 +4214,7 @@ if ($cgiparams{'TYPE'} eq 'net') {
 
        <tr>
                <td class='boldbase' nowrap='nowrap'>$Lang::tr{'ovpn mtu-disc'}</td>
-               <td colspan='2'>
+               <td colspan='3'>
                        <input type='radio' name='PMTU_DISCOVERY' value='yes' $checked{'PMTU_DISCOVERY'}{'yes'} /> $Lang::tr{'ovpn mtu-disc yes'}
                        <input type='radio' name='PMTU_DISCOVERY' value='maybe' $checked{'PMTU_DISCOVERY'}{'maybe'} /> $Lang::tr{'ovpn mtu-disc maybe'}
                        <input type='radio' name='PMTU_DISCOVERY' value='no' $checked{'PMTU_DISCOVERY'}{'no'} /> $Lang::tr{'ovpn mtu-disc no'}
@@ -4902,11 +4851,10 @@ END
 </tr>
 END
        ;
-        my $id = 0;
-        my $gif;
-        foreach my $key (sort { uc($confighash{$a}[1]) cmp uc($confighash{$b}[1]) } keys %confighash) {
-       if ($confighash{$key}[0] eq 'on') { $gif = 'on.gif'; } else { $gif = 'off.gif'; }
-
+    my $id = 0;
+    my $gif;
+    foreach my $key (sort { ncmp ($confighash{$a}[1],$confighash{$b}[1]) } keys %confighash) {
+       if ($confighash{$key}[0] eq 'on') { $gif = 'on.gif'; } else { $gif = 'off.gif'; }
        if ($id % 2) {
            print "<tr bgcolor='$color{'color20'}'>\n";
        } else {
@@ -4989,19 +4937,13 @@ END
 }
 
 
-       my $disable_clientdl = "disabled='disabled'";
-       if (( $cgiparams{'ENABLED'} eq 'on') || 
-           ( $cgiparams{'ENABLED_BLUE'} eq 'on') ||
-           ( $cgiparams{'ENABLED_ORANGE'} eq 'on')){
-           $disable_clientdl = "";
-       }
        print <<END
        <td align='center'>$active</td>
                
        <form method='post' name='frm${key}a'><td align='center'>
-           <input type='image'  name='$Lang::tr{'dl client arch'}' $disable_clientdl src='/images/openvpn.png' alt='$Lang::tr{'dl client arch'}' title='$Lang::tr{'dl client arch'}' border='0' />
-           <input type='hidden' name='ACTION' value='$Lang::tr{'dl client arch'}' $disable_clientdl />
-           <input type='hidden' name='KEY' value='$key' $disable_clientdl />
+           <input type='image'  name='$Lang::tr{'dl client arch'}' src='/images/openvpn.png' alt='$Lang::tr{'dl client arch'}' title='$Lang::tr{'dl client arch'}' border='0' />
+           <input type='hidden' name='ACTION' value='$Lang::tr{'dl client arch'}' />
+           <input type='hidden' name='KEY' value='$key' />
        </td></form>
 END
        ;