拓扑图:
switch配置:
interface Ethernet0/0
switchport access vlan 10
duplex auto
!
interface Ethernet0/1
switchport access vlan 20
duplex auto
!
interface Ethernet0/2
switchport trunk encapsulation dot1q
switchport mode trunk
duplex auto
!
interface Ethernet0/3
switchport access vlan 30
duplex auto
!
interface Vlan1
no ip address
shutdown
!
!
ip forward-protocol nd
no ip http server
R1配置:
interface Ethernet0/0
no ip address
!
interface Ethernet0/0.1
encapsulation dot1Q 10
ip address 192.168.1.1 255.255.255.0
ip nat inside //注意,ip nat inside要应用于子接口上
ip virtual-reassembly in
!
interface Ethernet0/0.2
encapsulation dot1Q 20
ip address 192.168.2.1 255.255.255.0
ip nat inside
ip virtual-reassembly in
!
interface Ethernet0/0.3
encapsulation dot1Q 30
ip address 192.168.3.1 255.255.255.0
!
interface Ethernet0/1
ip address 8.8.8.8 255.255.255.0
ip nat outside
ip virtual-reassembly in
!
interface Ethernet0/2
no ip address
shutdown
!
interface Ethernet0/3
no ip address
shutdown
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
ip nat inside source list 100 interface Ethernet0/1 overload
ip route 0.0.0.0 0.0.0.0 8.8.8.9
!
access-list 100 permit ip 192.168.1.0 0.0.0.255 any
access-list 100 permit ip 192.168.2.0 0.0.0.255 any
!
!
!
control-plane
!
!
!
!
!
!
!
line con 0
logging synchronous
line aux 0
line vty 0 4
login
transport input all
!
!
end
R2配置:
interface Ethernet0/0
ip address 8.8.8.9 255.255.255.0
!
interface Ethernet0/1
no ip address
shutdown
!
interface Ethernet0/2
no ip address
shutdown
!
interface Ethernet0/3
no ip address
shutdown
!
ip forward-protocol nd
!
!
no ip http server
no ip http secure-server
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。