计算机网络
实验四:访问控制列表实验
问题:添加三个路由器,三台计算机,首先设置静态路由,并实验访问控制列表的设置
/****************路由器B基础设置****************/
<Quidway>system
Enter system view, return to user view with Ctrl+Z.
[Quidway]]interface ethernet0
[Quidway-Ethernet0]]ip address 10.65.1.2 255.255.0.0
[Quidway-Ethernet0]undo shutdown
//上面是对路由器的接口e0进行配置,设置了ip地址和子网掩码
[Quidway-Ethernet0]int e1
[Quidway-Ethernet1]ip address 10.66.1.2 255.255.0.0
[Quidway-Ethernet1]undo shutdown
//对接口e1进行了配置,设置了ip地址和子网掩码
[Quidway-Ethernet1]int s1
[Quidway-Serial1]ip address 10.68.1.2 255.255.0.0
[Quidway-Serial1]clock rate 64000
[Quidway-Serial1]undo shutdown
//对接口s1进行了配置,这里注意的是,自己设置了clock,这样就表示成功了,如果自己在这里不主动设置clock,那么即使在后面在系统的提示下设置clock,也不会成功
[Quidway-Serial1]quit
[Quidway]ip routing
[Quidway]ip route-static 10.69.0.0 255.255.0.0 10.68.1.1 (静态路由,下同)/*设置静态路由,说明到达10.69.0.0 网络的下一跳路由为10.68.1.1*/
[Quidway]ip route-static 10.65.0.0 255.255.0.0 10.68.1.2/*设置静态路由,说明到达10.65.0.0 网络的下一跳路由为10.68.1.2*/
/**********************路由器A基础设置*******************/
<Quidway>system
Enter system view, return to user view with Ctrl+Z.
[Quidway]interface ethernet0
[Quidway-Ethernet0]ip address 10.69.1.2 255.255.0.0
[Quidway-Ethernet0]undo shutdown
//对路由器的接口e0进行设置IP地址,子网掩码
[Quidway-Ethernet1]int s0
[Quidway-Serial0]ip address 10.78.1.1 255.255.0.0
[Quidway-Serial0]clock rate 64000
[Quidway-Serial0]undo shutdown
//对s0接口进行设置IP地址,子网掩码,同时设置clock
[Quidway-Serial0]quit
[Quidway]ip routing
[Quidway]ip route-static 10.65.0.0 255.255.0.0 10.78.1.2 (静态路由)
[Quidway]ip route-static 10.69.0.0 255.255.0.0 10.78.1.1
/**********************路由器C基础设置*******************/
router>system
Enter system view, return to user view with Ctrl+Z.
[Quidway]interface s0
[Quidway-Serial0]ip address 10.68.1.1 255.255.0.0
[Quidway-Serial0]undo shutdown
//对路由器c的s0接口进行设置IP地址,子网掩码
[Quidway-Serial0]int s1
[Quidway-Serial1]ip address 10.78.1.2 255.255.0.0
[Quidway-Serial1]undo shutdown
//对s1接口进行设置IP地址,子网掩码
[Quidway-Serial1]quit
[Quidway]ip routing
[Quidway]ip route-static 10.69.0.0 255.255.0.0 10.78.1.1(静态路由)
[Quidway]ip route-static 10.65.0.0 255.255.0.0 10.68.1.2
/********************主机A设置************************/
PCA login: root
password: linux
[root@PCA root]# ifconfig eth0 10.65.1.1 netmask 255.255.0.0
//设置A的ip地址
[root@PCA root]# route add default gw 10.65.1.2
//设置A的默认路由,相当于A入网,能和外界联系
证明:
/*******************主机B设置*************************/
PCC login: root
password: linux
[root@PCC root]# ifconfig eth0 10.69.1.1 netmask 255.255.0.0
//设置B的ip地址
[root@PCC root]# route add default gw 10.69.1.2
设置B的默认路由,相当于入网,能和外界联系
/*******************主机C设置*************************/
PCC login: root
password: linux
[root@PCC root]# ifconfig eth0 10.66.1.1 netmask 255.255.0.0
//设置C的IP地址
[root@PCC root]# route add default gw 10.66.1.2
//设置C的默认路由,相当于入网,能和外网
默认路由的作用:
[root@PCA root]#ping 10.69.1.1 通
根据:
路由器B [Quidway]ip route-static 10.69.0.0 255.255.0.0 10.68.1.1
路由器C [Quidway]ip route-static 10.69.0.0 255.255.0.0 10.78.1.1
主机B [root@PCB root]# route add default gw 10.69.1.2
[root@PCB root]#ping 10.69.1.1 通
对路由器C设置访问控制列表
[Quidway]firewall enable
[Quidway]firewall default permit
[Quidway]acl 10
[Quidway-acl-10]rule normal deny source 10.65.1.1 /*禁止源为10.65.1.1的访问*/
[Quidway-acl-10]rule normal permit soure any
[Quidway-acl-10]int s0
[Quidway-Serial0]firewall packet-filter 10 inbound
[Quidway-Serial0]quit
[Quidway]display acl
[root@PCA root]#ping 10.69.1.1 不通
因为[Quidway-acl-10]rule normal deny source 10.65.1.1 /*禁止源为10.65.1.1的访问*/
[root@PCB root]#ping 10.69.1.1通
更改路由器C设置
[Quidway]undo acl 10
[root@PCA root]#ping 10.69.1.1 通
[root@PCB root]#ping 10.69.1.1 通