連接到 OpenVPN 伺服器時無法存取互聯網

連接到 OpenVPN 伺服器時無法存取互聯網

我最近在我的 Windows 2003 伺服器上安裝了 OpenVPN。一旦有人連接到伺服器,他們就無法存取網路。

  • 我的網路位於 192.168.1.1
  • 我的伺服器位於 192.168.1.110
  • 我使用的是dd-wrt固件
  • 我已在路由器上為 192.168.1.110 啟用連接埠 1194
  • 路由和遠端存取已禁用
  • 我的 Windows 2003 伺服器上有 2 個 Tap-Win32 適配器 V8
  • 我嘗試將此行設定為 192.168.1.1 並且我的 ISP 的 dns 伺服器推送「dhcp-option DNS 192.168.1.1」 # 將 X 替換為您的家庭網路的 DNS 的 IP 位址(通常是您的 ISP 的 DNS)
  • 我在dd-wrt中創建了一個高級路由網關

     Destination LAN NET: 192.168.10.0
     Subnet Mask: 255.255.255.252
     Gateway: 192.168.1.110
     Interface: Lan & WLAN
    

我完全關注了這個網站: http://www.itsatechworld.com/2006/01/29/how-to-configure-openvpn/

編輯:我只是嘗試透過cmd提示符進行連接並收到以下子網路錯誤 - 本地 LAN [192.168.1.0/255.255.255.0] 和遠端 LAN [192.168.1.0/255.255.255.0] [192.168.1.0/255.255.255.0] 潛在的路由子網路衝突之間潛在的路由子網衝突

我的伺服器文件如下所示:

local 192.168.1.110 # This is the IP address of the real network interface on the server connected to the router

port 1194 # This is the port OpenVPN is running on - make sure the router is port forwarding this port to the above IP

proto udp # UDP tends to perform better than TCP for VPN

mssfix 1400 # This setting fixed problems I was having with apps like Remote Desktop

push "dhcp-option DNS 192.168.1.1"  # Replace the Xs with the IP address of the DNS for your home network (usually your ISP's DNS)

#push "dhcp-option DNS X.X.X.X"  # A second DNS server if you have one

dev tap

#dev-node MyTAP  #If you renamed your TAP interface or have more than one TAP interface then remove the # at the beginning and change "MyTAP" to its name

ca "ca.crt"  

cert "server.crt"

key "server.key"  # This file should be kept secret

dh "dh1024.pem"

server 192.168.10.0 255.255.255.128  # This assigns the virtual IP address and subent to the server's OpenVPN connection.  Make sure the Routing Table entry matches this.

ifconfig-pool-persist ipp.txt

push "redirect-gateway def1"  # This will force the clients to use the home network's internet connection

keepalive 10 120

cipher BF-CBC        # Blowfish (default) encryption

comp-lzo

max-clients 100 # Assign the maximum number of clients here

persist-key

persist-tun

status openvpn-status.log

verb 1 # This sets how detailed the log file will be.  0 causes problems and higher numbers can give you more detail for troubleshooting

我的client1檔案如下:

client

dev tap

#dev-node MyTAP  #If you renamed your TAP interface or have more than one TAP interface then remove the # at the beginning and change "MyTAP" to its name

proto udp

remote my-dyna-dns.com 1194  #You will need to enter you dyndns account or static IP address here. The number following it is the port you set in the server's config

route 192.168.1.0 255.255.255.0 vpn_gateway 3  #This it the IP address scheme and subnet of your normal network your server is on.  Your router would usually be 192.168.1.1

resolv-retry infinite

nobind

persist-key

persist-tun

ca "ca.crt"

cert "client1.crt" # Change the next two lines to match the files in the keys directory.  This should be be different for each client.

key "client1.key"  # This file should be kept secret

ns-cert-type server

cipher BF-CBC        # Blowfish (default) encrytion

comp-lzo

verb 1

先致謝!

答案1

在我看來,伺服器正在將「重定向網關」選項推送給客戶端。這會導致客戶端使用 VPN 作為其預設網關。註解掉伺服器設定中的行「push」redirect-gateway def1」。

哇哦——剛剛看到你的編輯。您的用戶端不能使用與其連接的 LAN 相同的 IP 位址。那是行不通的。一端或另一端需要使用不同的IP位址。

編輯:

假設您的 Windows Server 2003 電腦上的路由配置正確(根據您引用的 www.itsatechworld.com 頁面),您應該能夠透過 VPN 透過 LAN IP 對 Windows Server 2003 電腦和 Windows Vista 電腦進行 PING。如果可以,那麼您就可以在 Windows Server 2003 和 DD-WRT 電腦上進行路由,並且可以繼續。如果沒有,那麼您需要開始追蹤為什麼 (1) 來自 OpenVPN 隧道的 PING 流量無法到達目的地,或 (b) 為什麼來自目標主機的 PING 回覆沒有回傳。您最終可能會在 Windows Vista 電腦上安裝 Wireshark 之類的工具來查看 PING 請求是否已到達(因為 PING 無法告訴您是否已收到您的請求,而答复只是丟失了)。

一旦您的 VPN 上的 IP 連線工作正常。我建議在 Windows Server 2003 VPN 伺服器電腦上安裝 DNS 和 WINS 服務,並將伺服器電腦和 Windows Vista 家庭電腦設定為使用該電腦進行 WINS 和 DNS。您可以將 ISP 的 DNS 新增為 Windows Server 2003 電腦上的“轉送”,或保留配置的庫存“根提示”以允許其解析 Internet 名稱。在您的 OpenVPN 伺服器設定中,在「push "dhcp-option DNS 192.168.1.1」行之後新增下列行:

push "dhcp-option WINS 192.168.1.1"

這將使遠端用戶端存取 Windows Server 2003 電腦上的 WINS 和 DNS 伺服器,並且應該取得 DNS 和 NetBIOS 名稱解析。

如果您在家中沒有使用 Active Directory 網域,您可能需要在 Windows Server 2003 DNS 伺服器上設定標準正向尋找區域,以便您的 Windows Server 2003 和 Windows Vista 電腦註冊到其中。建立此區域時,您需要授予客戶端動態更新記錄的權限(儘管不安全)。您應該將選項「DNS 網域」(選項 15)新增至您家中的 DHCP 範圍,以便您的用戶端電腦選擇正確的 DNS 網域後綴。 (如果您使用 DD-WRT 作為 DNS,那麼我無法告訴您如何操作。我是 OpenWRT 人員,我從命令列管理我的 WRT54G。我建議從 Windows Server 運行 DHCP無論如何,2003 機器,但我更喜歡那個DHCP 伺服器。

如果您使用的是 Active Directory 網域,您已經在 DNS 中建立了正向尋找區域。不過,由於您的遠端 VPN 用戶端不是您的網域的成員,因此它們將無法在 Windows Server 在 DNS 區域上設定的庫存安全設定下在 DNS 中註冊(至少,如果您讓它在 DNS 區域建立區域) DC促銷)。它是不安全的,但如果您想允許他們註冊,您可以(a - 不太安全)更改區域的權限以允許不安全的註冊,或者(b - 更安全但仍然不安全)為他們創建A 和PTR 記錄並修改每筆記錄的權限以允許任何人更新它們。

聽起來這是一個家庭網路的事情,而且對於很多事情來說這確實是一個很好的學習機會——IP 路由、VPN、名稱解析。也許你正在尋找它“只是工作”,而不是作為一個學習機會,在這種情況下,我只能表示歉意,並說這些東西還不是“交鑰匙”。

答案2

埃文的評論是正確的,除了我敦促您考慮啟用“重定向網關”並將伺服器配置為接受所有互聯網流量,至少如果您進行任何內容過濾。如果不這樣做,您的筆記型電腦就會成為(甚至更嚴重)網路的漏洞。

通常會考慮分割隧道VPN不安全感因為它本質上為破壞筆記型電腦的攻擊者提供了通往網路核心的短路通道。

答案3

您需要確保您的 Windows OpenVPN 伺服器安裝了路由服務。

之前已經提到過這一點,但強烈建議您將 LAN 網路位址變更為 192.168.1.X 以外的其他位址。大多數 Linksys 等...都是隨該網路開箱即用的,因此遠端主機將無法存取網路內的主機。我看到您的 VPN 網路設定為 192.168.10.X,這很好。現在將您的 LAN 設定為 192.168.5.X 等。效果會更好,相信我。

您可以打開重定向網關,但我不建議這樣做,因為它會佔用您的頻寬。如果您的網路上有 IDS/IPS 設備或類似設備,那麼它可能會很有用。

我會將動詞設定為高於 1...我將其保留為 4 以查看發生了什麼情況。

希望有幫助!

答案4

抱歉挖墳了,但是經過兩個小時的努力恢復連接到 Ubuntu OpenVPN 伺服器的 Windows 機器的互聯網訪問,剛剛找到了對我有用的東西(希望其他人也能這樣做):

[Windows 8.1 x64 和 Ubuntu Server 20.04]

  1. 在 Windows 電腦上,首先前往Network and Sharing Center,右鍵單擊您的主網卡(在我的例子中是 WiFi USB),然後Properties-> Internet Protocol Version 4-> Properties-> Advanced-> 取消選取Automatic metric-> 設定Interface metric為小數字,例如 10 -> OK- > OK->OK
  2. 現在喝點水並跳上 Linux 盒子 -> 在終端機中寫入nano /etc/openvpn/server/server.conf-> 添加這一行(1000 或類似的數字) -> 用Ypush "route-metric 1000"保存文件->重啟 OpenVPN 伺服器,也許你就可以訪問互聯網了再次在Windows機器上Ctrl+Xsystemctl restart [email protected]

現在我有兩個完全可以工作的不同設定:

可存取網際網路並透過 OpenVPN 連接至 Linux 電腦的 Windows 電腦 可存取網際網路並透過 OpenVPN 連接到 Vbox'd Linux 電腦的 Windows 計算機

相關內容