Router to Router安全隧道实例 以下是一个使用互联网上的加密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,任何一个路由器可以通过互联网访问到对端的路由器。 HomeOffice配置 在HomeOffice端建立PPTP服务器,首先我们进入/ppp secret目录下添加客户端账号: [admin@HomeOffice] ppp secret> add name=ex service=pptp password=123456 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="123456" profile=default local-address=10.0.103.1 remote-address=10.0.103.2 routes=="" [admin@HomeOffice] ppp secret> Winbox操作如下: 在interface pptp-server server目录下,启用pptp服务器: [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> Winbox下配置进入ppp目录下启用pptp server: RemoteOffice配置 在RemoteOffice路由器添加一个PPTP客户: [admin@RemoteOffice] interface pptp-client> add connect-to=192.168.80.1 user=ex \ \... password=123456 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="123456" profile=default add-default-route=no [admin@RemoteOffice] interface pptp-client> Winbox在interface中添加pptp-client 这样,一个PPTP隧道就在路由器之间创建好了。这个隧道就像在IP地址为10.0.103.1及10.0.103.2的路由器之间的三层点对点连接。 pptp局域网的互访 pptp隧道建立完成后,仅是路由器间可以互访,但两个企业间的局域网需要通过设置路由完成连接 为了在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服务器(HomeOffice)上通过用户配置的routes参数完成,RemoteOffice还是需要在/ip route中配置路由: [admin@HomeOffice] ppp secret> print detail Flags: X - disabled 0 name="ex" service=pptp caller-id="" password="123456" 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="123456" 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> 目的路由:10.150.1.0/24 pptp的网关:10.0.103.2 Distance路径: 1 Winbox中修改routes参数 测试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 通过PPTP隧道连接终端客户 下面的例子显示了通过终端电脑与远程办公网络进行PPTP加密隧道通信,如外地出差的同时,通过笔记本电脑连接会公司的网络进行远程信息管理和查询 这个例子中的路由器: · [RemoteOffice] 接口ToInternet 192.168.81.1/24 接口Office 10.150.1.254/24 在PPTP服务器上设置用户帐号: [admin@RemoteOffice] ppp secret> add name=ex service=pptp password=123456 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="123456" 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 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> 在笔记本电脑访问回公司后,需要访问内部网络资源,需要配置规则才能确保通常,有两种方法: 局域网连接方法1:代理ARP必须在'Office'接口上启用,这样可以通过代理arp访问,但有个缺点是内外的DHCP服务可能会受到影响: [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> 在winbox中进入interface目录下,选择office接口设置arp为proxy-arp 局域网连接方法2:通过nat设置masquerade,规则要求对所有来访数据进行伪装,这样保证内外网通过转换通信 [admin@RemoteOffice] /ip firewall nat> add chain=srcnat action=masquerade [admin@RemoteOffice] /ip firewall nat> print Flags: X - disabled, R - running Flags: X - disabled, I - invalid, D - dynamic 0 chain=srcnat action=masquerade [admin@RemoteOffice] interface ethernet> 在winbox中添加masquerade规则: 还有更多的相关资料大家可以到Cdnat官网去看看,也可以到ROS软路由论坛去交流。
|