在 Ubuntu VPS @ linode 上设置 VPN

kit*_*une 2 ubuntu vpn vps openvpn linode

我真的很挣扎,因为我不是网络管理员,只是一个凡人的程序员。

Linode 为您提供外部和内部 IP,以便与 linode 网络上的其他节点一起使用。在我的情况下,我已经像这样配置了我的外部接口:

# The loopback interface
auto lo
iface lo inet loopback

# Configuration for eth0 and aliases

# This line ensures that the interface will be brought up during boot.
auto eth0 eth0:0 eth0:1

# eth0 - This is the main IP address that will be used for most outbound connec$
# The address, netmask and gateway are all necessary.
iface eth0 inet static
 address 97.107.XXX.XX
 netmask 255.255.255.0
 gateway 97.107.XXX.1


# eth0:1 - Private IPs have no gateway (they are not publicly routable) so all $
# specify is the address and netmask.
iface eth0:1 inet static
 address 192.168.140.135
 netmask 255.255.128.0
Run Code Online (Sandbox Code Playgroud)

在 eth0:1 之前缺少的是我想用于我的 VPN 的接口 eth0:0。我必须这样做吗?好吧,我将此添加到 eth0 和 eth0:1 之间的接口文件中

iface eth0:0 inet static
 address 10.10.10.1
 netmask 255.0.0.0
Run Code Online (Sandbox Code Playgroud)

所以我开始安装 openvpn 并生成密钥。据我判断,这奏效了。我的 openvpn 服务器配置有问题。我希望能够在家中或在旅途中访问我的 VPS 文件,并且可能通过它访问互联网(也许在稍后阶段,我不知道,我主要对访问我的 VPS 和它的文件)

其中,我的server.conf 中有以下内容

dev tap1
server-bridge 10.10.10.1 255.0.0.0 10.10.10.50 10.10.10.100
Run Code Online (Sandbox Code Playgroud)

这样对吗?或者我必须在那里使用其他东西。

我为桥梁添加了一些 iptables mumbo jumbo。

iptables -A INPUT -i tap0 -j ACCEPT
iptables -A INPUT -i br0 -j ACCEPT
iptables -A FORWARD -i br0 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)

它在这里说tap0,即使其他地方都是tap1。我从指南 ( http://www.linode.com/wiki/index.php/OpenVPN ) 中获得这些数字。我不知道这是否正确。

然后我创建了一个桥接启动脚本:

 #!/bin/bash
 #################################
 # Set up Ethernet bridge on Linux
 # Requires: bridge-utils
 #################################
 # Define Bridge Interface
 br="br0"
 # Define list of TAP interfaces to be bridged,
 # for example tap="tap0 tap1 tap2".
 tap="tap1"
 # Define physical ethernet interface to be bridged
 # with TAP interface(s) above.
 eth="eth0:0"
 eth_ip="10.10.10.1"
 eth_netmask="255.0.0.0"
 eth_broadcast="10.10.10.255"
 for t in $tap; do
   openvpn --mktun --dev $t
 done
Run Code Online (Sandbox Code Playgroud)

同样,我不知道我在这里实际上在做什么...因为我决定使用 10.10.10.1,所以我猜默认的网络掩码应该是 255.0.0.0。我还添加了一个类似的桥接脚本。无论如何,如果我想开始我的桥接启动脚本,我会得到:

kitsune@makemake:/etc/openvpn/# /etc/openvpn/bridge-start
Thu Jun 25 21:08:36 2009 TUN/TAP device tap1 opened
Thu Jun 25 21:08:36 2009 Persist state set to: ON
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
Run Code Online (Sandbox Code Playgroud)

当我尝试启动 openvpn 时,它失败了。

任何人都可以理解这一点吗?