实验拓扑图如下
首先第一步就是写路由及其环回地址
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.1.1.1/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 1.1.1.1/32 up up(s)
NULLO unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.1.1.2/24 up up
GigabitEthernet0/0/1 23.1.1.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 2.2.2.2/32 up up(s)
NULLO unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 23.1.1.2/24 up up
GigabitEthernet0/0/1 34.1.1.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 3.3.3.3/32 up up(s)
NULLO unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 34.1.1.2/24 up up
GigabitEthernet0/0/1 45.1.1.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 4.4.4.4/32 up up(s)
NULLO unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 45.1.1.2/24 up up
GigabitEthernet0/0/1 56.1.1.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 5.5.5.5/32 up up(s)
NULLO unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 56.1.1.2/24 up up
GigabitEthernet0/0/1 67.1.1.1/24 up up
GigabitEthernet0/0/2 unassigned down down
LoopBack0 6.6.6.6/32 up up(s)
NULLO unassigned up up(s)
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 67.1.1.2/24 up up
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
LoopBack0 7.7.7.7/32 up up(s)
NULLO unassigned up up(s)
宣告所有地址并r1 r7上写环回
[r1]rip 1
[r1-rip-1]version 2
[r1-rip-1]net
[r1-rip-1] network 12.0.0.0
[r1-rip-1]net
[r1-rip-1]network 1.0.0.0
[r1-rip-1]q
[r1]int
[r1]interface
[r1]interface lo1
[r1-LoopBack1]ip ad
[r1-LoopBack1]ip address 192.168.1.1 24
[r1-LoopBack1]q
[r1]int
[r1]interface lo2
[r1-LoopBack2]ip ad
[r1-LoopBack2]ip address 192.168.2.1 24
[r1-LoopBack2]q
[r1]rip 1
[r1-rip-1]version 2
[r1-rip-1]net
[r1-rip-1]network 192.168.1.0
[r1-rip-1]net
[r1-rip-1]network 192.168.2.0
[r1-rip-1]q
[r2]rip 1
[r2-rip-1]version 2
[r2-rip-1]net
[r2-rip-1]network 12.0.0.0
[r2-rip-1]net
[r2-rip-1]network 2.0.0.0
[r2-rip-1]q
[r3]ospf 1 ro
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 0
[r3-ospf-1-area-0.0.0.0]net
[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]net
[r3-ospf-1-area-0.0.0.0]network 34.1.1.1 0.0.0.0
[r3-ospf-1-area-0.0.0.0]q
[r3-ospf-1]q
[r4]ospf 1 rou
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]net
[r4-ospf-1-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[r5]ospf 1 rou
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 0
[r5-ospf-1-area-0.0.0.0]net
[r5-ospf-1-area-0.0.0.0]network 45.1.1.2 0.0.0.0
[r6]ospf 2 rou
[r6]ospf 2 router-id 6.6.6.6
[r6-ospf-2]area 0
[r6-ospf-2-area-0.0.0.0]net
[r6-ospf-2-area-0.0.0.0]network 67.1.1.1 0.0.0.0
[r6-ospf-2-area-0.0.0.0]net
[r6-ospf-2-area-0.0.0.0]network 6.6.6.6 0.0.0.0
[r6-ospf-2-area-0.0.0.0]q
[r7]ospf 2 rou
[r7]ospf 2 router-id 7.7.7.7
[r7-ospf-2]area 0
[r7-ospf-2-area-0.0.0.0]net
[r7-ospf-2-area-0.0.0.0]network 0.0.0.0 255.255.255.255
[r1-ospf-2-area-0.0.0.0]q
[r7-ospf-2]q
[r7]int
[r7]interface lo1
[r7-LoopBack1]ip ad
[r7-LoopBack1]ip address 172.16.1.1 24
[r7-LoopBack1]q
[r7]int
[r7]interface lo2
[r7-LoopBack2]ip ad
[r7-LoopBack2]ip address 172.16.2.1 24
[r7-LoopBack2]q
然后建立邻居关系
[r1]bgp 100
[r1-bgp]rou
[r1-bgp]route-select
[r1-bgp]router-id 1.1.1.1
[r1-bgp]pe
[r1-bgp]peer 2.2.2.2 as
[r1-bgp]peer 2.2.2.2 as-number 100
[r1-bgp]peer 2.2.2.2 co
[r1-bgp]peer 2.2.2.2 connect-interface lo 0
[r2]bgp 100
[r2-bgp]peer 1.1.1.1 as
[r2-bgp]peer 1.1.1.1 as-number 100
[r2-bgp]peer 1.1.1.1 co
[r2-bgp]peer 1.1.1.1 connect-interface 1o0
[r2-bgp]pe
[r2-bgp]peer 23.1.1.2
Jan 18 2024 18:49:54-08:00 r2 %%01BGP/3/STATE_CHG_UPDOWN(1)[0]:The status of the peer 1.1.1.1 changed from OPENCONFIRM to ESTABLISHED. (InstanceName=Public, Sta teChangeReason=Up)
[r2-bgp]peer 23.1.1.2 as
[r2-bgp]peer 23.1.1.2 as-number 101
[r2-bgp]pe
[r2-bgp]peer 23.1.1.2 co
[r2-bgp]peer 23.1.1.2 connect-interface lo0
[r2-bgp]undo pe
[r2-bgp] undo peer 23.1.1.2 co
[r2-bgp]undo peer 23.1.1.2 connect-interface
[r2-bgp]dis
[r2-bgp]display this
[V200R003C00]
#
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
peer 23.1.1.2 as-number 101
#
ipv4-family unicast
undo synchronization
peer 1.1.1.1 enable
peer 23.1.1.2 enable
[r3]bgp 101
[r3-bgp]rou
[r3-bgp]route-select
[r3-bgp]router-id 3.3.3.3
[r3-bgp]pe
[r3-bgp]peer 23.1.1.1 as
[r3-bgp]peer 23.1.1.1 as-number 100
[r3-bgp]pe
[r3-bgp]peer 4.4.4.4 as
[r3-bgp]peer 4.4.4.4 as-number 101
[r3-bgp]pe
[r3-bgp]peer 4.4.4.4 co
[r3-bgp]peer 4.4.4.4 connect-interface lo0
[r5]bgp 101
[r5-bgp]rou
[r5-bgp]route-select
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 3.3.3.3 as
[r5-bgp]peer 3.3.3.3 as-number 101
[r5-bgp]pe
[r5-bgp]peer 3.3.3.3 co
[r5-bgp]peer 3.3.3.3 connect-interface lo0
[r5-bgp]pe
[r5-bgp]peer 56.1.1.2 as
[r5-bgp]peer 56.1.1.2 as-number 102
[r5-bgp]pe
[r6]bgp 102
[r6-bgp]rou
[r6-bgp]route-select
[r6-bgp]router-id 6.6.6.6
[r6-bgp]pe
[r6-bgp]peer 56.1.1.1 as
[r6-bgp]peer 56.1.1.1 as-number 101
[r6-bgp]pe
[r6-bgp]peer 7.7.7.7 as
[r6-bgp]peer 7.7.7.7 as-number 102
[r6-bgp]pe
[r6-bgp]peer 7.7.7.7 co
[r6-bgp]peer 7.7.7.7 connect-interface lo0
[r7]bgp 102
[r7-bgp]rou
[r7-bgp]route-select
[r7-bgp]router-id 7.7.7.7
[r7-bgp]peer 6.6.6.6 as
[r7-bgp]peer 6.6.6.6 as-number 102
[r7-bgp]pe
[r7-bgp]peer 6.6.6.6 co
[r7-bgp]peer 6.6.6.6 connect-interface lo0
最后做重发布
[r2 ]bgp 100
[r2-bgp]im
[r2-bgp]import-route rip 1
[r3]bgp 101
[r3-bgp]im
[r3-bgp]import-route ospf 1
[r5]bgp 101
[r5-bgp]im
[r5-bgp]import-route ospf 1
[r6]bgp 102
[r6-bgp]im
[r6-bgp]import-route ospf 2
实验结束