[分享]用兩台ASUS RT-N16(Tomato)建置兩地同網段的VPN

謝謝您的指導~
Tomato OpenVPN Server與WinXP Client大致都摸了一個程度.
TAP與TUN兩種連線也都很順利,一次連線就成.

看前面討論,覺得Win7 Client似乎問題蠻多的.
原本想說可否請您再說明Win7的相關設定,想想還是先自葛動手,有問題再請教.

在安裝Win7 OpenVPN時突然靈光一閃,想到WinXP時做的OpenVPN認證是否可沿用..
賓果!當真可以,TAP與TUN都可行!!

不過原本我希望設定TAP時是只需同步芳鄰,不需翻牆.
remote 220.134.45.195
port 1194
#dev tap or tun
dev tap
secret key.txt
proto udp
comp-lzo
#ifconfig 10.8.0.2 10.8.0.1
#redirect-gateway

WinXP是回應了我的需求;
但Win7同樣的設定不但共用了芳鄰,卻也翻了牆了(明明redirect-gateway已經屏避了說)

TUN則沒什麼問題,
我把創建的Client1認證給了WinXP ;Client2給Win7.
兩台不同作業系統的電腦都順利翻了牆,不過芳鄰卻是無法共有的(雖然早知會如此的結果).
gfx wrote:
不過原本我希望設定TAP時是只需同步芳鄰,不需翻牆.

WinXP是回應了我的需求;
但Win7同樣的設定不但共用了芳鄰,卻也翻了牆了(明明redirect-gateway已經屏避了說)..(恕刪)


在Windows下VPN連線建立後會不會 Redirect Internet traffic,和 Route Table 的內容有關係.
因為 'Default Gateway' 會決定要傳送到外網封包的閘道出口,
這點我在 第219樓第223樓 已有說明.

'TAP or TUN' 、 'dhcp-option DNS' 及 'redirect-gateway' 這些指令
都是要 OpenVPN 程式去擾動系統底層的 Route Table 來改變封包流向.

當然,在 Windows 下要改變 Route Table,除了上述的方法外,您也可以去cmd模式下指令.
有興趣可以去 Goolge 一下 'Route Add' 和 'Route Delete' 指令.
rontzong wrote:
在Windows下V...(恕刪)

Sorry,rontzong大!
因為我不是網管學生,太深奧的內容我可能聽不太懂.
不過我可以將我電腦的表象說給您聽.

主要是Win7 Client端測試TAP連線,電腦用的是無線網卡,
SSID來源一個是P874(與RT-N16不同網段) ;另一個是CHT-WIFI(來源自超商,剛好家中還收得到)

先測試CHT-WIFI:
在瀏覽器網址列輸入http://myip.com.tw 顯示的是CHT-WIFI的IP ,
有達到我想要芳鄰但不翻牆的結果.

換P874的WIFI:
在瀏覽器網址列輸入http://myip.com.tw 顯示的卻是RT-N16的IP ..有芳鄰,但也翻牆囉!

我想問同一台Win7電腦,同一個無線網卡,同一個Client設定,只是WIFI來源不同..
OpenVPN TAP的結果卻不一樣? 怎回事??

gfx wrote:
換P874的WIFI:

在瀏覽器網址列輸入http://myip.com.tw 顯示的卻是RT-N16的IP ..有芳鄰,但也翻牆囉!

我想問同一台Win7電腦,同一個無線網卡,同一個Client設定,只是WIFI來源不同..
OpenVPN TAP的結果卻不一樣? 怎回事??


以您貼的結果來看,我會猜測是 您的P874不但開啟了 Wifi 功能,也開啟了 NAT 功能.

我想問2個問題:
1.電腦用 Wifi 連上 P874 後,還需要做 PPPoE 嗎?
2.RT-N16 WAN 端接上 P874 是用 PPPoE 連線,還是用 DHCP 連線?

我怎麼看,都覺得是 N16 的 WAN 端是 Private IP,而且是由 P874 配發的.
rontzong wrote:
我想問2個問題:
1.電腦用 Wifi 連上 P874 後,還需要做 PPPoE 嗎?
2.RT-N16 WAN 端接上 P874 是用 PPPoE 連線,還是用 DHCP 連線?

1.不需要
2.RT-N16與P874全都有PPPoE連線,互PING GATEWAY是PING不通的.
(因為要測試VPN連線,不然平常是不會開P874 PPPoE連線使用)
gfx wrote:
1.不需要2.RT-...(恕刪)


小弟反復看了您 第233、235樓的狀況描述,覺得這應該是不太可能.
推判可能是您電腦 Route Table 的部份網段被指定導向了.

嘗試解析 Domain: myip.com.tw 得到它的 IP=122.147.183.5
您可用 C:\Windows\System32>route print 查看一下:
122.0.0.0 這個網段,它的 Default Gateway 是不是指向 N16.
也用別的查IP網站測試看看,情況一樣嗎?
rontzong wrote:
小弟反復看了您 第2...(恕刪)

我分別把Win7下RT-N16 ,P874 ,CHT-WIFI 的路由表Print下來,
麻煩請您幫我檢視好嗎? 謝謝~

其中RT-N16為對照組,
希望能釐清CHT-WIFI OpenVPN(TAP)可以選用網路芳鄰,但P874卻是芳鄰+翻牆 的差別..

gfx wrote:
我分別把Win7下RT-N16 ,P874 ,CHT-WIFI 的路由表Print下來,...(恕刪)


小弟在 第61樓 有提到:
當Interface Type=TAP時,電腦中的 Physical Ethernet Adapter 和 Virtual Ethernet Adapter 各自存在IP Address、Subnet Mask及Default Gateway.

第223樓 中也提到:
當一個LAN裡存在2個以上的Gateway時,可以透過改變 'Default Gateway' 或 'Route Table'
去指定要傳送到外網封包的閘道出口.

看您前面貼了三張圖(小弟簡略摘要如下):

情況1:電腦以無線網卡連結RT-N16(192.168.1.1)
IP是:192.168.1.106
子罩:255.255.255.0
閘道:192.168.1.1
路由:0.0.0.0/0.0.0.0/192.168.1.1

情況2:電腦以無線網卡連結CHT-Wifi(118.168.51.254)
IP是:118.168.50.60
子罩:255.255.254.0
閘道:118.168.51.254
路由:0.0.0.0/0.0.0.0/118.168.51.254

情況3:電腦以無線網卡連結CHT-Wifi(118.168.51.254)建立OpenVPN(TAP)連線.
Physical Ethernet Adapter(Wifi)
IP是:118.168.50.60
子罩:255.255.254.0
閘道:118.168.51.254
Virtual Ethernet Adapter(OpenVPN)
IP是:192.168.1.112
子罩:255.255.255.0
閘道:192.168.1.1
第1路由:0.0.0.0/0.0.0.0/192.168.1.1
第2路由:0.0.0.0/0.0.0.0/118.168.51.254

情況4:電腦以無線網卡連結P874(192.168.2.1)
IP是:192.168.2.106
子罩:255.255.255.0
閘道:192.168.2.1
路由:0.0.0.0/0.0.0.0/192.168.2.1

情況5:電腦以無線網卡連結P874(192.168.2.1)建立OpenVPN(TAP)連線.
Physical Ethernet Adapter(Wifi)
IP是:192.106.2.106
子罩:255.255.255.0
閘道:192.106.2.1
Virtual Ethernet Adapter(OpenVPN)
IP是:192.168.1.112
子罩:255.255.255.0
閘道:192.168.1.1
第1路由:0.0.0.0/0.0.0.0/192.168.1.1
第2路由:0.0.0.0/0.0.0.0/192.168.2.1

您實作的結果,和小弟的結論一樣,但令小弟不解的是:「不管是連接CHT-Wifi或是P874,當OpenVPN(TAP)建立連線後,連Internet的封包都應該要走第2路由(Physical Ethernet Adapter)才對,為什麼後者會去走第1路由(Virtual Ethernet Adapter)?」

問題的成因,小弟暫時還不敢下定論,但目前查覺到兩者的差異是:
連接CHT-Wifi時,電腦是取得 Public IP.
連接P874時,電腦是取得 Private IP.

請問為什麼我的client.ovpn檔案內容是這樣
跟版主的內容差好多
我是有固定IP 用Static方式 要翻牆用 port:443
請問要如何改如下檔案


##############################################
# Sample client-side OpenVPN 2.0 config file #
# for connecting to multi-client server. #
# #
# This configuration can be used by multiple #
# clients, however each client should have #
# its own cert and key files. #
# #
# On Windows, you might want to rename this #
# file so it has a .ovpn extension #
##############################################

# Specify that we are a client and that we
# will be pulling certain config file directives
# from the server.
client

# Use the same setting as you are using on
# the server.
# On most systems, the VPN will not function
# unless you partially or fully disable
# the firewall for the TUN/TAP interface.
;dev tap
dev tun

# Windows needs the TAP-Win32 adapter name
# from the Network Connections panel
# if you have more than one. On XP SP2,
# you may need to disable the firewall
# for the TAP adapter.
;dev-node MyTap

# Are we connecting to a TCP or
# UDP server? Use the same setting as
# on the server.
;proto tcp
proto udp

# The hostname/IP and port of the server.
# You can have multiple remote entries
# to load balance between the servers.
remote my-server-1 1194
;remote my-server-2 1194

# Choose a random host from the remote
# list for load-balancing. Otherwise
# try hosts in the order specified.
;remote-random
remote-random

# Keep trying indefinitely to resolve the
# host name of the OpenVPN server. Very useful
# on machines which are not permanently connected
# to the internet such as laptops.
resolv-retry infinite

# Most clients don't need to bind to
# a specific local port number.
nobind

# Downgrade privileges after initialization (non-Windows only)
;user nobody
;group nobody

# Try to preserve some state across restarts.
persist-key
persist-tun

# If you are connecting through an
# HTTP proxy to reach the actual OpenVPN
# server, put the proxy server/IP and
# port number here. See the man page
# if your proxy server requires
# authentication.
;http-proxy-retry # retry on connection failures
;http-proxy [proxy server] [proxy port #]

# Wireless networks often produce a lot
# of duplicate packets. Set this flag
# to silence duplicate packet warnings.
;mute-replay-warnings

# SSL/TLS parms.
# See the server config file for more
# description. It's best to use
# a separate .crt/.key file pair
# for each client. A single ca
# file can be used for all clients.
ca ca.crt
cert client.crt
key client.key

# Verify server certificate by checking
# that the certicate has the nsCertType
# field set to "server". This is an
# important precaution to protect against
# a potential attack discussed here:
# http://openvpn.net/howto.html#mitm
#
# To use this feature, you will need to generate
# your server certificates with the nsCertType
# field set to "server". The build-key-server
# script in the easy-rsa folder will do this.
;ns-cert-type server

# If a tls-auth key is used on the server
# then every client must also have the key.
;tls-auth ta.key 1

# Select a cryptographic cipher.
# If the cipher option is used on the server
# then you must also specify it here.
;cipher x

# Enable compression on the VPN link.
# Don't enable this unless it is also
# enabled in the server config file.
comp-lzo

# Set log file verbosity.
verb 3

# Silence repeating messages
;mute 20
Doto wrote:
請問為什麼我的cli...(恕刪)

這些內容全部要刪除,輸入新的內容!
client.ovpn只輸入下面紅字內容就可以了.
(X.X.X.X是分享器IP,改成你自己的)

remote X.X.X.X
port 443
dev tap
secret key.txt
proto tcp
comp-lzo
ifconfig 10.8.0.2 10.8.0.1
redirect-gateway


若Port是用443,那協定通常用TCP居多! 注意Server端是否也設定成TCP.
關閉廣告
文章分享
評分
評分
複製連結
請輸入您要前往的頁數(1 ~ 41)

今日熱門文章 網友點擊推薦!