PPTP应用实例

Router-to-Router安全隧道实例

以下是一个使用因特网上的加密PPTP隧道连接两个企业网的例子:

PPTP应用实例_职场

在这个例子中有两个路由器:

  • [HomeOffice]

接口LocalHomeOffice 10.150.2.254/24

接口ToInternet 192.168.80.1/24

  • [RemoteOffice]

接口ToInternet 192.168.81.1/24

接口 LocalRemoteOffice 10.150.1.254/24

每个路由器连接到一个不同的ISP。任何一个路由器可以通过因特网访问其他的路由器。

在 Preforma PPTP服务器,用户必须对客户设置:

[admin@HomeOffice] ppp secret> add name=ex service=pptp password=lkjrht

local-address=10.0.103.1 remote-address=10.0.103.2

[admin@HomeOffice] ppp secret> print detail

Flags: X - disabled

0 name="ex" service=pptp caller-id="" password="lkjrht" profile=default

local-address=10.0.103.1 remote-address=10.0.103.2 routes==""

[admin@HomeOffice] ppp secret>

然后应该在PPTP服务器列表中添加用户:

[admin@HomeOffice] interface pptp-server> add user=ex

[admin@HomeOffice] interface pptp-server> print

Flags: X - disabled, D - dynamic, R - running

# NAME USER MTU CLIENT-ADDRESS UPTIME ENC...

0 pptp-in1 ex

[admin@HomeOffice] interface pptp-server>

最后,启用服务器:

[admin@HomeOffice] interface pptp-server server> set enabled=yes

[admin@HomeOffice] interface pptp-server server> print

enabled: yes

mtu: 1460

mru: 1460

authentication: mschap2

default-profile: default

[admin@HomeOffice] interface pptp-server server>

在RemoteOffice路由器添加一个PPTP客户:

[admin@RemoteOffice] interface pptp-client> add connect-to=192.168.80.1 user=ex \

\... password=lkjrht disabled=no

[admin@RemoteOffice] interface pptp-client> print

Flags: X - disabled, R - running

0 R name="pptp-out1" mtu=1460 mru=1460 connect-to=192.168.80.1 user="ex"

password="lkjrht" profile=default add-default-route=no

[admin@RemoteOffice] interface pptp-client>

这样,一个PPTP隧道就在路由器之间创建好了。这个隧道就像在IP地址为10.0.103.1及10.0.103.2的路由器之间的以太网点对点连接。它使得在第三网络部分上的路由器之间能够直接通信。

PPTP应用实例_网络_02

为了在PPTP隧道上路由本地企业网你需要添加以下路由:

[admin@HomeOffice] > ip route add dst-address 10.150.1.0/24 gateway 10.0.103.2

[admin@RemoteOffice] > ip route add dst-address 10.150.2.0/24 gateway 10.0.103.1

在PPTP服务器上它或者可以通过使用用户配置的routes参数完成:

[admin@HomeOffice] ppp secret> print detail

Flags: X - disabled

0 name="ex" service=pptp caller-id="" password="lkjrht" profile=default

local-address=10.0.103.1 remote-address=10.0.103.2 routes==""

[admin@HomeOffice] ppp secret> set 0 routes="10.150.1.0/24 10.0.103.2 1"

[admin@HomeOffice] ppp secret> print detail

Flags: X - disabled

0 name="ex" service=pptp caller-id="" password="lkjrht" profile=default

local-address=10.0.103.1 remote-address=10.0.103.2

routes="10.150.1.0/24 10.0.103.2 1"

[admin@HomeOffice] ppp secret>

测试PPTP隧道连接:

[admin@RemoteOffice]> /ping 10.0.103.1

10.0.103.1 pong: ttl=255 time=3 ms

10.0.103.1 pong: ttl=255 time=3 ms

10.0.103.1 pong: ttl=255 time=3 ms

ping interrupted

3 packets transmitted, 3 packets received, 0% packet loss

round-trip min/avg/max = 3/3.0/3 ms

测试通过PPTP隧道到LocalHomeOffice接口的连接:

[admin@RemoteOffice]> /ping 10.150.2.254

10.150.2.254 pong: ttl=255 time=3 ms

10.150.2.254 pong: ttl=255 time=3 ms

10.150.2.254 pong: ttl=255 time=3 ms

ping interrupted

3 packets transmitted, 3 packets received, 0% packet loss

round-trip min/avg/max = 3/3.0/3 ms

要在这个安全隧道上桥接一个LAN,请参考EoIP部分手册的例子。要想对该隧道上的流量设置最大速度,请查询Queues部分。

通过PPTP隧道连接一个远程客户

下面的例子显示了如果通过给定电脑和远程办公网络同一网络IP地址的PPTP加密隧道把一个电脑连接到一个远程办公网络(不需要在EoIP隧道上桥接)

请查询如何设置一个你使用的软件的PPTP客户的手册。

PPTP应用实例_网络_03

这个例子中的路由器:

  • [RemoteOffice]

接口ToInternet 192.168.81.1/24

接口Office 10.150.1.254/24

客户电脑可以通过因特网访问路由器:

在PPTP服务器上设置用户帐号:

[admin@RemoteOffice] ppp secret> add name=ex service=pptp password=lkjrht

local-address=10.150.1.254 remote-address=10.150.1.2

[admin@RemoteOffice] ppp secret> print detail

Flags: X - disabled

0 name="ex" service=pptp caller-id="" password="lkjrht" profile=default

local-address=10.150.1.254 remote-address=10.150.1.2 routes==""

[admin@RemoteOffice] ppp secret>

然后应该在PPTP服务器列表中添加用户:

[admin@RemoteOffice] interface pptp-server> add name=FromLaptop user=ex

[admin@RemoteOffice] interface pptp-server> print

Flags: X - disabled, D - dynamic, R - running

# NAME USER MTU CLIENT-ADDRESS UPTIME ENC...

0 FromLaptop ex

[admin@RemoteOffice] interface pptp-server>

并且启用服务:

[admin@RemoteOffice] interface pptp-server server> set enabled=yes

[admin@RemoteOffice] interface pptp-server server> print

enabled: yes

mtu: 1460

mru: 1460

authentication: mschap2

default-profile: default

[admin@RemoteOffice] interface pptp-server server>

最后,代理ARP必须在'Office'接口上启用:

[admin@RemoteOffice] interface ethernet> set Office arp=proxy-arp

[admin@RemoteOffice] interface ethernet> print

Flags: X - disabled, R - running

# NAME MTU MAC-ADDRESS ARP

0 R ToInternet 1500 00:30:4F:0B:7B:C1 enabled

1 R Office 1500 00:30:4F:06:62:12 proxy-arp

[admin@RemoteOffice] interface ethernet>

1 : 1 NAT实例

如果你想从公用IP子网11.11.11.0/24访问本地的2.2.2.0/24,你应该使用目的地址翻译以及源地址翻译特性设置action=netmap

/ip firewall nat add chain=dstnat dst-address=11.11.11.1-11.11.11.254 \

       action=netmap to-addresses=2.2.2.1-2.2.2.254

/ip firewall nat add chain=srcnat src-address=2.2.2.1-2.2.2.254 \

       action=netmap to-addresses=11.11.11.1-11.11.11.254