2009年11月29日 星期日

Ubuntu : VPN Server 2

2009年11月29日 星期日
如果 VPN server 擺在防火牆內,該開放什麼 port 呢?由於現在已經不管學校的網路,沒有機會在真實的環境中實測,今天利用 VMWare 模擬了可能的狀況。
以 m0n0wall 當防火牆,插兩張網卡,VMNet0 對外,而 VMNet1 對內。對內擺了 Ubuntu(VPN server) ,透過 VMNet1 和 firwall 接在一起。網路架構如下:


XP(client) 172.17.1.10/16

Internet

-----VMNet0(bridged) 172.17.1.250/16-----
m0n0wall(firewall)
-----VMNet1(host only) 192.168.1.254/24-----

Intranet(192.168.1.0/24)

-----VMNet1(host only) 192.168.1.2/24-----
Ubuntu(VPN Server)

由於 VNP server 是擺在 firewall 之內,因此要注意開放 pptpd 連線時所需要的 port。
在 m0n0wall 上,VPN server 有個一對一的 NAT IP (合法 IP , 這裡先假設為 172.17.1.7),它對映到內網的 private IP (192.168.1.2)。

pptpd 是監聽在 TCP 1723 ,因此,我們在 firewall 上要對 WAN 開放連到內網 VPN server (192.168.1.2) 的 TCP 1723 port。

基本上,在尚未透過 VPN 連線前 XP 是無法存取 Intranet 的資源的,而且它的身份是 172.17.1.10。

我把 VPN server 上的 /etc/pptpd.conf 做了以下的設定
localip 192.168.1.2
remoteip 192.168.1.100-105


而 /etc/ppp/chap-secrets 做了以下的設定
vip pptpd walawala *

也就是當 XP 用帳號 vip 、密碼 walawala 連線 VPN server 以後,它可能會取得 192.168.1.100 (100~105) 的 IP ,這樣 XP 就變成好像直接置入 VPN server 所在的內網了。


XP 未進行 VPN 連線前的網路相關訊息

>ipconfig /all
Windows IP Configuration

   Host Name . . . . . . . . . . . . : xp1
   Primary Dns Suffix  . . . . . . . :
   Node Type . . . . . . . . . . . . : Unknown
   IP Routing Enabled. . . . . . . . : No
   WINS Proxy Enabled. . . . . . . . : No
   DNS Suffix Search List. . . . . . : happy.edu.tw

Ethernet adapter 區域連線:

   Connection-specific DNS Suffix  . : happy.edu.tw
   Description . . . . . . . . . . . : NVIDIA nForce Networking Controller
   Physical Address. . . . . . . . . : 00-17-31-B8-18-29
   Dhcp Enabled. . . . . . . . . . . : No
   IP Address. . . . . . . . . . . . : 172.17.1.10
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . : 172.17.1.254
   DNS Servers . . . . . . . . . . . : 172.17.1.254


>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 17 31 b8 18 29 ...... NVIDIA nForce Networking Controller
===========================================================================
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
     0.0.0.0          0.0.0.0     172.17.1.254     172.17.1.10       1
   127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1
 169.254.0.0      255.255.0.0      172.17.1.10     172.17.1.10       30
  172.17.0.0      255.255.0.0      172.17.1.10     172.17.1.10       20
 172.17.1.10  255.255.255.255        127.0.0.1       127.0.0.1       20
172.17.255.255  255.255.255.255      172.17.1.10     172.17.1.10       20
   224.0.0.0        240.0.0.0      172.17.1.10     172.17.1.10       20
255.255.255.255  255.255.255.255      172.17.1.10     172.17.1.10       1
Default Gateway:      172.17.1.254
===========================================================================
Persistent Routes:
None


>tracert www.hinet.net

Tracing route to www.hinet.net [203.66.88.89]
over a maximum of 30 hops:

1    <1 ms    <1 ms    <1 ms  vm.happy.edu.tw [172.17.1.254]
2    21 ms    21 ms    21 ms  218-160-32-254.dynamic.hinet.net [218.160.32.254]
3    21 ms    21 ms    21 ms  tp-mz-t64-2.router.hinet.net [168.95.71.54]
4    21 ms    22 ms    21 ms  tp-crs11.router.hinet.net [220.128.4.118]
5    21 ms    21 ms    21 ms  tp-s2-c6r10.router.hinet.net [220.128.2.137]
6    21 ms    21 ms    21 ms  www.hinet.net [203.66.88.89]

Trace complete.



當 VPN 連線成功以後,網路的相關訊息

>ipconfig /all  執行完,多了底下的東西

PPP adapter Ubuntu:

   Connection-specific DNS Suffix  . :
   Description . . . . . . . . . . . : WAN (PPP/SLIP) Interface
   Physical Address. . . . . . . . . : 00-53-45-00-00-00
   Dhcp Enabled. . . . . . . . . . . : No
   IP Address. . . . . . . . . . . . : 192.168.1.100
   Subnet Mask . . . . . . . . . . . : 255.255.255.255
   Default Gateway . . . . . . . . . : 192.168.1.100
   DNS Servers . . . . . . . . . . . : 192.168.1.254

>route print
===========================================================================
Interface List
0x1 ........................... MS TCP Loopback interface
0x2 ...00 17 31 b8 18 29 ...... NVIDIA nForce Networking Controller
0xe0004 ...00 53 45 00 00 00 ...... WAN (PPP/SLIP) Interface
===========================================================================
===========================================================================
Active Routes:
Network Destination        Netmask          Gateway       Interface  Metric
     0.0.0.0          0.0.0.0     172.17.1.254     172.17.1.10       2
     0.0.0.0          0.0.0.0    192.168.1.100   192.168.1.100       1
   127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1       1
 169.254.0.0      255.255.0.0      172.17.1.10     172.17.1.10       30
  172.17.0.0      255.255.0.0      172.17.1.10     172.17.1.10       20
 172.17.1.10  255.255.255.255        127.0.0.1       127.0.0.1       20
172.17.255.255  255.255.255.255      172.17.1.10     172.17.1.10       20
192.168.1.100  255.255.255.255        127.0.0.1       127.0.0.1       50
192.168.1.255  255.255.255.255    192.168.1.100   192.168.1.100       50
   224.0.0.0        240.0.0.0      172.17.1.10     172.17.1.10       20
   224.0.0.0        240.0.0.0    192.168.1.100   192.168.1.100       1
255.255.255.255  255.255.255.255      172.17.1.10     172.17.1.10       1
255.255.255.255  255.255.255.255    192.168.1.100   192.168.1.100       1
Default Gateway:     192.168.1.100
===========================================================================
Persistent Routes:
None

注意有 192.168.1.100 的那幾行

>tracert www.hinet.net

Tracing route to www.hinet.net [61.219.38.89]
over a maximum of 30 hops:

1     2 ms     1 ms     1 ms  192.168.1.2
2     3 ms     2 ms     1 ms  firewall.happy.edu.tw [192.168.1.254]
3     3 ms     2 ms     2 ms  vm.happy.edu.tw [172.17.1.254]
4    23 ms    23 ms    24 ms  218-160-32-254.dynamic.hinet.net [218.160.32.254]
5    23 ms    23 ms    22 ms  tp-mz-t64-2.router.hinet.net [168.95.71.54]
6    23 ms    24 ms    24 ms  tp-crs11.router.hinet.net [220.128.4.118]
7    23 ms    24 ms    25 ms  tp-s2-c6r9.router.hinet.net [220.128.2.17]
8    23 ms    23 ms    23 ms  www.hinet.net [61.219.38.89]

Trace complete.

當 VPN 連線成功以後,XP 有一個 192.168.1.100 的 IP ,DNS 依 VPN 的指示加了 VPN server 所在內網的 DNS,而 routing table 也更改了,Internet 的連線都改由 192.168.1.100 所在的介面(PPP)來進出。雖然它身在 Internet 中,但已經像 Intranet 中的某一臺機器了。

沒有留言:

張貼留言

 
雄::gsyan © 2009. Design by Pocket