OpenVPN服務無法啟動

OpenVPN服務無法啟動

我嘗試在 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,則初始化腳本可能會出現問題。

相關內容