在 Ubuntu VPS 上设置 VPN @ linode

在 Ubuntu VPS 上设置 VPN @ 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

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

iface eth0:0 inet static
 address 10.10.10.1
 netmask 255.0.0.0

因此,我开始安装 openvpn 并生成密钥。据我判断,这很有效。我在 openvpn 服务器配置方面遇到了问题。我希望能够在家中或旅途中访问我的 VPS 文件,并可能通过它访问互联网(也许在以后,我不知道,我主要对访问我的 VPS 及其文件感兴趣)

除其他外,我的服务器配置文件

dev tap1
server-bridge 10.10.10.1 255.0.0.0 10.10.10.50 10.10.10.100

这是正确的吗?还是我必须使用其他东西。

我为桥梁添加了一些 iptables 内容。

iptables -A INPUT -i tap0 -j ACCEPT
iptables -A INPUT -i br0 -j ACCEPT
iptables -A FORWARD -i br0 -j ACCEPT

这里显示的是 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

再说一遍,我不知道我在这里到底在做什么……由于我决定使用 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

当我尝试启动 openvpn 时失败。

有人能理解这一点吗?

答案1

那篇 wiki 文章完全是胡说八道。除非你真的,否则不要使用 OpenVPN 桥接,真的知道为什么要使用它。它让一切变得困难 100 倍。我会从官方开始OpenVPN 操作指南然后从那里出发。

相关内容