实验目的:
(一)禁止pc3上网,其他局域网内主机不受影响。pc2pc3pc4都在不同的子网里。
(二)使局域网内所有主机都能上网。(只有一个公网地址)
(三)局域网内所有主机ip地址均自动获取。
(四)r1提供单臂路由和dhcp功能,实现vlan间通信
(五)两个交换机一个为vtp server,另一个为vtp client,vtp有密码.交换机之间做端口汇聚。
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

 

  r1的公网地址219.146.0.1 255.255.255.248

 

        r2的公网地址219.146.0.2 255.255.255.248

 

        r1r2之间有chap认证。

 

实验步骤:
1、交换机S1S2之间的连线用trunk线相连!且千万要注意R1S1的连线中
F0/2的一端也要用trunk线!
2、路由器担当重要的责任!
   局域网内所有主机ip地址均自动获取:需要在r1设置!
   首先要进入路由器R1F0/0 端口,根据题意“r1提供单臂路由和dhcp
能”,做如下设置:
interface FastEthernet0/0.2(对应交换机S1创建的vlan 2
 encapsulation dot1Q 2
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.3(对应交换机S1创建的vlan 3
 encapsulation dot1Q 3
 ip address 192.168.2.1 255.255.255.0
 ip access-group 101 in
!
interface FastEthernet0/0.4(对应交换机S1创建的vlan 4
 encapsulation dot1Q 4
 ip address 192.168.3.1 255.255.255.0
  
 ip dhcp pool v2
 network 192.168.1.0 255.255.255.0
 default-router 192.168.1.1
 ip dhcp excluded-address 192.168.1.1(指定不分发的ip地址!)
 ip dhcp pool v3
 network 192.168.2.0 255.255.255.0
 default-router 192.168.2.1
 ip dhcp excluded-address 192.168.1.1 (指定不分发的ip地址!)

 

 ip dhcp pool v4
 network 192.168.3.0 255.255.255.0
 default-router 192.168.3.1
 ip dhcp excluded-address 192.168.1.1(指定不分发的ip地址!)

 

3、交换机S1做如下配置:
vlan 2 name aaavlan 3 name bbb vlan 4 name ccc
vtp mode server
vtp version 2
vtp domain haiyang
vtp password cisco
并将F0/1放入vlan 2中!
4、交换机S2做如下配置:
vtp mode client
vtp version 2
vtp domain haiyang
vtp password cisco
并将F0/1放入vlan 3,F0/2放入vlan 4中!
5、端口汇聚的配置是:
分别在交换机S1S2中做如下配置:
int range f0/23-24
channel-group 1 mode on即可!
6、对于R1R2之间的连接,我不做过多解释,将路由器R1R2show run信息列出:
路由器R1:
!
hostname r1
username r2 password 0 cisco
interface FastEthernet0/0.2
 encapsulation dot1Q 2
 ip address 192.168.1.1 255.255.255.0
!
interface FastEthernet0/0.3
 encapsulation dot1Q 3
 ip address 192.168.2.1 255.255.255.0
 ip access-group 101 in
!
interface FastEthernet0/0.4
 encapsulation dot1Q 4
 ip address 192.168.3.1 255.255.255.0
!
interface Serial0/0/0
 ip address 219.146.0.1 255.255.255.248
 encapsulation ppp
 ppp authentication chap
 clock rate 64000
!
router eigrp 100
 network 219.146.0.0
 network 192.168.1.0
 network 192.168.2.0
 network 192.168.3.0
!
access-list 101 deny tcp 192.168.2.0 0.0.0.255 any eq www
access-list 101 permit ip any any
!
ip dhcp excluded-address 192.168.1.1
ip dhcp excluded-address 192.168.2.1
ip dhcp excluded-address 192.168.3.1
!
ip dhcp pool v2
 network 192.168.1.0 255.255.255.0
 default-router 192.168.1.1
ip dhcp pool v3
 network 192.168.2.0 255.255.255.0
 default-router 192.168.2.1
ip dhcp pool v4
 network 192.168.3.0 255.255.255.0
 default-router 192.168.3.1
路由器R2:
hostname r2
!
username r1 password 0 cisco
!
interface FastEthernet0/0
 ip address 192.168.4.1 255.255.255.0
 ip nat inside

 duplex auto
 speed auto
!
interface Serial0/0/0
 ip address 219.146.0.2 255.255.255.248
 encapsulation ppp
 ip nat outside

router eigrp 100
 network 219.146.0.0
 network 192.168.0.0
 network 192.168.4.0
!
ip nat inside source static tcp 192.168.4.2 80 219.146.0.2 80(将服务器与公网绑定!)