组网技术(四)
1.动态路由BGP实验
1.1 BGP:边界网关协议,在自制系统AS之间选择最佳路由,距离矢量。支持多出口大型网络。路由采用增量更新。除了下一跳还有经过的AS列表通过信息。允许CIDR和VLSM,支持鉴别、验证等。分为EBGP(外部)和BGP(外部)。
第一步:配置R1到R4接口IP。
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]int g0/0/2
[R1-GigabitEthernet0/0/2]ip add 59.74.112.2 24
第二步:配置IBGP:R2、R3、R4如下配置
[R2]bgp 65009 //启动BGP及AS号
[R2-bgp]router-id 2.2.2.2 //配置BGP的RouterID
[R2-bgp]peer 9.1.1.2 as-number 65009 //配置BGP对等体
[R2-bgp]peer 9.1.3.2 as-number 65009
[R3]bgp 65009
[R3-bgp]router-id 3.3.3.3
[R3-bgp]peer 9.1.3.1 as-number 65009
[R3-bgp]peer 9.1.2.2 as-number 65009
[R3-bgp]quit
[R3]
[R4]bgp 65009
[R4-bgp]router-id 4.4.4.4
[R4-bgp]peer 9.1.1.1 as-number 65009
[R4-bgp]peer 9.1.2.1 as-number 65009
[R4-bgp]quit
第三步:配置EBGP:R1、R2如下配置。
[R1]bgp 65008
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 59.74.112.1 as-number 65009
[R2-bgp]peer 59.74.112.2 as-number 65008
第四步:配置R1发布路由,如下配置。
[R1-bgp]ipv4-family unicast //进入ipv4地址族视图
[R1-bgp-af-ipv4]network 172.16.60.0 255.255.255.0
[R1-bgp-af-ipv4]quit
[R1-bgp]
第五步:配置R2引入路由,如下配置。
> [R2-bgp]ipv4-family unicast [R2-bgp-af-ipv4]import-route
> direct //引入路由表
第六步:验证。
2.路由技术ACL实验
2.1 ACL:访问控制列表,可以根据源地址、目标地址、源端口、目标端口、协议信息对数据包进出过滤控制。
2.2 两个方向:入口inbound是指数据流进入路由器(进门)、出口outbound是指数据流从路由器流出(出门)。
2.3 两种动作:允许permit、拒绝deny
2.4 基本ACL:编号2000~2999
<Huawei>sys
[Huawei]sysname R1
[R1]
<R1>sys //进入系统视图
Enter system view, return user view with Ctrl+Z.
[R1]acl 2001 //配置编号
[R1-acl-basic-2001]rule permit source 172.16.10.3 0
[R1-acl-basic-2001]rule deny source 172.16.10.0 0.0.0.255
[R1-acl-basic-2001]description permit only 172.16.10.3 through //ACL列表
[R1-acl-basic-2001]
- ·基于ACL,基于源地址,放置到目的端路由。
2.5 基本ACL命名规则:编号2000~2999
acl命令[number可选] acl-number编号[匹配match-order排序{auto排序|config顺序}] acl
name acl-mane{basic|acl-number}[match-order{auto|config}]
<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]time-range working-time 8:00 to 18:00 working-day
[R1]acl name work-acl basic
[R1-acl-basic-work-acl]rule deny source 172.16.10.0 0.0.0.255 time-range working
-time
<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]acl 2001
[R1-acl-basic-2001]rule deny source 172.16.10.0 0.0.0.255 none-first-fragment
- ·善用Tab键补全命令和用?帮助命令
2.6 ACL几个重点知识:
① ACL执行原则:自上而下排序原则;先匹配原则(特例在前,其他在后);默认丢弃原则(deny any)
② 反掩码:0.0.0.0,单个主机,同host,如:192.168.1.1 0.0.0.0 = host 192.168.1.1
③ 反掩码:255.255.255.255,任意主机,同any,通常与0.0.0.0一起使用,例如:0.0.0.0 255.255.2555.255 = any
2.7 高级ACL:编号3000~3999
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]acl 3001
[R2-acl-adv-3001]rule permit icmp source 172.16.10.3 0 destination 172.16.20.0 0
.0.0.255
[R2]acl name deny-telnet
[R2-acl-adv-deny-telnet]rule deny tcp destination-port eq telnet source 172.16.1
0.3 0 destination 172.16.20.0 0.0.0.255
- ·高级ACL:基于目的,放置到源端的路由器。
2.8 高级ACL命令规则:编号3000~3999
2.9 高级ACL实验:限制用户在特定时间访问服务器。
要求:禁止销售部门在上班时间(8:00~18:00)访问工资查询服务器,财务部门不受限制,可以随时访问,如图:
第一步:配置IP、配置VLAN、VLANIF等
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R`
[R`]sysname R1
[R1]
[R1]
[R1]vlan batch 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[R1]int e0/0/1
[R1-Ethernet0/0/1]port link-type trunk
[R1-Ethernet0/0/1]port trunk allow-pass vlan 10
[R1-Ethernet0/0/1]quit
[R1]int vlanif 10
Jan 20 2021 18:16:18-08:00 R1 %%01IFNET/4/IF_STATE(l)[0]:Interface Vlanif10 has
turned into UP state.
[R1-Vlanif10]ip address 192.168.1.1 255.255.255.0
Jan 20 2021 18:17:01-08:00 R1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP
on the interface Vlanif10 has entered the UP state.
[R1-Vlanif10]quit
第二步:配置基于时间的ACL访问规则等。
#配置8:00至18:00的周期时间段
<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]
[R1]
[R1]time-range satime 8:00 to 18:00 working-day
#配置销售部门到工资查询服务器的访问规则
[R1]acl 3001
[R1-acl-adv-3001]rule deny ip source 192.168.1.0 0.0.0.255 destination 192.168.1
0.10 0.0.0.0 time-range satime
·Mon(周一)Tue(周二)Wed(周三)Thu(周四)Fri(周五)Sat(周六)Sun(周日)working-day(工作日:周一到周五)off-day(周末)daily(周一到周日)数字0-6(每周几)。
第三步:配置基于ACL的流分类策略。
<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]
#配置流分类c_xs,对匹配ACL3001的报文进行分类
[R1]traffic classifier c_xs
[R1-classifier-c_xs]if-match acl 3001
[R1-classifier-c_xs]quit
#配置流行为b_xs,动作为拒绝报文通过
[R1]traffic behavior b_xs
[R1-behavior-b_xs]deny
[R1-behavior-b_xs]quit
第四步:应用基于ACL的流策略
#配置流策略p_xs,将流分类c_xs与流行为b_xs关联
[R1]traffic policy p_xs
[R1-trafficpolicy-p_xs]classifier c_xs behavior b_xs
[R1-trafficpolicy-p_xs]quit
#由于销售部门访问服务器的流量从接口E0/0/1进入Router,所以可以在E0/0/1接口的方向应用流策略p_xs
[R1]int e0/0/1
[R1-Ethernet0/0/1]traffic-policy p_xs inbound
[R1-Ethernet0/0/1]quit