RIP、OSPF、BGP路由协议认证实验

Cisco Packet Tracer中的所有路由器都无法模拟RIPv2以及BGP的认证功能,因此思科设备使用GNS3进行实验,GNS3的安装及基本使用推荐观看此视频:https://www.bilibili.com/video/BV1gw411C73h/

GNS3文字教程可以参考此文档:https://zjucomp.net/docs/GNS3/client-usage

GNS3中使用的路由器型号为c7200: https://blog.csdn.net/counsellor/article/details/106709780

eNSP使用的路由器型号为AR2220: https://support.huawei.com/enterprise/zh/routers/ar2220-pid-250414853

1. RIPv2

RIPv1不支持认证功能,而RIPv2支持文本认证(即 Simple 认证)和数据报认证(即 MD5 认证)。

1.1. 思科(GNS3)

参考:https://wenku.baidu.com/view/cb0c5e782b160b4e767fcf8c?pcf=2&bfetype=new&bfetype=new&_wkts_=1739801826459

1.1.1. 拓扑

alt text

1.1.2. 配置

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
en
conf t

! 创建密钥链
key chain rip-auth
! 添加密钥
key 1
! 配置与密匙相对应的密码
key-string mkbk

int f0/0
ip add 10.0.0.1 255.255.255.128
! 设置rip使用md5认证
rip authentication mode md5
! 设置rip认证使用的密匙链为前面创建的rip-auth(明文认证也同样需要关联密钥链)
ip rip authentication key-chain rip-auth
no shu

int loop1
! 使用vlsm
ip add 192.168.1.1 255.255.255.128

router rip
version 2
no auto-summary
network 10.0.0.1
network 192.168.1.1

R2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
en
conf t

hostname R2

key chain rip-auth
key 1
key-string mkbk

int f0/0
ip add 10.0.0.2 255.255.255.128
rip authentication mode md5
ip rip authentication key-chain rip-auth
no shu

int loop1
ip add 192.168.1.129 255.255.255.128

router rip
version 2
no auto-summary
network 10.0.0.2
network 192.168.1.129

1.1.3. 验证

  1. 查看路由表(show ip route rip):

    • R1: alt text
    • R2: alt text
  2. 查看rip数据库(show ip rip database):

    • R1: alt text
    • R2: alt text
  3. 连通信测试(ICMP 通信):

    • R1: alt text
    • R2: alt text

1.2. 华为(eNSP)

1.2.1. 拓扑

alt text

1.2.2. 配置

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sys

sysname R1

int g0/0/0
ip add 10.0.0.1 30
// 在接口上配置rip md5密文认证
rip authentication-mode md5 usual cipher mkbk

int loop1
ip add 6.6.6.6 32

rip 1
ver 2
// 必须使用主类网络地址进行宣告
net 10.0.0.0
net 6.0.0.0

R2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sys

sysname R2

int g0/0/0
ip add 10.0.0.2 30
// 在接口上配置rip md5密文认证
rip authentication-mode md5 usual cipher mkbk

int loop1
ip add 8.8.8.8 32

rip 1
ver 2
// 必须使用主类网络地址进行宣告
net 10.0.0.0
net 8.0.0.0

1.2.3. 验证

  1. 查看路由表(dis ip rou p rip):
    • R1:
      alt text

    • R2:
      alt text

2. OSPF

2.1. 思科(GNS3)

参考:https://book.douban.com/subject/36521254/

攻击者可能会伪造OSPF数据包或获得网络的物理访问权限,控制了路由表之后,攻击者可能会拦截流量、发起拒绝服务攻击或其他恶意行为。

可以逐个接口启用OSPF认证机制,也可以在区域内的所有接口上同时启用OSPF认证机制。此外,只能将密码设置为接口参数,必须为每个接口设置密码。如果没有为接口设置密码,那么默认密码将设置为空值。若同时设置了区域认证和接口认证,路由器将以接口的设置优先。

OSPF支持两种认证模式:

  • 明文认证:几乎没有什么安全性,任何有权访问链路的人都能通过网络嗅探器看到密码。可以通过命令area area-id authentication为OSPF区域启用明文认证模式,也可以通过接口参数命令ip ospf authentication仅在特定接口启用明文认证模式。可以通过接口参数命令ip ospf authentication-keypassword配置明文密码。

  • MD5认证:该认证模式使用哈希,永远也不会通过链路向外发送密码。MD5认证是一种较为安全的认证模式。可以通过命令area area-id authentication message-digest为OSPF区域启用MD5认证,也可以通过接口参数命令ip ospf authentication message-digest为特定接口启用MD5认证。最后再通过接口参数命令ip ospf message-digest-key <key-id> md5 <password>配置MD5密码。

2.1.1. 拓扑

Area 10使用明文认证,Area 0使用MD5认证。R1和R3使用基于接口的认证方式,R2使用基于区域的认证方式。所有区域的密码均为mkbk。

alt text

2.1.2. 配置

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
en
conf t

int f1/0
ip add 10.0.0.2 255.255.255.0
! 基于接口开启ospf明文认证
ip ospf authentication
! 配置明文认证密码
ip ospf authentication-key mkbk
no shu

! int loop1
! ip add 192.168.1.1 255.255.255.128

router ospf 1
network 10.0.0.2 0.0.0.255 area 10

R2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
en
conf t

int f1/0
ip add 10.0.0.1 255.255.255.0
! 配置明文认证密码
ip ospf authentication-key mkbk
no shu

int g0/0
ip add 20.0.0.1 255.255.255.0
! 配置md5加密认证密码
ip ospf message-digest-key 1 md5 mkbk
no shu

! int loop1
! ip add 192.168.1.1 255.255.255.128

router ospf 1
! 基于区域配置认证方式
! 标准区域使用明文密码认证
area 10 authentication
! 主干区域使用md5认证
area 0 authentication message-digest
network 10.0.0.1 0.0.0.255 area 10
network 20.0.0.1 0.0.0.255 area 0

R3:

1
2
3
4
5
6
7
8
9
10
11
12
13
en
conf t

int g0/0
ip add 20.0.0.2 255.255.255.0
! 基于接口开启ospf的明文认证
ip ospf authentication message-digest
! 配置明文认证密码
ip ospf message-digest-key 1 md5 mkbk
no shu

router ospf 1
network 20.0.0.2 0.0.0.255 area 0

2.1.3. 验证

  1. 查看ospf邻居列表(show ip ospf neighbor):

    • R1:
      alt text
    • R3:
      alt text
    • R2:
      alt text
  2. 查看ospf路由表(show ip route ospf):

    • R1: alt text
    • R3: alt text
      ospf路由条目中的IA表示区域间路由(Inter Area),去往不同区域的路由条目就会标记上IA
  3. 查看认证信息(show ip ospf interface | include line|auth|key):

    • R1: alt text
    • R2: alt text
    • R3: alt text

2.2. 华为(eNSP)

2.2.1. 拓扑

为保证主干区域area 0的安全性,在area 0开启区域认证,使用hmac-md5的验证方式,密码为mkbk。R1与R2之间开启OSPF接口认证,使用明文的认证方式,密码为mkbk。并且R2的area 0和area 10分别属于ospf进程100和200(多进程ospf)。

alt text

2.2.2. 配置

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
sys

sysname R1

int loop1
ip add 6.6.6.6 32

int g0/0/0
ip add 10.0.0.2 30
// 基于接口的明文认证
ospf authentication-mode simple cipher mkbk

ospf 1
area 10
network 10.0.0.2 0.0.0.3
network 6.6.6.6 0.0.0.0

dis cu | be ospf

R2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
sys

sysname R2

int g0/0/0
ip add 10.0.0.1 30

int g0/0/1
ip add 20.0.0.1 30

ospf 100
area 10
network 10.0.0.1 0.0.0.3
// area 10中的所有接口采用明文认证
authentication-mode simple cipher mkbk

// 多进程ospf
ospf 200
area 0
network 20.0.0.1 0.0.0.3
// area 0中的所有接口采用hmac-md5认证
authentication-mode hmac-md5 1 cipher mkbk

dis cu | be ospf

R3:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
sys

sysname R3

int loop1
ip add 8.8.8.8 32

int g0/0/0
ip add 20.0.0.2 30
ospf authentication-mode hmac-md5 1 cipher mkbk

ospf 1
area 0
network 20.0.0.2 0.0.0.3
network 8.8.8.8 0.0.0.0

dis cu | be ospf

2.2.3. 验证

  1. 验证邻居关系已建立(dis ospf peer
    alt text

  2. 验证不同ospf进程会维护不同ospf路由表(dis ospf rou
    alt text
    OSPF进程100与OSPF进程200相互隔离,然而这两个OSPF进程都能够为R2自身贡献路由(dis ip rou pro ospf):
    alt text

  3. R2默认不会将OSPF进程200中的LSA注入进程100,反之亦然。因此路由器R3与R1无法互访。要实现互访,要在R2上为这两个OSPF进程之间相互进行路由重发布即可,即将OSPF进程100的路由引入进程200(import-route ospf 100),同时将OSPF进程200的路由引入进程100(import-route ospf 200)即可:
    alt text

3. BGP

3.1. 思科(GNS3)

参考:https://www.cisco.com/c/zh_cn/support/docs/ip/border-gateway-protocol-bgp/112188-configure-md5-bgp-00.html

3.1.1. 拓扑

R1和R2建立eBGP关系:

alt text

3.1.2. 配置

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
en
conf t

int g0/0
ip add 10.0.0.1 255.255.255.252
no shu

int loop1
ip add 6.6.6.6 255.255.255.255

router bgp 65001
neighbor 10.0.0.2 remote-as 65002
! 开启MD5邻居身份认证
neighbor 10.0.0.2 password mkbk
net 6.6.6.6 mask 255.255.255.255

R2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
en
conf t

int g0/0
ip add 10.0.0.2 255.255.255.252
no shu

int loop1
ip add 8.8.8.8 255.255.255.255

router bgp 65002
neighbor 10.0.0.1 remote-as 65001
! 开启MD5邻居身份认证
neighbor 10.0.0.1 password mkbk
net 8.8.8.8 mask 255.255.255.255

3.1.3. 验证

  1. 查看路由表(show ip rou bgp):
    • R1:
      alt text
    • R2:
      alt text

3.2. 华为(eNSP)

参考:https://cloud.tencent.com/developer/article/2302390

3.2.1. 拓扑

3.1.1,R1和R2建立eBGP关系:

alt text

3.2.2. 配置

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sys

sysn R1

int g0/0/0
ip add 10.0.0.1 30

int loop1
ip add 6.6.6.6 32

bgp 65001
peer 10.0.0.2 as-number 65002
peer 10.0.0.2 password cipher mkbk
net 6.6.6.6 32

R1:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
sys

sysn R2

int g0/0/0
ip add 10.0.0.2 30

int loop1
ip add 8.8.8.8 32

bgp 65002
peer 10.0.0.1 as-number 65001
peer 10.0.0.1 password cipher mkbk
net 8.8.8.8 32

3.2.3. 验证

  1. 查看路由表(dis ip rou p bgp
    • R1: alt text
    • R2: alt text