![无法在 Debian 8 上通过 OpenVPN 路由流量](https://linux22.com/image/662810/%E6%97%A0%E6%B3%95%E5%9C%A8%20Debian%208%20%E4%B8%8A%E9%80%9A%E8%BF%87%20OpenVPN%20%E8%B7%AF%E7%94%B1%E6%B5%81%E9%87%8F.png)
我一直在尝试设置 OpenVPN,但遇到了一些小问题,我似乎无法通过服务器路由所有流量。我可以正常连接到服务器,但连接后似乎无法 ping 服务器,也无法通过服务器推送来自客户端的任何流量。
服务器配置文件
local 94.23.xxx.xxx
port 1194
proto udp
dev tun
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "route 10.8.0.0 255.255.255.0"
;push "redirect-gateway def1 bypass-dhcp"
;push "redirect-gateway def1"
push "dhcp-option DNS 208.67.220.222"
push "dhcp-option DNS 208.67.220.220"
当我取消注释;推“redirect-gateway def1bypass-dhcp”或;推“redirect-gateway def1”时,我与服务器失去了连接,不得不将它们注释掉。
我认为我配置 iptables 的方式可能有问题
iptables -L -v -n --line-numbers
Chain INPUT (policy ACCEPT 147K packets, 12M bytes)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT all -- tun0 * 0.0.0.0/0 0.0.0.0/0
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
num pkts bytes target prot opt in out source destination
1 0 0 ACCEPT all -- tun0 * 0.0.0.0/0 0.0.0.0/0
2 0 0 ACCEPT all -- tun0 eth0 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
3 0 0 ACCEPT all -- eth0 tun0 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED
4 0 0 ACCEPT all -- * eth0 10.8.0.0/24 0.0.0.0/0
Chain OUTPUT (policy ACCEPT 260K packets, 606M bytes)
num pkts bytes target prot opt in out source destination
netstat -rn
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 94.23.xxx.xxx 0.0.0.0 UG 0 0 0 eth0
10.8.0.0 10.8.0.2 255.255.255.0 UG 0 0 0 tun0
10.8.0.1 10.8.0.5 255.255.255.255 UGH 0 0 0 tun1
10.8.0.2 0.0.0.0 255.255.255.255 UH 0 0 0 tun0
10.8.0.5 0.0.0.0 255.255.255.255 UH 0 0 0 tun1
94.23.xxx.xxx 0.0.0.0 255.255.255.0 U 0 0 0 eth0
如果需要的话我会很乐意提供更多细节,干杯!
答案1
看来我忘了将 client.conf 从 /etc/openvpn/ 目录中移出,所以当我取消注释这些行时,它只是在服务器内循环了服务器的所有流量!哎呀!