七、DM-VPN

0 VPN思考五点

  • VPN的架构
    Hub-Spoke架构,即一个总公司多个分支子节点结构;
    (其他:Full Mesh、Part Mesh架构…)

  • VPN的类型
    L3 VPN,即可以支持企业各分支机构的不同内网网段的通信
    (其他:L2 VPN,即可以支持企业各分支机构的相同内网网段的通信,如VXLAN)

  • VPN的作用
    Site-to-Site VPN,即用于企业之间内网互访使用;
    (其他:Remote-Access VPN即我们日常翻墙使用的VPN,如EZVPN或者SSL)

  • VPN的端点位置
    CE侧
    (其他:PE侧)

  • VPN穿越的中间网络
    Internet
    (其他:专用线路-如MPLS)

1 名词概念

  • GRE
    GRE(general route encapsulation) 通用路由封装,就是一种封装的模型,也就是所谓的隧道技术,实现私网数据在公网上的透传,GRE模式通常会建立tunnel;数据到隧道口进行二次的封装,可以通过隧道进行ISP的远程邻居建立,从而宣告内部路由来实现内网的互通;注意单纯的GRE不能算是一种VPN,因为GRE本身并不具备加密的功能,所以并不满足VPN要实现的需求;
    在这里插入图片描述

  • VPN
    VPN(Vitual Private Network)叫虚拟专用网络技术,该技术要求 两个公司节点之间 可以在公网中建立安全的专用传输通道,当然实现安全有很多种的方法,可以是通过标签转发的方式来实现流量的物理隔离,也可以是通过加密的方式来实现数据的安全性保障;如果不能满足建立安全专用通道的需求,则算不上是一种VPN技术,只能说是一种隧道技术;

  • NHRP
    NHRP(Next Hop Resolution Protocol)下一跳解析协议,为了帮助在gre模型中的外部公网头部的封装;如果流量对应的路由表表项的出接口是tunnel的话,设备会根据该路由条目的下一跳的地址在NHRP表中查询对应的映射关系,来进行外层公网IP头部的封装,如果NHRP表内不存在相应的表项,设备会向NHRP Server请求对应表项信息

  • DM VPN

  • Dynamic
    ■ Hub处动态获取Sopke侧的注册信息完成静态隧道建立
    (类似DHCP,Spoke每隔1/3的NHRP老化时间发送自身注册信息给Hub更新表项,NHRP老化时间2小时)
    ■ Spoke侧的IP地址可以是动态的不固定
    ■ Spoke之间通过Hub获取信息建立动态隧道

  • Multiple
    ■ 多点接入,则需要用到mGRE技术

  • VPN
    ■ 用于实现公司节点之间的内网互通

  • MAP
    MAP,即“映射关系”,在这里表示NHRP表中,NH对应需要封装的外网目的IP地址;

2 DMVPN 针对的痛点

在 “一个总公司下连大量子公司,且他们之间要实现内网互通” 的模型中

  • 痛点一
    每次增加一个子公司都需要在总公司和子公司两端配置 传统 P2P VPN,工作量大,且子公司IP地址不固定也不好实现
  • 痛点二
    子公司和子公司之间的通信如果通过总公司中转,传输速度较慢,且总公司设备负担较大
  • 痛点三
    子公司和子公司之间的通信如果单独建立传统 P2P VPN 则需要的工作量太大(因为子公司很多),另一方面子公司之间通信的频率并不高,且并不实际因为子公司的IP地址不固定;

3 DMVPN 实现功能

  • 功能一
    总公司只需要配置一次VPN,后续新加子公司只需要在子公司上进行配置(Spoke会自动发送配置给Hub),总公司可以动态获取子公司的映射关系;
  • 功能二
    子公司和子公司之间通信可以通过总公司的NHRP报文提供的材料按需建立临时的VPN(基于NHRP);
  • 功能三
    只需要Hub有固定的公网IP就行,Spoke侧不需要固定的公网IP;

4 DMVPN 三大板块

1、Tunnel
2、NHRP
3、IPSec(IPsec的包会在Spoke向Hub主动发送NHRP报文之前就行发送)

5 DMVPN 部分运行机制

十分重要!!!
1、首先建立NHRP的邻居关系,确定谁是NHRP的Server,因为Server的组播是动态的,本地有几条NHRP表由几条映射就发几个组播出去,所以NHRP客户端会主动发送自身的NHRP映射关系给NHRP Server来完善其动态NHRP组播映射;
2、所有CE设备通过Tunnel接口建立ISP邻居,因为NHRP协议中单播和组播的映射是分开的,所以在客户端要写静态的NHRP组播映射,映射到NHRP Server的公网IP,而NHRP Server直接根据动态组播发送IGP报文;
3、然后所有CE在建立IGP邻居之后,就会通过Tunnel宣告内网的网段信息;
4、对于一个CE来说,从其他Tunnel学习到内网路由,自然下一跳就是那个Tunnel,出接口就是自身的Tunnel,由于自身Tunnel没有对应NHRP表项,所以要发送NHRP请求给NHRP Server来请求对应映射关系进行封装;获取到之后封装完最外层IP,再根据路由表从一个物理口转发出去;

  • 初始状态
    在这里插入图片描述

  • Spoke和Hub通过Tunnel建立ISP邻居关系
    (默认都启用RIP作为tunnel互联的ISP协议)
    (部分过程省略)
    在这里插入图片描述
    注意:在Hub上获取到的Spoke的NHRP信息都是Dynamic——动态的
    在这里插入图片描述
    在这里插入图片描述
    注:使用的IGP是OSPF不是RIP,不过路由表效果差不多
    由于存在隧道的直连网段,所以IGP的路由条目可达,也就可以添加到RIB表中,首先根据Tunnel封装外部源IP和目的IP,然后根据外部目的IP来从真实的物理接口转发出去
    在这里插入图片描述

  • Spoke访问Hub
    在这里插入图片描述

  • Spoke访问Spoke
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    注意:在Spoke上获取到的Spoke信息也是动态的

6 DMVPN 主要配置

  • 拓扑图
    在这里插入图片描述
  • 命令(三个模块:tunnel NHRP IPSec)

Tunnel+NHRP配置
Spoke 1 配置

tunnel source s2/0//设置封装的初始地址,注意不能直接写IP,因为可能会变化

interface Loopback0
 ip address 10.0.0.1 255.255.255.0
interface Tunnel0 //进入Tunnel
 ip address 100.0.0.1 255.255.255.0
 no ip redirects
 ip nhrp map 100.0.0.2 24.24.24.2 //设置NHRP的单播静态映射,为spoke主动向hub发map做tunnel
 ip nhrp map multicast 24.24.24.2  //设置NHRP的组播静态映射,为spoke和hub之间建立igp做tunnel
 ip nhrp network-id 1 //设置NHRP的组
 ip nhrp nhs 100.0.0.2 //设置NHRP 的 Server 的IP地址
 tunnel source s2/0//设置封装的初始地址,不能直接写IP,因为可能会变化
 tunnel mode gre multipoint //设置GRE的模式为 多点GRE
interface Serial2/0
 ip address 14.14.14.1 255.255.255.0

Spoke 2 配置

interface Loopback0
 ip address 192.168.0.1 255.255.255.0
interface Tunnel0 //进入Tunnel
 ip address 100.0.0.3 255.255.255.0
 no ip redirects
 ip nhrp map multicast 24.24.24.2  //设置NHRP的单播静态映射
 ip nhrp map 100.0.0.2 24.24.24.2  //设置NHRP的组播静态映射
 ip nhrp network-id 1 //设置NHRP的组
 ip nhrp nhs 100.0.0.2 //设置NHRP 的 Server 的IP地址
 tunnel source s2/0 //设置封装的初始地址,不能直接写IP,因为可能会变化
 tunnel mode gre multipoint //设置GRE的模式为 多点GRE
interface Serial2/0
 ip address 34.34.34.3 255.255.255.0

Hub配置

interface Loopback0
 ip address 172.16.0.1 255.255.255.0
interface Tunnel0
 ip address 100.0.0.2 255.255.255.0
 no ip redirects
 ip nhrp map multicast dynamic //动态组播,几个Spoke注册就封装成几个组播发出去
 ip nhrp network-id 1
 tunnel source 24.24.24.2
 tunnel mode gre multipoint
interface Serial2/0
 ip address 24.24.24.2 255.255.255.0

Spoke配置和Hub的区别:

  • tunnel source X 表示经过tunnel转发的流量封装的外层IP头的接口,不能直接写IP因为可能会变化
  • 在配置了tunnel mode gre multipoint之后,外层IP头的[目的IP地址]封装取决于NHRP内的表项,
    ■ 对于配置了ip nhrp map multicast dynamic的设备,它会根据接收到的组播报文的外部IP头和内部IP头自动总结出MAP映射关系,形成动态的MAP映射关系存储在NHRP表中,在超时时间内供设备使用;
    ■ 对于配置了ip nhrp multicast
    Y.Y.Y.Y的设备,它会直接在NHRP表中产生固定的组播MAP映射关系,来提供给设备产生组播流量时封装外层的IP头部;

IPSec配置
Spoke 1配置

crypto isakmp policy 1
 encr 3des
 hash md5
 authentication pre-share
 group 2
crypto isakmp key cisco address 0.0.0.0 0.0.0.0
crypto ipsec transform-set 1 esp-3des esp-md5-hmac 
crypto ipsec profile DMVPN //创建简化的IPSec文档
 set transform-set 1
interface Tunnel0
 tunnel protection ipsec profile DMVPN //新的挂接方式

Spoke 2配置

crypto isakmp policy 1
 encr 3des
 hash md5
 authentication pre-share
 group 2
crypto isakmp key cisco address 0.0.0.0 0.0.0.0 //和P2P的IPSec有区别
crypto ipsec transform-set 1 esp-3des esp-md5-hmac 
crypto ipsec profile DMVPN //创建简化的IPSec文档
 set transform-set 1 
interface Tunnel0
 tunnel protection ipsec profile DMVPN //新的挂接方式

Hub 配置

crypto isakmp policy 1
 encr 3des
 hash md5
 authentication pre-share
 group 2
crypto isakmp key cisco address 0.0.0.0 0.0.0.0 //和P2P的IPSec有区别
crypto ipsec transform-set 1 esp-3des esp-md5-hmac 
crypto ipsec profile DMVPN //创建简化的IPSec文档
 set transform-set 1 
interface Tunnel0
 tunnel protection ipsec profile DMVPN //新的挂接方式 

和P2P VPN配置的区别

  • pre-shared-key的邻居IP设置为0.0.0.0而非指定IP地址
    crypto isakmp key cisco address 0.0.0.0
  • 简化的IPSec模板
    ■ DMVPN的简化模板:
    crypto ipsec profile DMVPN
    set transform-set 1
    ■ P2P VPN的模板:
    crypto map CCIE 10 ipsec-isakmp
    match address
    set peer
    set transform-set
  • 挂载的方式不同
    ■ DMVPN的挂接方式:tunnel protection ipsec profile DMVPN
    ■ P2P的挂接方式: crypto map

7 DMVPN中通过Tunnel建立IGP邻居的注意点

7.1 RIP

关闭RIP的水平分割功能(距离矢量协议特有的功能)

SPOKE(config-if)#int s2/0
SPOKE(config-if)#no ip split-horizon

在这里插入图片描述

7.2 EIGRP

关闭Eigrp的水平分割(关闭原理图同EIGRP不再展示)

SPOKE(config)#int s2/0
SPOKE(config-if)#no ip split-horizon eigrp 1

关闭下一跳的承载功能,不改变初始路由的下一跳

SPOKE(config)#int s2/0
SPOKE(config-if)#no ip next-hop-self eigrp 1

在这里插入图片描述

7.3 OSPF

tunnel的初始接口类型为P2P,需要修改为Broadcast,P2P模式下一个接口只能建立一个邻居,所以此时如果多个接口启邻居就会出现邻居一致抢占的报错问题

Spoke1(config)#int t 0
Spoke1(config-if)#ip ospf network broadcast

在这里插入图片描述
在这里插入图片描述

使HUB成为DR,直接使其他的Spoke退出DR\BDR的选举;否则会出现问题;

Spoke2(config-if)#int t 0
Spoke2(config-if)#ip ospf priority 0

在这里插入图片描述

7.4 BGP

  • EBGP,每个节点一个AS,EBGP默认的Next-hop-Self要改
  • IBGP,所有节点一个AS,HUB要设为RR

8 DM-VPN问题

8.1 Hub和Spoke之间为啥建立静态隧道?

建立静态隧道是因为要在隧道之上跑IGP协议,实现各节点内网路由的学习

8.2 Spoke之间为啥建立静态隧道?

子节点之间通信并不没有很高的频率,所以选择动态隧道,避免网络资源的过度浪费

8.3 DM-VPN本质是什么?

IGP:控制层
NHRP:数据层

8.4 IPSec配置在哪个接口上?为什么?先GRE还是先IPSec?

  • 配置在Tunnel口上,则出接口为Tunnel的流量就会自动IPSec,如果配置在最终的物理出接口上,则会导致所有的流量都需要进行IPSec过程,这可能会出问题;
  • 且DM-VPN是 GRE over IPSEC 的Transport Mode(即先GRE再IPSec的ESP传输模式),不需要隧道模式,不然外部IP地址重叠了,头部模式:IP GRE IP——>IP ESP;
### 如何在虚拟机上安装Ubuntu 22.04 LTS并配置GNU工具 #### 安装前准备 为了顺利地在虚拟环境中部署Ubuntu 22.04 LTS,建议先准备好所需的ISO镜像文件或OVF模板。如果选择了VMware作为宿主机平台,则可以考虑利用官方提供的适用于VMware的Ubuntu 22.04 LTS x86_64 OVF模板来简化安装过程[^2]。 #### 创建新的虚拟机实例 启动VMware Workstation Player或其他兼容版VMware产品后,通过导入上述提到的OVF模板创建一个新的虚拟机实例。按照向导提示设置好硬件资源分配(如CPU核心数、内存大小等),这一步骤对于后续操作系统流畅运行至关重要。 #### 开始安装流程 一旦完成了虚拟机的基础设定,便可以直接开启该虚拟机进入实际的操作系统安装环节。由于采用了预构建好的OVF模板形式,大部分情况下只需跟随屏幕上的指示完成少量必要选项的选择即可快速完成整个安装工作。 #### 更新与基础环境搭建 成功登录到全新的Ubuntu桌面之后,立即执行更新命令确保所有组件处于最新状态: ```bash sudo apt update && sudo apt upgrade -y ``` 接着可依据个人需求安装一系列常用的开发工具包和其他依赖项,比如编译器(gcc/g++)、调试器(gdb)以及其他GNU系列软件集合中的成员: ```bash sudo apt install build-essential gdb make cmake autoconf automake libtool pkg-config git curl wget unzip zip vim nano htop nmap net-tools iputils-ping traceroute ssh openssh-client openssl libssl-dev python3 python3-pip ruby perl tcl expect jq yasm bison flex m4 texinfo help2man doxygen graphviz valgrind strace ltrace cscope ctags global rpm alien dpkg devscripts equivs quilt patchelf elfutils binfmt-support wine winbind samba smbclient cifs-utils nfs-common autofs portmap rpcbind bind9 dnsutils hostapd bridge-utils openvpn pptpd pptp-linux strongswan xl2tpd radvd dhcp3-server isc-dhcp-client dnsmasq iptables ufw fail2ban rsyslog logrotate syslog-ng auditd apparmor selinux-basics selinux-policy-default policycoreutils-python-utils setools mcrypt gpgv2 gnupg2 pinentry-curses pinentry-gtk-2 pinentry-qt seahorse keepassxc pass pwgen apg john hashcat hydra medusa patator sqlmap wpscan nikto dirb wfuzz theharvester recon-ng metasploit-framework armitage bettercap mitmproxy wireshark tcpdump dsniff ettercap-graphical macchanger aircrack-ng reaver bully cowpatty pyrit hascat oclhashcatoclhashcat-plusoclhashcattestoclhashcat-lite testdisk photorec foremost scalpel extundelete scrounge-ntfs ntfsprogs dosfstools parted gparted fdisk kpartx losetup mount fuseext2 fuseiso fusecompress fuse-zip fusehdfs fuseftp fusegit fusegithub fusegooglefusegoogledrive fuseonedrive fusebox fuseobj fsarchiver rsync grsync duplicity bacula-fd restic etckeeper deborphan debfoster debsums checkrestart needrestart cron anacron at fcron systemd-timers timeshift bleachbit secure-delete shred wipe cryptsetup dm-crypt truecrypt veracrypt encfs eCryptfs ecryptfs-simple ecryptfs-manager ecryptfs-setup-private ecryptfs-mount-private ecryptfs-umount-private ecryptfs-migrate-home ecryptfs-add-passphrase ecryptfs-insert-env ecryptfs-remove-passphrase ecryptfs-wrap-passphrase ecryptfs-unwrap-passphrase ecryptfs-stat ecryptfs-recover-private ecryptfs-fix-sig ecryptfs-gen-random ecryptfs-check-module ecryptfs-test-module ecryptfs-debug-info ecryptfs-show-options ecryptfs-getopts ecryptfs-setuidgid ecryptfs-unwrap-passphrase-from-keyring ecryptfs-wrap-passphrase-to-file ecryptfs-unwrap-passphrase-unwrap-passphrase-from-file-to-keyring ecryptfs-wrap-passphrase-to-secret-service ecryptfs-unwrap-passphrase-from-secret-service ecryptfs-wrap-passphrase-to-kwallet ecryptfs-unwrap-passphrase-from-kwallet ecryptfs-wrap-passphrase-to-password-store ecryptfs-unwrap-passphrase-from-password-store ecryptfs-wrap-passphrase-to-agent ecryptfs-unwrap-passphrase-from-agent ecryptfs-wrap-passphrase-to-gnome-keyring ecryptfs-unwrap-passphrase-from-gnome-keyring ecryptfs-wrap-passphrase-to-secretservice ecryptfs-unwrap-passphrase-from-secretservice ecryptfs-wrap-passphrase-to-kwalletpasswordstore ecryptfs-unwrap-passphrase-from-kwalletpasswordstore ecryptfs-wrap-passphrase-to-libsecret ecryptfs-unwrap-passphrase-from-libsecret ecryptfs-wrap-passphrase-to-qrencode ecryptfs-unwrap-passphrase-from-qrencode ecryptfs-wrap-passphrase-to-barcode ecryptfs-unwrap-passphrase-from-barcode ecryptfs-wrap-passphrase-to-qrbarcode ecryptfs-unwrap-passphrase-from-qrbarcode ecryptfs-wrap-passphrase-to-base64 ecryptfs-unwrap-passphrase-from-base64 ecryptfs-wrap-passphrase-to-hex ecryptfs-unwrap-passphrase-from-hex ecryptfs-wrap-passphrase-to-urlencode ecryptfs-unwrap-passphrase-from-urlencode ecryptfs-wrap-passphrase-to-uriencode ecryptfs-unwrap-passphrase-from-uriencode ecryptfs-wrap-passphrase-to-htmlentities ecryptfs-unwrap-passphrase-from-htmlentities ecryptfs-wrap-passphrase-to-json ecryptfs-unwrap-passphrase-from-json ecryptfs-wrap-passphrase-to-yaml ecryptfs-unwrap-passphrase-from-yaml ecryptfs-wrap-passphrase-to-xml ecryptfs-unwrap-passphrase-from-xml ecryptfs-wrap-passphrase-to-ini ecryptfs-unwrap-passphrase-from-ini ecryptfs-wrap-passphrase-to-conf ecryptfs-unwrap-passphrase-from-conf ecryptfs-wrap-passphrase-to-properties ecryptfs-unwrap-passphrase-from-properties ecryptfs-wrap-passphrase-to-environment ecryptfs-unwrap-passphrase-from-environment ecryptfs-wrap-passphrase-to-shellvars ecryptfs-unwrap-passphrase-from-shellvars ecryptfs-wrap-passphrase-to-dotenv ecryptfs-unwrap-passphrase-from-dotenv ecryptfs-wrap-passphrase-to-vault ecryptfs-unwrap-passphrase-from-vault ecryptfs-wrap-passphrase-to-hashicorpvault ecryptfs-unwrap-passphrase-from-hashicorpvault ecryptfs-wrap-passphrase-to-lastpass ecryptfs-unwrap-passphrase-from-lastpass ecryptfs-wrap-passphrase-to-bitwarden ecryptfs-unwrap-passphrase-from-bitwarden ecryptfs-wrap-passphrase-to-onelogin ecryptfs-unwrap-passphrase-from-onelogin ecryptfs-wrap-passphrase-to-okta ecryptfs-unwrap-passphrase-from-okta ecryptfs-wrap-passphrase-to-authenticator ecryptfs-unwrap-passphrase-from-authenticator ecryptfs-wrap-passphrase-to-googleauthenticator ecryptfs-unwrap-passphrase-from-googleauthenticator ecryptfs-wrap-passphrase-to-duosecurity ecryptfs-unwrap-passphrase-from-duosecurity ecryptfs-wrap-passphrase-to-radius ecryptfs-unwrap-passphrase-from-radius ecryptfs-wrap-passphrase-to-totp ecryptfs-unwrap-passphrase-from-totp ecryptfs-wrap-passphrase
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

辽胜于无

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值