我正在尝试在 Raspberry Pi 上设置 VPN 服务器,但收到错误[FAIL] Starting virtual private network daemon: server failed!
我遵循了几个不同的教程,但没有一个能使服务正常运行。我肯定我在某个地方误解了说明,但有人能帮我让它运行吗?
Pi 运行的是 Raspbian。它有一个静态 IP 192.168.1.230。路由器是 192.168.1.254。
我的 /etc/openvpn/server.conf 文件内容如下:
dev tun
proto udp
port 1194
ca /etc/openvpn/easy-rsa/keys/ca.crt
cert /etc/openvpn/easy-rsa/keys/server.crt
key /etc/openvpn/easy-rsa/keys/server.key
dh /etc/openvpn/easy-rsa/keys/dh2048.pem
user nobody
group nogroup
server 10.8.0.0 255.255.255.0
persist-key
persist-tun
status /var/log/openvpn-status.log
verb 3
client-to-client
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
log-append /var/log/openvpn
comp-lzo
ifconfig -a 显示:
eth0 Link encap:Ethernet HWaddr b8:27:eb:78:40:2b
inet addr:192.168.1.230 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:18862 errors:0 dropped:35 overruns:0 frame:0
TX packets:16015 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1130316 (1.0 MiB) TX bytes:1997172 (1.9 MiB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 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:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:10.8.0.1 P-t-P:10.8.0.2 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)
/var/log/openvpn 包含:
Fri Jul 4 18:32:39 2014 OpenVPN 2.2.1 arm-linux-gnueabihf [SSL] [LZO2] [EPOLL] [PKCS11] [eurephia] [MH] [PF_INET6] [IPv6 payload 20110424-2 (2.2RC2)] built on Oct 12 2013
Fri Jul 4 18:32:39 2014 WARNING: --keepalive option is missing from server config
Fri Jul 4 18:32:39 2014 NOTE: your local LAN uses the extremely common subnet address 192.168.0.x or 192.168.1.x. Be aware that this might create routing conflicts if you connect to the VPN server from $
Fri Jul 4 18:32:39 2014 NOTE: OpenVPN 2.1 requires '--script-security 2' or higher to call user-defined scripts or executables
Fri Jul 4 18:32:39 2014 Diffie-Hellman initialized with 2048 bit key
Fri Jul 4 18:32:39 2014 TLS-Auth MTU parms [ L:1542 D:138 EF:38 EB:0 ET:0 EL:0 ]
Fri Jul 4 18:32:39 2014 Socket Buffers: R=[163840->131072] S=[163840->131072]
Fri Jul 4 18:32:39 2014 ROUTE default_gateway=192.168.1.254
Fri Jul 4 18:32:39 2014 TUN/TAP device tun0 opened
Fri Jul 4 18:32:39 2014 TUN/TAP TX queue length set to 100
Fri Jul 4 18:32:39 2014 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0
Fri Jul 4 18:32:39 2014 /sbin/ifconfig tun0 10.8.0.1 pointopoint 10.8.0.2 mtu 1500
Fri Jul 4 18:32:39 2014 /sbin/route add -net 10.8.0.0 netmask 255.255.255.0 gw 10.8.0.2
Fri Jul 4 18:32:39 2014 Data Channel MTU parms [ L:1542 D:1450 EF:42 EB:135 ET:0 EL:0 AF:3/1 ]
Fri Jul 4 18:32:39 2014 GID set to nogroup
Fri Jul 4 18:32:39 2014 UID set to nobody
Fri Jul 4 18:32:39 2014 UDPv4 link local (bound): [undef]
Fri Jul 4 18:32:39 2014 UDPv4 link remote: [undef]
Fri Jul 4 18:32:39 2014 MULTI: multi_init called, r=256 v=256
Fri Jul 4 18:32:39 2014 IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0
Fri Jul 4 18:32:39 2014 Initialization Sequence Completed
2014 年 7 月 13 日更新
命令ps aux | grep openvpn
显示:
nobody 2269 0.0 0.2 5072 1192 ? Ss Jul04 0:17 /usr/sbin/openvpn --writepid /var/run/openvpn.openvpn.pid --daemon ovpn-openvpn --cd /etc/openvpn --config /etc/openvpn/openvpn.conf
root 5140 0.0 0.1 3548 800 pts/0 S+ 08:54 0:00 grep openvpn
该命令netstat -l | grep 1194
没有输出。
答案1
日志输出和 tun 设备出现的事实ifconfig
表明 openvpn 守护进程确实正在运行。运行以下命令,您可以在进程列表中看到它:
ps aux | grep openvpn
服务启动命令,您是否以 sudo/root 身份运行?如果不是,它可能正在尝试调整路由表或控制 tun 设备,并且它没有足够的权限。
另外,请确保:
netstat -l | grep 1194
显示守护进程正在监听 UDP 端口 1194
日志输出显示 openvpn 守护进程已经能够创建 tun 设备(并且它显示在 ifconfig 的输出中),因此如果守护进程实际上没有运行,我会感到非常惊讶。如果是这种情况,并且您没有对服务控制执行 sudo 操作,则 init 脚本可能存在问题。