命令行连 vpn

连接

鼠标坏了,所有都只能用命令行了.

vpn 之前是在 menu 里配好的,找到了以下的办法来用命令行的连vpn

fedora 19

nmcli con list

fedora 20

fedora 20 改成了 show

nmcli con show

可以看到可用的vpn和uuid:

NAME                      UUID                                   TYPE              TIMESTAMP-REAL                    
us3.vpncloud.me           6f12dc8d-5b43-4118-8ad8-f80f48ca0a3c   vpn               Tue 13 Aug 2013 10:53:58 AM CST   
Auto 21-2-601             b10cae0c-7a4c-4eb4-8183-fde52589b216   802-11-wireless   never                             
ChinaNet-bigzhu           f0681dc9-856d-4ebd-95a6-c70105450709   802-11-wireless   Thu 22 Aug 2013 08:34:23 AM CST   
LiHao                     b42a3cf3-7d82-4992-ad20-5f1a20cc98dd   802-11-wireless   Sun 30 Jun 2013 11:45:47 AM CST   
KCC                       cf1dd566-9964-4e01-a875-bf69bef58685   802-11-wireless   never                             
BCYY                      d98fb399-4c11-4248-a4fe-a8d3e50578e7   802-11-wireless   never                             
CMCC                      b036101a-c546-49d5-9aa5-7f3eeb9a246f   802-11-wireless   Thu 04 Jul 2013 10:08:42 AM CST   
uk1.vpncloud.me           b3881420-cc06-4141-996b-ae0f7e593ae6   vpn               Tue 14 May 2013 12:21:04 PM CST   
us1.vpncloud.me           b3b795ca-9097-4efc-8dfb-62040c171cd9   vpn               Thu 22 Aug 2013 11:08:15 PM CST   
sg1.vpncloud.me           3aadd172-00c9-4a4d-b7dd-128d47bf17a2   vpn               Tue 14 May 2013 06:08:56 PM CST   
Auto dw135771             45c63fce-2c10-42da-a156-73bd8505aa9a   802-11-wireless   never                             
二叔                      3285eb89-455c-4003-826e-b19c697e126f   802-3-ethernet    Thu 11 Jul 2013 02:32:10 PM CST   
Tenda_3AD5C8 1            8e7c6366-72ce-44c8-bda4-162010e07fec   802-11-wireless   Sat 26 Jan 2013 09:21:50 PM CST   
Auto ChinaNet-bigzhu      0456903a-9012-4705-b570-b00ae830b80a   802-11-wireless   Sun 03 Feb 2013 10:23:13 PM CST   
hykj                      0840b5c8-c8fd-434f-8881-e5c558f46bae   802-11-wireless   Tue 22 Jan 2013 10:37:42 AM CST   
hykj1                     e8235e68-578f-4829-af80-57660fd773b3   802-11-wireless   Thu 01 Aug 2013 01:45:14 PM CST   
ChinaNet                  df357c9c-d659-4445-b892-ad835f11be82   802-11-wireless   Mon 19 Aug 2013 03:58:16 PM CST   
hykj2                     8359c594-d6f8-4c79-8f35-baa1f8b4ba6a   802-11-wireless   Sat 24 Aug 2013 10:26:28 AM CST   
Auto xinyun               a2540cac-b464-4254-b4e1-0a0896f774ca   802-11-wireless   Thu 17 Jan 2013 11:42:15 AM CST   
shuiyuan003               1809751e-8320-432c-846e-cdbbfaa8941d   802-11-wireless   Thu 11 Apr 2013 11:24:40 PM CST   
default                   5dbe489e-405b-4c1a-9575-b98a05d60312   802-11-wireless   never                             
Tenda_3AD5C8              8a85cc9f-84f5-46c1-9bc5-f799a9c30408   802-11-wireless   Sun 13 Jan 2013 08:00:44 PM CST   
China Telecom connection  9357b6d0-2118-4f44-be6f-78a8f86e2166   cdma              Tue 20 Aug 2013 06:50:33 PM CST   
bigzhu                    7e8afbcb-ca88-42a8-a6b4-b8750e142024   802-11-wireless   Sun 23 Jun 2013 10:42:15 PM CST   
Tenda_33A5B8              fc11620b-ac50-46c4-bcde-0fb3a5f7ba90   802-11-wireless   never                             
YNZJKJ                    e956e15d-7dab-406f-bb2c-ffc2c9661cfe   802-11-wireless   Wed 21 Aug 2013 05:07:41 PM CST   
AndroidAP                 da9ae6c4-5fd0-42d8-9c43-6ad9326acefa   802-11-wireless   Thu 08 Aug 2013 07:26:10 PM CST   
Auto hykj                 aabae9a8-0d2c-4e3e-aa5a-9b73748af0d6   802-11-wireless   Tue 22 Jan 2013 09:26:16 PM CST   
MERCURY_0802              2402b918-fbe9-4365-a934-79531fffdefc   802-11-wireless   never                             
我的密码是0到9            4febbea8-b7b1-4f62-958f-ec159f8fc899   802-11-wireless   never                             
auto                      e8241ef8-dfeb-4e88-a7a5-28605741ae78   802-3-ethernet    Tue 02 Jul 2013 10:14:41 AM CST

用以下命令来连

nmcli con up uuid b3b795ca-9097-4efc-8dfb-62040c171cd9

必须要 tmux 出马了,才能把 uuid 复制过来

断开

up 改成 down 就行了

nmcli con down uuid  bbf9eaf3-5ce1-4e73-961a-625ac4deab0a

脚本

编写一个脚本,来连接会方便得多

#! /bin/bash
#连接vpn
#vpn.sh up #连接
#vpn.sh down #断开
nmcli con $1 uuid  bbf9eaf3-5ce1-4e73-961a-625ac4deab0a