Bonjour

J'utilise lubuntu

Dans ce script bash:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
 
# get two parameters : ip and port, try to connect to ssl vpn. if success return 0, else return 1
 
 
if [ "x$1" ==  "x" ];
then
	echo "Usage: vpn.sh connect ip port ";
	echo "	     vpn.sh disconnect ";
	exit 1;
fi 
 
if [ "x$1" == "xdisconnect" ];
then
	# delete old sslvpn and collect original ip address for route delete
 
	echo $(cat vpndel.cmd | vpncmd | grep "^VPN Server Hostname" | cut -d "|" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 ) | xargs sudo ./route.sh del;
	exit 0;
fi 
 
if [ "x$1" == "xconnect" ];
then
 
	if [ "x$2" == "x" ] || [ "x$3" == "x" ];
	then
		echo "Usage: vpn.sh connect ip port ";
		exit 1;
	fi
fi		
 
# delete old sslvpn and collect original ip address for route delete
echo $(cat vpndel.cmd | vpncmd | grep "^VPN Server Hostname" | cut -d "|" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 ) | xargs sudo ./route.sh del;
 
 
 
# ensure ip/port is open via nc(netcat). 
 
alive=$(nc -z --timeout=1 $2 $3 )
 
if [ "x$alive" == "x" ]; then
	echo "nc $2:$3 succeeds.";
else
	echo "nc $2:$3 fails.";
    	exit 1;
fi
 
 
 
# generate ssl.vpn
 
./vpndef.sh $2 $3
 
# delete old sslvpn and collect original ip address for route delete
 
echo $(cat vpndel.cmd | /usr/local/vpnclient/vpncmd | grep "^VPN Server Hostname" | cut -d "|" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 ) | xargs sudo ./route.sh del
 
# import new vpn definition
 
cat vpnimport.cmd | /usr/local/vpnclient/vpncmd
cat vpnconnect.cmd | /usr/local/vpnclient/vpncmd  
 
sleep 3
 
isConnected=$(cat vpnlist.cmd | /usr/local/vpnclient/vpncmd | grep  Status  | cut -d "|" -f 2)
 
echo "vpn status is $isConnected"
 
if [ $isConnected != "Connected" ];
then
	#disconnect the old vpn first
	./vpn.sh disconnect
	exit 1;
fi;
 
# add new route 
echo $(cat vpnlist.cmd | /usr/local/vpnclient/vpncmd | grep "^VPN Server Hostname" | cut -d "|" -f 2 | cut -d " " -f 1 | cut -d ":" -f 1 ) | xargs sudo ./route.sh add
 
# test if vpnconnection is up
 
 
connected=$(nc -z --timeout=1 www.youtube.com 80 )
 
if [ "x$connected" == "x" ]; then
        echo "vpn connection to $2:$3 succeeds.";
	exit 0;
else
        echo "vpn connection to $2:$3 fails.";
        exit 1;
fi
j'ai cette erreur:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Specify the host name or IP address of the computer that the destination VPN Client is operating on. 
If nothing is input and Enter is pressed, connection will be made to localhost (this computer).
 
Error occurred. (Error code: 1)
Connection to the server failed. Check network connection and make sure that address and port number of destination server are correct.
vpn status is 
./vpn.sh: ligne 68 : [: != : opérateur unaire attendu
vpn server ip missing!  ./route.sh add/del vpn_server_ip [device]
nc: invalid option -- '-'
This is nc from the netcat-openbsd package. An alternative nc is available
in the netcat-traditional package.
usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
	  [-P proxy_username] [-p source_port] [-q seconds] [-s source]
	  [-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
	  [-x proxy_address[:port]] [destination] [port]
 succeeds.tion to 116.80.157.162:1382
comment résoudre ce problème s'il vous plait

Voici le script nommé "route.sh" si besoin:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/bash
if [ "x$2" == "x" ]; 
then
  echo "vpn server ip missing!  ./route.sh add/del vpn_server_ip [device]" 
  exit 1
fi
 
if [ "x$3" == "x" ];
then
	echo "device not specified. Default to wlan0";
	dev=wlan0;
else
	dev=$3;
fi
 
 
	case "$1" in
 
	add)
 
 
 
	# restore default route to home network
	ip route delete default
	ip route add default via 192.168.100.1 dev $dev
 
	# obtain ip address for vpn_se
	ifdown vpn_se
	ifup vpn_se
 
 
	# add route to vpn server
 
	ip route add $2/32 via 192.168.100.1 dev $dev
	ip route delete default
	ip route add default via 10.211.254.254 dev vpn_se
 
 
	;;
 
	del)
 
 
	ip route del $2/32
	ip route del default
	ip route add default via 192.168.100.1 dev $dev
	ifdown vpn_se
 
 
	;;
 
	esac
j'ai trouvé ce script ici:

https://github.com/lukeluo/linux-deb...e/luke/vpngate

Merci d'avance