我在我的 RaspberryPi(Raspbian)上设置了一个 OpenVPN 服务器。启动成功,但是没有监听端口,所以无法连接。我在这里找不到问题?我做错了什么?
cat /etc/openvpn/vpn-server.conf
port 11094 proto udp dev tun ca ca.crt cert vpn-server.crt key vpn-server.key dh dh2048.pem server 10.8.0.0 255.255.255.0 ifconfig-pool-persist ipp.txt push "redirect-gateway def1 bypass-dhcp" push "dhcp-option DNS 208.67.222.222" push "dhcp-option DNS 208.67.220.220" keepalive 10 120 tls-auth ta.key 0 key-direction 0 cipher AES-128-CBC auth SHA256 comp-lzo user nobody group nogroup persist-key persist-tun status openvpn-status.log log /var/log/openvpn.log verb 6
sudo netstat -vaun
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State udp 0 0 0.0.0.0:11094 0.0.0.0:* udp 0 0 0.0.0.0:68 0.0.0.0:* udp 0 0 192.168.1.2:123 0.0.0.0:* udp 0 0 10.8.0.1:123 0.0.0.0:* udp 0 0 127.0.0.1:123 0.0.0.0:* udp 0 0 0.0.0.0:123 0.0.0.0:* udp 0 0 0.0.0.0:43721 0.0.0.0:* udp 0 0 0.0.0.0:5353 0.0.0.0:* udp6 0 0 :::44058 :::* udp6 0 0 fe80::6d3d:f08e:c6b:123 :::* udp6 0 0 ::1:123 :::* udp6 0 0 :::123 :::* udp6 0 0 :::5353 :::*
nmap -sU 10.8.0.1 -p 11094
Starting Nmap 6.47 ( http://nmap.org ) at 2018-02-16 17:04 UTC Nmap scan report for 10.8.0.1 Host is up. PORT STATE SERVICE 11094/udp open|filtered unknown
cat /var/log/openvpn.log
Fri Feb 16 15:47:29 2018 OpenVPN 2.3.4 arm-unknown-linux-gnueabihf [SSL (OpenSSL)] [LZO] [EPOLL] [PKCS11] [MH] [IPv6] built on Jun 27 2017 Fri Feb 16 15:47:29 2018 library versions: OpenSSL 1.0.1t 3 May 2016, LZO 2.08 Fri Feb 16 15:47:29 2018 Diffie-Hellman initialized with 2048 bit key Fri Feb 16 15:47:29 2018 Control Channel Authentication: using 'ta.key' as a OpenVPN static key file Fri Feb 16 15:47:29 2018 Outgoing Control Channel Authentication: Using 256 bit message hash 'SHA256' for HMAC authentication Fri Feb 16 15:47:29 2018 Incoming Control Channel Authentication: Using 256 bit message hash 'SHA256' for HMAC authentication Fri Feb 16 15:47:29 2018 Socket Buffers: R=[163840->131072] S=[163840->131072] Fri Feb 16 15:47:29 2018 ROUTE: default_gateway=UNDEF Fri Feb 16 15:47:29 2018 TUN/TAP device tun0 opened Fri Feb 16 15:47:29 2018 TUN/TAP TX queue length set to 100 Fri Feb 16 15:47:29 2018 do_ifconfig, tt->ipv6=0, tt->did_ifconfig_ipv6_setup=0 Fri Feb 16 15:47:29 2018 /sbin/ip link set dev tun0 up mtu 1500 Fri Feb 16 15:47:29 2018 /sbin/ip addr add dev tun0 local 10.8.0.1 peer 10.8.0.2 Fri Feb 16 15:47:29 2018 /sbin/ip route add 10.8.0.0/24 via 10.8.0.2 Fri Feb 16 15:47:29 2018 GID set to nogroup Fri Feb 16 15:47:29 2018 UID set to nobody Fri Feb 16 15:47:29 2018 UDPv4 link local (bound): [undef] Fri Feb 16 15:47:29 2018 UDPv4 link remote: [undef] Fri Feb 16 15:47:29 2018 MULTI: multi_init called, r=256 v=256 Fri Feb 16 15:47:29 2018 IFCONFIG POOL: base=10.8.0.4 size=62, ipv6=0 Fri Feb 16 15:47:29 2018 IFCONFIG POOL LIST Fri Feb 16 15:47:29 2018 Initialization Sequence Completed
sudo systemctl status openvpn@vpn-server
openvpn@vpn-server.service - OpenVPN connection to vpn-server Loaded: loaded (/lib/systemd/system/openvpn@.service; enabled) Active: active (running) since Fri 2018-02-16 15:47:29 UTC; 1h 10min ago Process: 499 ExecStart=/usr/sbin/openvpn --daemon ovpn-%i --status /run/openvpn/%i.status 10 --cd /etc/openvpn --config /etc/openvpn/%i.conf (code=exited, status=0/SUCCESS) Main PID: 547 (openvpn) CGroup: /system.slice/system-openvpn.slice/openvpn@vpn-server.service └─547 /usr/sbin/openvpn --daemon ovpn-vpn-server --status /run/openvpn/vpn-server.status 10 --cd /etc/openvpn --config /etc/openvpn/vpn-server.conf Feb 16 15:47:28 raspberrypi systemd[1]: Starting OpenVPN connection to vpn-server... Feb 16 15:47:29 raspberrypi systemd[1]: Started OpenVPN connection to vpn-server. Feb 16 16:06:40 raspberrypi systemd[1]: Started OpenVPN connection to vpn-server.
通常,您需要在两个 /24 网络之间使用路由器。
在您的 VPN 配置中,您将服务器地址配置为 10.8.0.0 255.255.255.0。那是网络,不是地址。
“2018 年 2 月 16 日星期五 15:47:29 路由:default_gateway=UNDEF”此外,您需要为第 3 层设备定义的默认网关能够在其子网之外进行通信。(这是将您连接到 192.168.1.0 /24 子网的路由器的地址)
尝试将您的 openvpn 服务器地址更改为您的本地子网。192.168.1.254 255.255.255.0
并将您的默认网关指向您已连接的路由器。
评论专区