DD-WRT OpenVPN - 无法访问局域网或互联网


0

我的vpn服务器设置有问题。 2天之后,我在dd-wrt上放弃了gui,并为bridget连接做了一个配置,但是没有在iPhone上(他们不支持它)。所以我决定改用TUN。 Sever正在运行,我可以连接,但有两个问题 -

  1. 无法访问局域网
  2. 无法访问Internet /除非我从服务器中删除dhcp-option

我的局域网是192.168.1.0/24,VPN网络是192.168.2.0/24 这是我的服务器设置

push "route 192.168.1.0 255.255.255.0"
push "dhcp-option DNS 192.168.1.1" 
server 192.168.2.0 255.255.255.0
push "redirect-gateway def1" 

mode server
proto udp4
port 1194 
dev tun0 
cipher AES-256-CBC
tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA256
auth SHA256
comp-lzo yes
script-security 2
keepalive 10 120 
daemon 
verb 5 

dh /tmp/openvpn/dh.pem 
ca /tmp/openvpn/ca.crt 
cert /tmp/openvpn/cert.pem 
key /tmp/openvpn/key.pem

防火墙脚本

iptables -I INPUT -p udp --dport 1194 -j ACCEPT
iptables -I FORWARD 1 --source 192.168.2.0/24 -j ACCEPT
iptables -I FORWARD -i br0 -o tun0 -j ACCEPT
iptables -I FORWARD -i tun0 -o br0 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE

和客户端设置

remote router-ip 1194

client 
dev tun0
proto udp 
resolv-retry infinite 
nobind 
persist-key 
persist-tun 
float
cipher AES-256-CBC
auth SHA256
tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA256
comp-lzo yes
verb 5

ca ca.crt 
cert client1.crt 
key client1.key 

remote-cert-tls server

路线表

default via XX.XXX.XXX.XXX dev vlan2
XXX.XXX.XXX.XXX/26 dev vlan2  proto kernel  scope link  src XXX.XXX.XXX.XXX
127.0.0.0/8 dev lo  scope link
169.254.0.0/16 dev br0  proto kernel  scope link  src 169.254.255.1
192.168.1.0/24 dev br0  proto kernel  scope link  src 192.168.1.1
192.168.2.0/24 via 192.168.2.2 dev tun0
192.168.2.2 dev tun0  proto kernel  scope link  src 192.168.2.1

我的手机掉线访问局域网

Sep 16 14:46:03 DD-WRT kern.warn kernel: DROP IN=tun0 OUT= MAC= SRC=192.168.2.6 DST=192.168.1.1 LEN=60 TOS=0x00 PREC=0x00 TTL=255 ID=9878 PROTO=UDP SPT=64708 DPT=53 LEN=40
Sep 16 14:46:03 DD-WRT kern.warn kernel: DROP IN=tun0 OUT= MAC= SRC=192.168.2.6 DST=192.168.1.1 LEN=76 TOS=0x00 PREC=0x00 TTL=255 ID=35922 PROTO=UDP SPT=49210 DPT=53 LEN=56
Sep 16 14:46:05 DD-WRT kern.warn kernel: DROP IN=tun0 OUT= MAC= SRC=192.168.2.6 DST=192.168.1.1 LEN=76 TOS=0x00 PREC=0x00 TTL=255 ID=1652 PROTO=UDP SPT=49210 DPT=53 LEN=56

任何想法都可能是这里的问题? :/我的猜测是2.0大炮与1.0网络对话,但我不知道如何编辑iptables使其工作:/。

Answers:


0

所以2天后,我找到了一个有效的解决方案:D

VPN服务器配置

push "route 192.168.1.0 255.255.255.0"
push "dhcp-option DNS 5.135.183.146" 
push "dhcp-option DNS 151.80.147.153" 
server 192.168.2.0 255.255.255.0
push "redirect-gateway def1" 

management localhost 5001
mode server
proto udp4
port 1194 
dev tun0 
cipher AES-256-CBC
tls-cipher TLS-DHE-RSA-WITH-AES-256-CBC-SHA256
auth SHA256
comp-lzo yes
script-security 2
keepalive 10 120 
daemon 
verb 5 

dh /tmp/openvpn/dh.pem 
ca /tmp/openvpn/ca.crt 
cert /tmp/openvpn/cert.pem 
key /tmp/openvpn/key.pem 

防火墙脚本

iptables -I INPUT 1 -p udp --dport 1194 -j ACCEPT
iptables -I INPUT 2 -i tun0 -j ACCEPT
iptables -I FORWARD -i br0 -o tun0 -j ACCEPT
iptables -I FORWARD -i tun0 -o br0 -j ACCEPT 
iptables -I FORWARD 1 --source 192.168.2.0/24 -j ACCEPT
iptables -t nat -A POSTROUTING -s 192.168.2.0/24 -j MASQUERADE
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.