IP相关问题 --- BGP基础建邻+宣告实验

1.配置ip

1.R1配置ip

[r1]int lo0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1-LoopBack0]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24

2.R2配置ip

[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
Aug 11 2023 05:56:40-08:00 r2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r2-GigabitEthernet0/0/0]int lo0
[r2-LoopBack0]ip add 2.2.2.2 24
[r2-LoopBack0]int g0/0/1 
[r2-GigabitEthernet0/0/1]ip add 23.1.1.1 24
Aug 11 2023 05:57:30-08:00 r2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

3.R3配置ip

[r3]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 23.1.1.2 24
Aug 11 2023 05:59:21-08:00 r3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r3-GigabitEthernet0/0/0]int lo0
[r3-LoopBack0]ip add 3.3.3.3 24
[r3-LoopBack0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
Aug 11 2023 06:00:11-08:00 r3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

4.R4配置ip

r4]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 34.1.1.2 24
Aug 11 2023 06:01:25-08:00 r4 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[r4-GigabitEthernet0/0/0]int lo0
[r4-LoopBack0]ip add 4.4.4.4 24
[r4-LoopBack0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 45.1.1.1 24
Aug 11 2023 06:02:20-08:00 r4 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

5.R5配置ip

[r5]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 45.1.1.2 24
[r5-GigabitEthernet0/0/0]int lo0
[r5-LoopBack0]ip add 5.5.5.5 24

 

2.在R2 R3 R4上配置ospf 

1.在R2上宣告ospf

[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 0
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network 23.1.1.1 0.0.0.0

2.在R3上宣告ospf

[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]network 23.1.1.2 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 34.1.1.1 0.0.0.0

3.在R4上宣告ospf

[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 34.1.1.2 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0

4.在R3上查看情况

[r3]display ospf peer brief 

	 OSPF Process 1 with Router ID 3.3.3.3
		  Peer Statistic Information
 ----------------------------------------------------------------------------
 Area Id          Interface                        Neighbor id      State    
 0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
 0.0.0.0          GigabitEthernet0/0/1             4.4.4.4          Full        
 ----------------------------------------------------------------------------

3.配置BGP

1.R1与R2建立直连的EBGP

[r1]bgp 1 	
[r1-bgp]route-select
[r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 12.1.1.2 as-number 2


[r2]bgp 2
[r2-bgp]route-select
[r2-bgp]router-id 2.2.2.2	
[r2-bgp]peer 12.1.1.1 as-number 1
[r1]display tcp status
TCPCB    Tid/Soid Local Add:port        Foreign Add:port      VPNID  State
b4b56658 6  /1    0.0.0.0:23            0.0.0.0:0             23553  Listening
b4b56a24 164/1    0.0.0.0:179           12.1.1.2:0            0      Listening
b4b56b68 164/4    12.1.1.1:179          12.1.1.2:50130        0      Established
 Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State Pre
fRcv

  12.1.1.2        4           2        5        6     0 00:03:40 Established     0

 2.R2与R3建立IBGP

[r2]ping -a 2.2.2.2 3.3.3.3
  PING 3.3.3.3: 56  data bytes, press CTRL_C to break
    Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=50 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=255 time=10 ms

  --- 3.3.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/26/50 ms

[r2]bgp 2
[r2-bgp]peer 3.3.3.3 as	
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 connect-interface lo0


[r3]bgp 2	
[r3-bgp]route-select	
[r3-bgp]router-id 3.3.3.3 
[r3-bgp]peer 2.2.2.2 as-number 2
[r3-bgp]peer 2.2.2.2 connect-interface  lo0

[r2]display bgp peer

 BGP local router ID : 2.2.2.2
 Local AS number : 2
 Total number of peers : 2		  Peers in established state : 2

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State Pre
fRcv

  3.3.3.3         4           2        2        2     0 00:00:16 Established    0
  12.1.1.1        4           1       17       17     0 00:15:53 Established    0



3.R3与R4建立IBGP

[r3-bgp]peer 4.4.4.4 as-number 2	
[r3-bgp]peer 4.4.4.4 connect-interface lo0

[r4]bgp 2
[r4-bgp]router-id
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 3.3.3.3 as-number 2	
[r4-bgp]peer 3.3.3.3 connect-interface lo0

4.R4与R5建立EBGP(静态路由)

[r4]ip route-static 5.5.5.0 24 45.1.1.2
Aug 12 2023 22:36:28-08:00 r4 %%01IFPDT/4/IF_STATE(l)[0]:Interface GigabitEthern
et0/0/2 has turned into UP state.
[r4]ip route-static 5.5.5.0 24 54.1.1.2

[r5]ip route-static 4.4.4.0 24 45.1.1.1
[r5]ip route-static 4.4.4.0 24 54.1.1.1

[r5]ping -a 5.5.5.5 4.4.4.4
  PING 4.4.4.4: 56  data bytes, press CTRL_C to break
    Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=255 time=60 ms
    Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 4.4.4.4 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/28/60 ms

[r4]bgp 2
[r4-bgp]peer 5.5.5.5 as-number 3
[r4-bgp]peer 5.5.5.5 connect-interface lo0	
[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2

[r5]bgp 3
[r5-bgp]peer 4.4.4.4 as	
[r5-bgp]peer 4.4.4.4 as-number 2
[r5-bgp]peer 4.4.4.4 con	
[r5-bgp]peer 4.4.4.4 connect-interface lo0
[r5-bgp]peer 4.4.4.4 eb	
[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2

[r4]display bgp peer

 BGP local router ID : 4.4.4.4
 Local AS number : 2
 Total number of peers : 3		  Peers in established state : 3

  Peer            V          AS  MsgRcvd  MsgSent  OutQ  Up/Down       State Pre
fRcv

  2.2.2.2         4           2       38       38     0 00:36:01 Established    
   0
  3.3.3.3         4           2       39       39     0 00:37:32 Established    
   0
  5.5.5.5         4           3        2        5     0 00:00:12 Established    
   0





 4.在BGP上宣告环回

1.宣告R1上环回

[r1]bgp 1
[r1-bgp]network 1.1.1.0 24	
[r1]display bgp routing-table 
 Total Number of Routes: 1
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>   1.1.1.0/24         0.0.0.0         0                     0      i


针对R3 R4修改下一跳
[r2]bgp 2
[r2-bgp]peer 3.3.3.3 next-hop-local.
[r2-bgp]peer 4.4.4.4 next-hop-local

      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  1.1.1.0/24         2.2.2.2         0          100        0      1i
[r3]

    Network            NextHop        MED        LocPrf    PrefVal Path/Ogn

 *>i  1.1.1.0/24         2.2.2.2         0          100        0      1i
[r4]

2.宣告R2上环回

[r2]bgp 2
[r2-bgp]network 2.2.2.0 24

3.宣告R3上环回

[r3]bgp 2
[r3-bgp]net 3.3.3.0 24

4.宣告R4上环回

[r4]bgp 2
[r4-bgp]net	
[r4-bgp]network 4.4.4.0 24

5.测试结果

[r1]ping -a 1.1.1.1 2.2.2.2
  PING 2.2.2.2: 56  data bytes, press CTRL_C to break
    Reply from 2.2.2.2: bytes=56 Sequence=1 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=2 ttl=255 time=30 ms
    Reply from 2.2.2.2: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 2.2.2.2: bytes=56 Sequence=4 ttl=255 time=30 ms
    Reply from 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=10 ms

  --- 2.2.2.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/22/30 ms

[r1]ping -a 1.1.1.1 3.3.3.3
  PING 3.3.3.3: 56  data bytes, press CTRL_C to break
    Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=30 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=40 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=30 ms

  --- 3.3.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/28/40 ms


[r1]ping -a 1.1.1.1 4.4.4.4
  PING 4.4.4.4: 56  data bytes, press CTRL_C to break
    Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=253 time=60 ms
    Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=253 time=40 ms
    Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=253 time=40 ms
    Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=253 time=40 ms
    Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=253 time=30 ms

  --- 4.4.4.4 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/42/60 ms

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值