闲着无聊随便做些实验,如果有妥之处,请各位指出!
 
 
思路是这样,很简单:自动获得IP,划分sw1/2/3/4分别划到4个vlan中,通过nat访问外部。
主要是在r1,和sww1上做配置,其他都可以当摆设了。
 
R1:r1#show ru
r1#show running-config
Building configuration...
Current configuration : 1620 bytes
!
version 12.4
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname r1
!
!
!
!
ip dhcp excluded-address 192.168.20.1
ip dhcp excluded-address 192.168.30.1
ip dhcp excluded-address 192.168.40.1
ip dhcp excluded-address 192.168.50.1
!
ip dhcp pool oo
ip dhcp pool vlan2
 network 192.168.20.0 255.255.255.0
 default-router 192.168.20.1
ip dhcp pool vlan3
 network 192.168.30.0 255.255.255.0
 default-router 192.168.30.1
ip dhcp pool vlan4
 network 192.168.40.0 255.255.255.0
 default-router 192.168.40.1
ip dhcp pool vlan5
 network 192.168.50.0 255.255.255.0
 default-router 192.168.50.1
!
!
!
!
!
!
!
no ip domain-lookup
!
!
!
!
!
!
interface FastEthernet0/0
 no ip address
 ip nat inside
 duplex auto
 speed auto
!
interface FastEthernet0/0.2
 encapsulation dot1Q 2
 ip address 192.168.20.1 255.255.255.0
 ip nat inside
!
interface FastEthernet0/0.3
 encapsulation dot1Q 3
 ip address 192.168.30.1 255.255.255.0
 ip nat inside
!
interface FastEthernet0/0.4
 encapsulation dot1Q 4
 ip address 192.168.40.1 255.255.255.0
 ip nat inside
!
interface FastEthernet0/0.5
 encapsulation dot1Q 5
 ip address 192.168.50.1 255.255.255.0
 ip nat inside
!
interface FastEthernet0/1
 ip address 12.1.1.1 255.255.255.0
 ip nat outside
 duplex auto
 speed auto
!
interface Vlan1
 no ip address
 shutdown
!
ip nat inside source list 10 interface FastEthernet0/1 overload
ip classless
ip route 0.0.0.0 0.0.0.0 FastEthernet0/1
!
!
access-list 10 permit 192.168.0.0 0.0.255.255
!
!
!
!
!
line con 0
 exec-timeout 0 0
 logging synchronous
line vty 0 4
 login
!
!
!
end
 
 
 
 
 
SWW1:
sww1#show ru
sww1#show running-config
Building configuration...
Current configuration : 1289 bytes
!
version 12.2
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname sww1
!
no ip domain-lookup
!
!
interface FastEthernet0/1
 switchport mode trunk
!
interface FastEthernet0/2
 switchport access vlan 2
 switchport mode access
!
interface FastEthernet0/3
 switchport access vlan 3
 switchport mode access
!
interface FastEthernet0/4
 switchport access vlan 4
 switchport mode access
!
interface FastEthernet0/5
 switchport access vlan 5
 switchport mode access
!
interface FastEthernet0/6
!
interface FastEthernet0/7
!
interface FastEthernet0/8
!
interface FastEthernet0/9
!
interface FastEthernet0/10
!
interface FastEthernet0/11
!
interface FastEthernet0/12
!
interface FastEthernet0/13
!
interface FastEthernet0/14
!
interface FastEthernet0/15
!
interface FastEthernet0/16
!
interface FastEthernet0/17
!
interface FastEthernet0/18
!
interface FastEthernet0/19
!
interface FastEthernet0/20
!
interface FastEthernet0/21
!
interface FastEthernet0/22
!
interface FastEthernet0/23
!
interface FastEthernet0/24
!
interface GigabitEthernet1/1
!
interface GigabitEthernet1/2
!
interface Vlan1
 no ip address
 shutdown
!
!
line con 0
 logging synchronous
 exec-timeout 0 0
!
line vty 0 4
 login
line vty 5 15
 login
!
!
end
sww1# show vlan brief
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa0/6, Fa0/7, Fa0/8, Fa0/9
                                                Fa0/10, Fa0/11, Fa0/12, Fa0/13
                                                Fa0/14, Fa0/15, Fa0/16, Fa0/17
                                                Fa0/18, Fa0/19, Fa0/20, Fa0/21
                                                Fa0/22, Fa0/23, Fa0/24, Gig1/1
                                                Gig1/2
2    VLAN0002                         active    Fa0/2
3    VLAN0003                         active    Fa0/3
4    VLAN0004                         active    Fa0/4
5    VLAN0005                         active    Fa0/5
1002 fddi-default                     active   
1003 token-ring-default               active   
1004 fddinet-default                  active   
1005 trnet-default                    active   
 
 
 
下面是自动获得的ip地址;
PC1和PC2的,其他都一样就不上图了
 
 
那些DNS和一些其他的时间都没有设置,反正都很简单的。
下面是查看nat的
 
想要的结果都完成了,以后没事在发发其他的,呵呵
 
第一次哦,肯定不是太好了