AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 821168
Accepted
bigbiggerpepe
bigbiggerpepe
Asked: 2016-12-17 08:05:17 +0800 CST2016-12-17 08:05:17 +0800 CST 2016-12-17 08:05:17 +0800 CST

不同主机中的多个 openvpn 客户端

  • 772

我正在尝试同时运行多个 openvpn 实例,运行单个实例时一切正常,但我希望有几个实例,每个实例连接到不同的主机,并从那里能够使用我的接口想。

我正在尝试这样:

法国.ovpn

client
dev tun
proto udp
remote france.privateinternetaccess.com
lport 1190
resolv-retry infinite
persist-key
persist-tun
cipher aes-128-cbc
auth sha1
tls-client
remote-cert-tls server
auth-user-pass /etc/openvpn/piaauth.txt
comp-lzo
verb 1
reneg-sec 0
crl-verify /etc/openvpn/crl.rsa.2048.pem
ca /etc/openvpn/ca.rsa.2048.crt
disable-occ
lport 1189
rport 1198

|

 sudo /usr/sbin/openvpn --config /etc/openvpn/France.ovpn --dev tun0

Fri Dec 16 16:59:32 2016 OpenVPN 2.3.10 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Feb  2 2016
Fri Dec 16 16:59:32 2016 library versions: OpenSSL 1.0.2g  1 Mar 2016, LZO 2.08
Fri Dec 16 16:59:32 2016 WARNING: file '/etc/openvpn/piaauth.txt' is group or others accessible
Fri Dec 16 16:59:32 2016 UDPv4 link local (bound): [undef]
Fri Dec 16 16:59:32 2016 UDPv4 link remote: [AF_INET]108.61.122.121:1198
Fri Dec 16 16:59:32 2016 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Fri Dec 16 16:59:32 2016 [113b1963081eb5270c22e4405fb71051] Peer Connection Initiated with [AF_INET]108.61.122.121:1198
Fri Dec 16 16:59:34 2016 TUN/TAP device tun0 opened
Fri Dec 16 16:59:34 2016 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Fri Dec 16 16:59:34 2016 /sbin/ip link set dev tun0 up mtu 1500
Fri Dec 16 16:59:34 2016 /sbin/ip addr add dev tun0 local 10.43.10.6 peer 10.43.10.5
Fri Dec 16 16:59:34 2016 Initialization Sequence Completed

在此之后一切正常。但是当我运行下一个 ovpn 实例时,我得到了一些错误。

多伦多

client
dev tun
proto udp
remote ca-toronto.privateinternetaccess.com
resolv-retry infinite
persist-key
persist-tun
cipher aes-128-cbc
auth sha1
tls-client
remote-cert-tls server
auth-user-pass /etc/openvpn/piaauth.txt
comp-lzo
verb 1
reneg-sec 0
crl-verify /etc/openvpn/crl.rsa.2048.pem
ca /etc/openvpn/ca.rsa.2048.crt
disable-occ
lport 1192
rport 1198

|

sudo /usr/sbin/openvpn --config /etc/openvpn/Toronto.ovpn --dev tun1

Fri Dec 16 16:59:57 2016 OpenVPN 2.3.10 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Feb  2 2016
Fri Dec 16 16:59:57 2016 library versions: OpenSSL 1.0.2g  1 Mar 2016, LZO 2.08
Fri Dec 16 16:59:57 2016 WARNING: file '/etc/openvpn/piaauth.txt' is group or others accessible
Fri Dec 16 16:59:57 2016 UDPv4 link local (bound): [undef]
Fri Dec 16 16:59:57 2016 UDPv4 link remote: [AF_INET]172.98.67.16:1198
Fri Dec 16 16:59:57 2016 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this
Fri Dec 16 16:59:58 2016 [484ec5eff7d70137ae07ee3ec5e62b80] Peer Connection Initiated with [AF_INET]172.98.67.16:1198
Fri Dec 16 17:00:00 2016 TUN/TAP device tun1 opened
Fri Dec 16 17:00:00 2016 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Fri Dec 16 17:00:00 2016 /sbin/ip link set dev tun1 up mtu 1500
Fri Dec 16 17:00:00 2016 /sbin/ip addr add dev tun1 local 10.84.10.6 peer 10.84.10.5
RTNETLINK answers: File exists
Fri Dec 16 17:00:00 2016 ERROR: Linux route add command failed: external program exited with error status: 2
RTNETLINK answers: File exists
Fri Dec 16 17:00:00 2016 ERROR: Linux route add command failed: external program exited with error status: 2
Fri Dec 16 17:00:00 2016 Initialization Sequence Completed

这里ip link和ip addr都失败了。

这是我的路由表

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.43.10.5      128.0.0.0       UG    0      0        0 tun0
default         192.168.1.1     0.0.0.0         UG    0      0        0 enp3s0
10.43.10.1      10.43.10.5      255.255.255.255 UGH   0      0        0 tun0
10.43.10.5      *               255.255.255.255 UH    0      0        0 tun0
10.84.10.1      10.84.10.5      255.255.255.255 UGH   0      0        0 tun1
10.84.10.5      *               255.255.255.255 UH    0      0        0 tun1
108.61.122.121. 192.168.1.1     255.255.255.255 UGH   0      0        0 enp3s0
128.0.0.0       10.43.10.5      128.0.0.0       UG    0      0        0 tun0
link-local      *               255.255.0.0     U     1000   0        0 enp3s0
172.98.67.16    192.168.1.1     255.255.255.255 UGH   0      0        0 enp3s0
192.168.1.0     *               255.255.255.0   U     0      0        0 enp3s0

这是我的 ifconfig

enp3s0    Link encap:Ethernet  HWaddr 
          inet addr:192.168.1.128  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::beae:c5ff:fe5a:7ec/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1146017 errors:0 dropped:0 overruns:0 frame:0
          TX packets:727717 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:1500194552 (1.5 GB)  TX bytes:117446235 (117.4 MB)
          Interrupt:40 

tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.43.10.6  P-t-P:10.43.10.5  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:2143 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1715 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:2312566 (2.3 MB)  TX bytes:170653 (170.6 KB)

tun1      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
          inet addr:10.84.10.6  P-t-P:10.84.10.5  Mask:255.255.255.255
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

我想我只需要配置一些路由,对吗?

vpn openvpn tunneling route
  • 1 1 个回答
  • 549 Views

1 个回答

  • Voted
  1. Best Answer
    rda
    2016-12-19T01:33:57+08:002016-12-19T01:33:57+08:00

    第一个 VPN 实例添加 2 条由服务器推送的路由,使用push "redirect-gateway def1. 选项def10.0.0.0/1使用and覆盖默认网关128.0.0.0/1。

    第二个 VPN 实例尝试相同,但未能添加这 2 条路由,因为它们已经存在。只允许 1 个默认路由。

    您至少有 2 个选项:

    1. route-noexec向 VPN 实例 2 的客户端配置添加指令

    --route-noexec

    不要自动添加或删除路由。而是使用环境变量将路由传递给 --route-up 脚本。

    现在路线将被拉出,但不会添加到您的系统中。您可以使用脚本进行自己的路由。例子:

    route-up add-routes.sh
    
    1. 或者将指令添加route-noexec到两个 VPN 实例的客户端配置中

    添加路由脚本并设置基于策略的路由。

    • 1

相关问题

  • 无法通过 Ubuntu VPN 访问外部网络

  • 用 D-LINK DFL-CPG310 防火墙替换 Cisco Pix 防火墙

  • 最好的点对点 VPN?

  • WAN 上的 VLAN

  • 通过 VPN 连接什么是远程服务器 IP?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve