拓扑
拓扑.png
R0
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#inter g0/0
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
Router(config-if)#exit
Router(config)#inter g0/0.1
Router(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0.1, changed state to up
Router(config-subif)#encapsulation dot1q 1
Router(config-subif)#ip add 192.168.10.1 255.255.255.0
Router(config-subif)#inter g0/0.2
Router(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0.2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0.2, changed state to up
Router(config-subif)#encapsulation dot1q 2
Router(config-subif)#ip add 192.168.20.1 255.255.255.0
Router(config-subif)#exit
Router(config)#inter g0/1
Router(config-if)#no shut
Router(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
Router(config-if)#
Router(config-if)#
Router(config-if)#inter g0/1
Router(config-if)#ip add 10.98.10.2
% Incomplete command.
Router(config-if)#ip add 10.98.10.2 255.255.255.0
Router(config-if)#exit
Router(config)#router ospf 1
Router(config-router)#network 10.98.10.0 0.0.0.255 area 0
Router(config-router)#exit
Router(config)#
00:18:22: %OSPF-5-ADJCHG: Process 1, Nbr 10.98.10.1 on GigabitEthernet0/1 from LOADING to FULL, Loading Done
Router(config)#
Router(config)#access-list 1 permit 192.168.10.0 0.0.0.255
Router(config)#access-list 1 permit 192.168.20.0 0.0.0.255
Router(config)#ip nat inside source list 1 inter g0/1 overload
Router(config)#inter g0/0
Router(config-if)#ip nat inside
Router(config-if)#inter g0/1
Router(config-if)#ip nat outside
Router(config-if)#exit
Router(config)#exit
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#show ip nat tran
Router#show ip nat tran
Router#show ip nat tran
Router#show ip nat tran
Router#show ip nat tran
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#inter g0/0.1
Router(config-subif)#ip nat inside
Router(config-subif)#inter g0/0.2
Router(config-subif)#ip nat inside
Router(config-subif)#exit
Router(config)#exit
Router#
%SYS-5-CONFIG_I: Configured from console by console
Router#show ip nat tran
Router#show ip nat tran
Pro Inside global Inside local Outside local Outside global
icmp 10.98.10.2:45 192.168.10.2:45 10.98.10.1:45 10.98.10.1:45
icmp 10.98.10.2:46 192.168.10.2:46 10.98.10.1:46 10.98.10.1:46
icmp 10.98.10.2:47 192.168.10.2:47 10.98.10.1:47 10.98.10.1:47
icmp 10.98.10.2:48 192.168.10.2:48 10.98.10.1:48 10.98.10.1:48
Router#
W1配置
Switch>en
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 1
Switch(config-vlan)#vlan 2
Switch(config-vlan)#
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch(config-vlan)#
Switch(config-vlan)#exit
Switch(config)#inter f0/1
Switch(config-if)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
Switch(config-if)#switchport trunk encap dot
Switch(config-if)#switchport mode trunk
Switch(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch(config-if)#exit
Switch(config)#inter f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 1
Switch(config-if)#inter f0/3
Switch(config-if)#switchport access vlan 2
Switch(config-if)#
W2配置
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 1
Switch(config-vlan)#exit
Switch(config)#inter f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 1
Switch(config-if)#inter f0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 1
Switch(config-if)#
W3配置
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 20
Switch(config-vlan)#vlan2
^
% Invalid input detected at '^' marker.
Switch(config-vlan)#vlan 2
Switch(config-vlan)#exit
Switch(config)#inter f0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config-if)#inter f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 20
Switch(config-if)#inter f0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#inter f0/2
Switch(config-if)#switchport mode access
Switch(config-if)#switchport access vlan 2
Switch(config-if)#
测试
nat测试.png
vlan1和vlan2访问.png
访问外网.png