我正在尝试以桥接模式设置 openvpn。我之前在 openbsd 路由器上做过这个。现在我有一台运行 openbsd 的内部机器。客户端是一台 Windows 7 笔记本电脑。
设置如下。
我家里的本地局域网是 10.0.10.0 255.255.255.0,网关是 10.0.10.1 VPN 服务器是 10.0.10.15
我正在将端口 9999 udp 公共转发至 10.0.10.15。
在服务器上:/etc/hostname.tun0
link0 up
/etc/桥名称.bridge0
add pcn0
add tun0
up
/etc/openvpn.conf
dev-type tap
dev tun0
comp-lzo
keepalive 10 60
ping-timer-rem
persist-tun
persist-key
user nobody
group nobody
daemon openvpn
chroot /var/empty
port 9999
proto udp
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
dh /etc/openvpn/keys/dh1024.pem
management 127.0.0.1 9998 /etc/openvpn/mgmt.pwd
server-bridge 10.0.10.1 255.255.255.0 10.0.10.240 10.0.10.244
push "route 10.0.10.0 255.255.255.0"
ifconfig-pool-persist ipp.txt
client-to-client
tls-auth /etc/openvpn/keys/ta.key 0
cipher AES-256-CBC
max-clients 5
status openvpn-status.log
log-append openvpn.log
verb 4
mute 20
在客户端上:openvpn.conf:
client
remote xxx.xxx.xxx.xxx 9999 #my ip is really here
proto udp
dev tap
dev-node VPN
nobind
comp-lzo
link-mtu 1590
persist-key
persist-tun
keepalive 10 120
management 127.0.0.1 9090 "mgmt.pwd"
ns-cert-type server
ca "ca.crt"
cert "tim-work-laptop.crt"
key "tim-work-laptop.key"
tls-client
tls-auth "ta.key" 1
cipher AES-256-CBC
pull
verb 2
当我在服务器上运行 ifconfig -a 时:
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33204
priority: 0
groups: lo
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
pcn0: flags=8b43<UP,BROADCAST,RUNNING,PROMISC,ALLMULTI,SIMPLEX,MULTICAST> mtu 1500
lladdr 08:00:27:04:df:8c
priority: 0
groups: egress
media: Ethernet none
status: active
inet6 fe80::a00:27ff:fe04:df8c%pcn0 prefixlen 64 scopeid 0x1
inet 10.0.10.15 netmask 0xffffff00 broadcast 10.0.10.255
enc0: flags=0<> mtu 1536
priority: 0
tun0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> mtu 1500
priority: 0
groups: tun
bridge0: flags=0<> mtu 1500
priority: 0
groups: bridge
pflog0: flags=141<UP,RUNNING,PROMISC> mtu 33204
priority: 0
groups: pflog
由于它是一个内部盒子,所以我的防火墙配置是打开的:
int_if="pcn0"
vpn_if="tun0"
br_if="bridge0"
vpn="9999"
ntp="123"
dns="53"
#set require-order no
set skip on lo
scrub in
pass in proto udp from any to any port $ntp
pass in proto {tcp,udp} from any to any port $dns
pass in # to establish keep-state
#vpn/bridge info
pass in quick on $int_if proto udp from any to $int_if port $vpn
pass in quick on {$vpn_if,$br_if} proto {tcp,udp,icmp} from any to any
pass out quick on {$vpn_if,$br_if} proto {tcp,udp,icmp} from any to any
Windows 客户端连接后,如预期一样给了我一个 10.0.10.240 的 IP,并且 openvpn gui 图标是绿色的。但是,我无法 ping 通家里本地局域网上的任何东西,包括 10.0.10.15。
有任何想法吗?
我正在使用以下指南: http://blog.innerewut.de/2005/07/04/openvpn-2-0-on-openbsd http://openvpn.net/index.php/open-source/documentation/howto.html http://www.kernel-panic.it/openbsd/vpn/vpn4.html
答案1
真是愚蠢的事情……
hostname.tun0 和 bridgename.bridge0 文件末尾需要有一个回车符。