[r1]ospf 1 router-id 1.1.1.1 启用ospf
[r1-ospf-1]area 1 划分区域
[r1-ospf-1-area-0.0.0.1]network 12.1.1.1 0.0.0.0 宣告网段
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 1
[r2-ospf-1-area-0.0.0.1]network 12.1.1.2 0.0.0.0
[r2-ospf-1-area-0.0.0.1]network 23.1.1.1 0.0.0.0
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]network 23.1.1.2 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 123.1.1.1 0.0.0.0
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]area 0
[r4-ospf-1-area-0.0.0.0]network 123.1.1.2 0.0.0.0
[r4]interface LoopBack 0
[r4-LoopBack0]ip address 4.4.4.4 32 配置环回地址
[r4-ospf-1]area 2 划分区域
[r4-ospf-1-area-0.0.0.2]network 45.1.1.1 0.0.0.0
[r5]interface LoopBack 0
[r5-LoopBack0]ip address 5.5.5.5 32
[r5]ospf 1 router-id 5.5.5.5
[r5-ospf-1]area 2
[r5-ospf-1-area-0.0.0.2]network 45.1.1.2 0.0.0.0
[r5-ospf-1-area-0.0.0.2]network 5.5.5.5 0.0.0.0
[r5-ospf-1-area-0.0.0.2]network 56.1.1.1 0.0.0.0
[r5-ospf-1-area-0.0.0.0]network 123.1.1.4 0.0.0.0
[r6]interface LoopBack 0
[r6-LoopBack0]ip address 6.6.6.6 32
[r6]ospf 1 router-id 6.6.6.6
[r6-ospf-1]area 2
[r6-ospf-1-area-0.0.0.2]network 56.1.1.2 0.0.0.0
[r6-ospf-1-area-0.0.0.0]network 123.1.1.3 0.0.0.0
[r4]interface g0/0/1
[r4-GigabitEthernet0/0/1]ospf dr-priority 0 在接口修改r4的dr优先级,优先级为0,则不参加选举
[r6]interface g0/0/0
[r6-GigabitEthernet0/0/0]ospf dr-priority 0
[r5]interface g0/0/2
[r5-GigabitEthernet0/0/2]ospf dr-priority 0
加快收敛速度:
[r1]interface g0/0/0
[r1-GigabitEthernet0/0/0]ospf timer hello 5
[r1]interface g0/0/1
[r1-GigabitEthernet0/0/1]ospf timer hello 5
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ospf timer hello 5
[r2]interface g0/0/1
[r2-GigabitEthernet0/0/1]ospf timer hello 5
[r3]interface g0/0/0
[r3-GigabitEthernet0/0/0]ospf timer hello 5
[r3]interface g0/0/1
[r3-GigabitEthernet0/0/1]ospf timer hello 5
[r4]interface g0/0/1
[r4-GigabitEthernet0/0/1]ospf timer hello 5
[r4]interface g0/0/0
[r4-GigabitEthernet0/0/0]ospf timer hello 5
[r5]interface g0/0/1
[r5-GigabitEthernet0/0/1]ospf timer hello 5
[r5]interface g0/0/2
[r5-GigabitEthernet0/0/2]ospf timer hello 5
[r5]interface g0/0/0
[r5-GigabitEthernet0/0/0]ospf timer hello 5
[r6]interface g0/0/1
[r6-GigabitEthernet0/0/1]ospf timer hello 5
[r6]interface g0/0/0
[r6-GigabitEthernet0/0/0]ospf timer hello 5
不宣告r4环回地址,实现全网可达:
[r4-ospf-1]default-route-advertise always
[sw1]vlan 2 在交换机上添加vlan
[sw1]vlan 3
[sw1]interface e0/0/2 进入接口
[sw1-Ethernet0/0/2]port link-type access 将接口模式改为接入模式
[sw1-Ethernet0/0/2]port default vlan 2 将vlan 2 划入该接口
[sw1]interface e0/0/3
[sw1-Ethernet0/0/3]port link-type access
[sw1-Ethernet0/0/3]port default vlan 3
[sw1]interface e0/0/1
[sw1-Ethernet0/0/1]port link-type trunk 启用trunk干道
[sw1-Ethernet0/0/1]port trunk allow-pass vlan all 允许所有vlan通过
[r1]interface g0/0/1.1 创建虚拟子接口
[r1-GigabitEthernet0/0/1.1]ip address 192.168.1.1 24 给虚拟子接口配置IP地址
[r1]interface g0/0/1.2
[r1-GigabitEthernet0/0/1.2]ip address 192.168.2.1 24
[r1]dhcp enable 启用DHCP服务
[r1]ip pool 1 创建地址池
Info: It's successful to create an IP address pool.
[r1-ip-pool-1]network 192.168.1.0 mask 255.255.255.0 宣告要下放地址的网段
[r1-ip-pool-1]gateway-list 192.168.1.1 配置网关
[r1-ip-pool-1]dns-list 8.8.8.8 114.114.114.114 配置dns服务
[r1]interface g0/0/1.1 进入该接口
[r1-GigabitEthernet0/0/1.1]dhcp select global 在该接口启用全局dhcp
[r1]ip pool 2
Info: It's successful to create an IP address pool.
[r1-ip-pool-2]network 192.168.2.0 mask 255.255.255.0
[r1-ip-pool-2]gateway-list 192.168.2.1
[r1-ip-pool-2]dns-list 8.8.8.8 114.114.114.114
[r1]interface g0/0/1.2
[r1-GigabitEthernet0/0/1.2]dhcp select global
[r1-GigabitEthernet0/0/1.1]dot1q termination vid 2 在该接口启用trunk干道的dot1q封装模式
[r1-GigabitEthernet0/0/1.2]dot1q termination vid 3
[sw2]vlan 2
[sw2]vlan 3
[sw2]interface e0/0/2
[sw2-Ethernet0/0/2]port link-type access
[sw2-Ethernet0/0/2]port default vlan 2
[sw2]interface e0/0/3
[sw2-Ethernet0/0/3]port link-type access
[sw2-Ethernet0/0/3]port default vlan 3
[sw2]interface e0/0/1
[sw2-Ethernet0/0/1]port link-type trunk
[sw2-Ethernet0/0/1]port trunk allow-pass vlan all
[r2-GigabitEthernet0/0/2.1]dot1q termination vid 2
[r2-GigabitEthernet0/0/2.2]dot1q termination vid 3
area 1使用明文加密:
[r1]interface g0/0/0
[r1-GigabitEthernet0/0/0]ospf authentication-mode simple cipher 123
[r2]interface g0/0/0
[r2-GigabitEthernet0/0/0]ospf authentication-mode simple cipher 123
[r2]interface g0/0/1
[r2-GigabitEthernet0/0/1]ospf authentication-mode simple cipher 123
[r3]interface g0/0/0
[r3-GigabitEthernet0/0/0]ospf authentication-mode simple cipher 123
area 2使用密文加密:
[r4]interface g0/0/0
[r4-GigabitEthernet0/0/0]ospf authentication-mode simple cipher 123
[r4-GigabitEthernet0/0/0]ospf authentication-mode md5
[r5]interface g0/0/1
[r5-GigabitEthernet0/0/1]ospf authentication-mode simple cipher 123
[r5-GigabitEthernet0/0/1]ospf authentication-mode md5
[r5]interface g0/0/0
[r5-GigabitEthernet0/0/0]ospf authentication-mode simple cipher 123
[r5-GigabitEthernet0/0/0]ospf authentication-mode md5
[r5]interface g0/0/0
[r5-GigabitEthernet0/0/0]ospf authentication-mode simple cipher 123
[r5-GigabitEthernet0/0/0]ospf authentication-mode md5
汇总网段,减少路由条目:在边界路由器上汇总
[r3]ospf 1
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]abr-summary 192.168.0.0 255.255.252.0
[r3]ospf 1
[r3-ospf-1]area 1
[r3-ospf-1-area-0.0.0.1]abr-summary 172.16.0.0 255.255.252.0
在子接口启用arp广播功能:
[r1]interface g0/0/1.1
[r1-GigabitEthernet0/0/1.1]arp broadcast enable
[r1]interface g0/0/1.2
[r1-GigabitEthernet0/0/1.2]arp broadcast enable
[r2]interface g0/0/2.1
[r2-GigabitEthernet0/0/2.1]arp broadcast enable
[r2]interface g0/0/2.2
[r2-GigabitEthernet0/0/2.2]arp broadcast enable
宣告汇总后的网段:
[r1]ospf 1 router-id 1.1.1.1
[r1-ospf-1]area 1
[r1-ospf-1-area-0.0.0.1]network 192.168.0.0 0.0.255.255
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]area 1
[r2-ospf-1-area-0.0.0.1]network 172.16.0.0 0.0.255.255
用acl指令完成pc1 不能 ping pc4
[r1]acl 3000 高级acl
[r1-acl-adv-3000]rule deny icmp source 192.168.1.254 0.0.0.0 destination 172.16.
1.254 0.0.0.0
[r1-GigabitEthernet0/0/0.1]traffic-filter outbound acl 3000 在虚拟子接口激活高级acl
在r4上开启远程登录功能:
[r4]user-interface vty 0 4
[r4-ui-vty0-4]authentication-mode password
Please configure the login password (maximum length 16):1232
用高级acl完成r1不能远程登录r4,高级acl检查源目IP地址及上层协议,所以,在r3上写高级acl
[r2]acl 3000 在靠近源的地方r2上操作
[r2-acl-adv-3000]rule deny tcp source 12.1.1.1 0.0.0.0 destination 123.1.1.2 0.
0.0.0 destination-port eq 23
[r2-GigabitEthernet0/0/0]traffic-filter intbound acl 3000
ospf协议配置好后,测试是否全网可达
完成r1为r3456中的dr,没有bdr, 查看ospf邻居表
测试pc1能否ping pc4
用acl完成pc1不能ping pc4
r1可以远程登录r4
用acl完成r1不能telnet r4,但是能ping r4