歡迎您光臨本站 註冊首頁

測試情況如下:

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

測試情況如下:

總公司,分公司IP段都為192.168.10.0 網關都為:192.168.10.1
虛擬網段為10.8.0.0
VPN服務端為192.168.10.111  /10.8.0.1
客戶端     :192.168.10.45  /10.8.0.6



VPN連接后

客戶端PING的情況 : 192.168.10.111/10.8.0.1 通的   192.168.10.1 不通   www.gcjob.net 通     


服務端PING的情況: 10.8.0.6通   192.168.10.45不通  192.168.10.1通    www.gcjob.net 通


這是什麼情況造成的?

要看服務端跟客戶端的參數不?

接下來我貼配置參數:
《解決方案》

服務端如下:


port 1194


proto udp


dev tun



ca ca.crt   #OpenVPN使用的ROOT CA,使用build-ca生成的,用於驗證客戶是證書是否合法
cert server01.crt #Server使用的證書文件
key server01.key   #Server使用的證書對應的key,該文件必須嚴格控制其安全性


dh dh1024.pem


server 10.8.0.0 255.255.255.0


ifconfig-pool-persist ipp.txt



# 下面這句使客戶端能訪問伺服器後面的子網機器
# 比如:伺服器子網網段是192.168.10.0和192.168.10.2
# 你需要在openVPN伺服器端配置文件中添加下面這兩句

push "route 192.168.0.0 255.255.255.0"

push "route 192.168.1.0 255.255.255.0"




# 使伺服器子網內機器可以訪問客戶端子網內機器
# 僅用於路由模式
# 假設:客戶端子網網段192.168.40.0
# 首先,在伺服器配置文件中添加下面這兩行
#     client-config-dir ccd
#   和route 192.168.40.0   255.255.255.0
# 然後在伺服器端ccd目錄下創建一個文件,文件名是客戶端的公共名
# 文件內容是:
#     iroute 192.168.40.0   255.255.255.0
;client-config-dir ccd
;route 192.168.40.0   255.255.255.0


# EXAMPLE: Suppose you want to give
# Thelonious a fixed VPN IP address of 10.9.0.1.
# First uncomment out these lines:
;client-config-dir ccd
;route 10.9.0.0 255.255.255.252
# Then add this line to ccd/Thelonious:
#   ifconfig-push 10.9.0.1 10.9.0.2

# 支持對不同客戶端組執行不同的防火牆策略
# 這裡有兩種方法
# (1) 運行多個OpenVPN守護進程, 每個對應不同的組
#     並且防火牆對不同的組和進程執行不同的策略
# (2) (高級)創建1個動態腳本使防火牆對接入的不同客戶端執行不同的策略
;learn-address ./script


# 下面這句使客戶端所有網路通信通過vpn
# If enabled, this directive will configure
# all clients to redirect their default
# network gateway through the VPN, causing
# all IP traffic such as web browsing and
# and DNS lookups to go through the VPN
# (The OpenVPN server machine may need to NAT
# the TUN/TAP interface to the internet in
# order for this to work properly).
# CAVEAT: May break client's network config if
# client's local DHCP server packets get routed
# through the tunnel.   Solution: make sure
# client's local DHCP server is reachable via
# a more specific route than the default route
# of 0.0.0.0/0.0.0.0.
;push "redirect-gateway"

# 客戶端DHCP設置
# Certain Windows-specific network settings
# can be pushed to clients, such as DNS
# or WINS server addresses.   CAVEAT:
# http://openvpn.net/faq.html#dhcpcaveats
;push "dhcp-option DNS 10.8.0.1"
;push "dhcp-option WINS 10.8.0.1"

# 下面這句使客戶端能相互訪問
# 否則,默認設置下客戶端間不能相互訪問
client-to-client

# 這段常用於測試用途,註釋該條可實現限制一個證書在同一時刻只能有一個客戶端接入
# Uncomment this directive if multiple clients
# might connect with the same certificate/key
# files or common names.   This is recommended
# only for testing purposes.   For production use,
# each client should have its own certificate/key
# pair.
# IF YOU HAVE NOT GENERATED INDIVIDUAL
# CERTIFICATE/KEY PAIRS FOR EACH CLIENT,
# EACH HAVING ITS OWN UNIQUE "COMMON NAME",
# UNCOMMENT THIS LINE OUT.
;duplicate-cn

# 活動連接保時期限
# The keepalive directive causes ping-like
# messages to be sent back and forth over
# the link so that each side knows when
# the other side has gone down.
# Ping every 10 seconds, assume that remote
# peer is down if no ping received during
# a 120 second time period.
keepalive 10 120

# 為防止遭到DDoS攻擊
# 生成ta.key文件,並cp到伺服器端和每個客戶端
# 該文件用以下命令生成
# openvpn --genkey --secret ta.key
# 伺服器端0,客戶端1
# 該文件要嚴格保護
tls-auth ta.key 0 # 伺服器端是0


auth-user-pass-verify checkpsw.exe via-env
client-cert-not-required
username-as-common-name

# 選擇一種加密演算法,Server端和client端必須一樣
# Select a cryptographic cipher.
# This config item must be copied to
# the client config file as well.
;cipher BF-CBC         # Blowfish (default)
;cipher AES-128-CBC   # AES
;cipher DES-EDE3-CBC   # Triple-DES

# 允許數據壓縮
# 客戶端配置文件也需要有這項
comp-lzo

# 最大客戶端併發連接數量
;max-clients 100

#定義運行openvpn的用戶
user nobody
group nobody

#通過keepalive檢測超時后,重新啟動VPN,不重新讀取keys,保留第一次使用的keys
persist-key
#通過keepalive檢測超時后,重新啟動VPN,一直保持tun或者tap設備是linkup的,
#否則網路連接會先linkdown然後linkup
persist-tun

#定期把openvpn的一些狀態信息寫到文件中,以便自己寫程序計費或者進行其他操作
status status.log

#記錄日誌,每次重新啟動openvpn后刪除原有的log信息
;log         openvpn.log  
#或者
#記錄日誌,每次重新啟動openvpn后追加原有的log信息
;log-append   openvpn.log   #[為便於管理log可將該項改為/var/log/openvpn.log]

# 設置日誌記錄冗長級別
# Set the appropriate level of log
# file verbosity.
#
# 0 is silent, except for fatal errors
# 4 is reasonable for general usage
# 5 and 6 can help to debug connection problems
# 9 is extremely verbose
verb 3

# 重複日誌記錄限額
# Silence repeating messages.   At most 20
# sequential messages of the same message
# category will be output to the log.
mute 20
《解決方案》

client

dev tun

port 1194
proto udp


remote www.xx.com 1194
;remote my-server-2 1194


;remote-random


resolv-retry infinite


nobind


user nobody
group nobody


route 192.168.10.0 255.255.255.0

persist-key
persist-tun


ca ca.crt


auth-user-pass

ns-cert-type server


tls-auth ta.key 1

# 選擇一種加密演算法,必需和伺服器端一致
;cipher x

# 允許數據壓縮
# 這項和伺服器配置文件一樣
comp-lzo

# 設置日誌記錄冗長級別
verb 3

# 重複日誌記錄限額
mute 20
《解決方案》

把客戶端的這個參數去掉:route 192.168.10.0 255.255.255.0


后連接VPN

客戶端的區域網能PING通,但是不能PING通VPN服務端的真實的192。168。10。111的地址虛擬的10。8。0。1能PING通,!
《解決方案》

感覺你的問題比較多。
首先是在不連openvpn的情況下,也是兩主機也是可以互相訪問的。兩者到外網都是通的。
所以你無法知道兩者之間通信走的是openvpn呢還是你內網。最後tracert 看看。
其次是你server配置文件中的push,192.168.0.0/24和192.168.1.0/24這兩個網段是什麼?我想你加的應該是server內網的IP段,但根據你的描述,下面的兩IP地址段不是server段的內網段。
push "route 192.168.0.0 255.255.255.0"

push "route 192.168.1.0 255.255.255.0"
建議有兩點:一是把測試機分成不同的網段測試(意思是在原始態下,client與server的內網無法通信情況)
二是修改push里的IP,修改為你的server的內網IP段。另外你的ccd下文件的東西不知道有沒有問題!
《解決方案》

其次是你server配置文件中的push,192.168.0.0/24和192.168.1.0/24這兩個網段是什麼?

答:不是說要把客房端的IP寫入服務端的配置文件中嘛,不過在這兒沒有用過這個,因為,在這兒的客戶端為192.168.10.0我說的很清楚啊.

二是修改push里的IP,修改為你的server的內網IP段。
另外你的ccd下文件的東西不知道有沒有問題!

答:修改PUSH為SERVER的IP段,不過我還是不明白這句話的功能,或是起什麼作用的能說一下嗎?
CCD文件我根本沒有建.請問CCD是做什麼用的,起什麼作用,何建啊?
《解決方案》

我說的很清楚,一個在總公司,一個在分公司當然地理位置不一樣,暈,死了,你還沒有明白哦!
《解決方案》

回復 #7 QQ44439489 的帖子

分支機構,區域網IP段一樣很容易混淆……,建議修改成為不一樣的。

[火星人 ] 測試情況如下:已經有589次圍觀

http://coctec.com/docs/service/show-post-33242.html