Nên xem bài cấu hình căn bản trước xem bài này
Sơ đồ LAB:
STT | Tên Thiết Bị | Interface | IP Address | Subnet Mask | Gateway/Default Route |
---|---|---|---|---|---|
1 | Internet | Lookback 8 | 8.8.8 | 255.0.0.0 | |
Et0/0 | 200.1.1.1 | 255.255.255.252 | |||
2 | ISP-Router | Et0/0 | 200.1.1.2 | 255.255.255.0 | 200.1.1.1 |
Et0/1 | 125.234.102.241 | 255.255.255.248 | |||
3 | Firewall | Et0/1 | 125.234.102.243 | 255.255.255.248 | 125.234.102.241 |
Et0/1 | 192.168.200.1 | 255.255.255.0 | |||
4 | Core | Et0/1 | 192.168.200.2 | 255.255.255.0 | 192.168.200.1 |
Vlan100 | 192.168.100.254 | 255.255.255.0 | |||
Vlan101 | 192.168.101.254 | 255.255.255.0 | |||
Vlan102 | 192.168.102.254 | 255.255.255.0 | |||
Vlan103 | 192.168.103.254 | 255.255.255.0 | |||
5 | DHCP Server | Vlan100 | 192.168.100.100 | 255.255.255.0 | 192.168.100.254 |
6 | PC1 | Eth0 | 192.168.101.101 | 255.255.255.0 | 192.168.101.254 |
7 | PC2 | Eth0 | 192.168.102.102 | 255.255.255.0 | 192.168.102.254 |
8 | PC3 | Eth0 | DHCP | ||
9 | PC3 | Eth0 | DHCP |
YÊU CẦU:
- Tạo các vlan 101, 102,103 và thực hiện đặt IP theo sơ đồ
- Tạo vlan 500 và gán port Et0/2, Et0/3 vào vlan 500
- Đặt IP Address và Default Route như sơ đồ
- Cấu hình các pool DHCP cho vlan 101, 102, 103
- Vlan 103 chỉ cấp DHCP trong khoảng từ 192.168.103.104 đến 192.168.103.253
- Tạo vlan 100, đặt ip cho vlan 100 theo sơ đồ, gán port Et0/0 vào vlan 100
- Cấu hình dhcp relay agent cho vlan 101,102,103 đảm bảo các PC trong các vlan có thể lấy được địa chỉ IP do DHCP_Server 192.168.100.100 cấp
THỰC HIỆN:
1. Đặt IP theo sơ đồ- Internet:
conf thostname Internetinterface Loopback8no shutdownip address 8.8.8.8 255.0.0.0exitinterface et0/0ip address 200.1.1.1 255.255.255.252no shendwri
- ISP-Router:
conf thostname ISP-Routerinterface et0/0ip address 200.1.1.2 255.255.255.252no shexitinterface et0/1ip address 125.234.102.241 255.255.255.248no shendwri
- Firewall:
conf thostname Firewallinterface et0/2ip address 125.234.102.243 255.255.255.248no shexitinterface et0/1ip address 192.168.200.1 255.255.255.248no shendwri
- Switch Core/Layer3:
conf thostname Coreinterface et0/1no switchportip address 192.168.200.2 255.255.255.248no shendwri
- Tạo các vlan 101, 102,103 và thực hiện đặt IP theo sơ đồ
conf tvlan 101int vlan 101ip address 192.168.101.254 255.255.255.0no shexitvlan 102int vlan 102ip address 192.168.102.254 255.255.255.0no shexitvlan 103int vlan 103ip address 192.168.103.254 255.255.255.0no shendwri
- Tạo vlan 500 và gán port Et0/2, Et0/3 vào vlan 500
conf tvlan 500exitint et0/2sw mode accesssw acc vlan 500exitint et0/3sw mode accesssw acc vlan 500endwri
- Cấu hình
conf tint et1/1switchport trunk encapsulation dot1qswitchport mode trunkswitchport trunk allowed vlan allendwri
conf thostname Acc01in et0/0switchport trunk encapsulation dot1qswitchport mode trunkswitchport trunk allowed vlan allendwri
- Kiểm tra:
Core#show interfaces trunkPort Mode Encapsulation Status Native vlanEt1/1 on 802.1q trunking 1Port Vlans allowed on trunkEt1/1 1-4094Port Vlans allowed and active in management domainEt1/1 1,100-103,500Port Vlans in spanning tree forwarding state and not prunedEt1/1 1,100-103,500Core#
Acc01#show interfaces trunkPort Mode Encapsulation Status Native vlanEt0/0 on 802.1q trunking 1Port Vlans allowed on trunkEt0/0 1-4094Port Vlans allowed and active in management domainEt0/0 1,101-102Port Vlans in spanning tree forwarding state and not prunedEt0/0 1,101-102Acc01#
- Cấu hình:
conf tvlan 101vlan 102exitint et0/1sw mode accesssw acc vlan 101exitint et0/2sw mode accesssw acc vlan 102endwri
- Kiểm tra:
Acc01#show vlanVLAN Name Status Ports---- -------------------------------- --------- -------------------------------1 default active Et0/3101 VLAN0101 active Et0/1102 VLAN0102 active Et0/21002 fddi-default act/unsup1003 token-ring-default act/unsup1004 fddinet-default act/unsup1005 trnet-default act/unsup
PC1> ping 192.168.102.10284 bytes from 192.168.102.102 icmp_seq=1 ttl=63 time=1.830 ms84 bytes from 192.168.102.102 icmp_seq=2 ttl=63 time=1.349 ms84 bytes from 192.168.102.102 icmp_seq=3 ttl=63 time=2.090 ms84 bytes from 192.168.102.102 icmp_seq=4 ttl=63 time=1.659 ms84 bytes from 192.168.102.102 icmp_seq=5 ttl=63 time=1.987 msPC1>
PC2> ping 192.168.101.10184 bytes from 192.168.101.101 icmp_seq=1 ttl=63 time=2.088 ms84 bytes from 192.168.101.101 icmp_seq=2 ttl=63 time=1.770 ms84 bytes from 192.168.101.101 icmp_seq=3 ttl=63 time=1.893 ms84 bytes from 192.168.101.101 icmp_seq=4 ttl=63 time=1.721 ms84 bytes from 192.168.101.101 icmp_seq=5 ttl=63 time=1.349 msPC2>
5. Tương tự cấu hình trunk trên cổng đấu nối giữa Core switch và Acc02; trên Acc02 tạo vlan 102, 103; gán port Et0/2 vào vlan 102 và port Et0/3 vào vlan 103.
- Cấu hình trunk
conf tint et1/2switchport trunk encapsulation dot1qswitchport mode trunkswitchport trunk allowed vlan allendwri
conf thostname Acc02in et0/0switchport trunk encapsulation dot1qswitchport mode trunkswitchport trunk allowed vlan allendwri
- Gán port vào vlan
conf tvlan 102vlan 103exitint et0/2sw mode accesssw acc vlan 102exitint et0/3sw mode accesssw acc vlan 103endwri
- Kiểm tra trên Acc02:
Acc02#show interfaces trunkPort Mode Encapsulation Status Native vlanEt0/0 on 802.1q trunking 1Port Vlans allowed on trunkEt0/0 1-4094Port Vlans allowed and active in management domainEt0/0 1,102-103Port Vlans in spanning tree forwarding state and not prunedEt0/0 1,102-103Acc02#
Acc02#show vlanVLAN Name Status Ports---- -------------------------------- --------- -------------------------------1 default active Et0/1102 VLAN0102 active Et0/2103 VLAN0103 active Et0/31002 fddi-default act/unsup1003 token-ring-default act/unsup1004 fddinet-default act/unsup1005 trnet-default act/unsup{...}Acc02#
- Đặt IP Address và Default Route như sơ đồ
conf thostname DHCP_Serverint et0/0ip address 192.168.100.100 255.255.255.0no shexitip route 0.0.0.0 0.0.0.0 192.168.100.254endwri
- Cấu hình các pool DHCP cho vlan 101, 102, 103
conf tip dhcp pool vlan_101network 192.168.101.0 255.255.255.0dns-server 8.8.8.8default-router 192.168.101.254lease 0 0 10exitip dhcp pool vlan_102network 192.168.102.0 255.255.255.0dns-server 8.8.8.8default-router 192.168.102.254lease 0 0 10exitip dhcp pool vlan_103network 192.168.103.0 255.255.255.0dns-server 8.8.8.8default-router 192.168.103.254lease 0 0 10endwri
Noted: Ở đây chúng tôi lấy router của cisco làm DHCP server, các bạn cũng có thể thay thế bằng Windows, Linux, ...
- Vlan 103 chỉ cấp DHCP trong khoảng từ 192.168.103.104 đến 192.168.103.253
conf tip dhcp excluded-address 192.168.103.1 192.168.103.103ip dhcp excluded-address 192.168.103.254endwri
- Tạo vlan 100, đặt ip cho vlan 100 theo sơ đồ, gán port Et0/0 vào vlan 100
conf tvlan 100int vlan 100ip address 192.168.100.254 255.255.255.0no shexitint et0/0sw mode accesssw acc vlan 100endwri
- Cấu hình dhcp relay agent cho vlan 101,102,103 đảm bảo các PC trong các vlan có thể lấy được địa chỉ IP do DHCP_Server 192.168.100.100 cấp
conf tint vlan 101ip helper-address 192.168.100.100int vlan 102ip helper-address 192.168.100.100int vlan 103ip helper-address 192.168.100.100endwri
PC3> ip dhcpDDORA IP 192.168.102.1/24 GW 192.168.102.254PC3>
PC4> ip dhcpDDORA IP 192.168.103.104/24 GW 192.168.103.254PC4>
DHCP_Server#show ip dhcp bindingBindings from all pools not associated with VRF:IP address Client-ID/ Lease expiration TypeHardware address/User name192.168.102.1 0100.5079.6668.03 Jun 07 2021 06:19 AM Automatic192.168.103.104 0100.5079.6668.04 Jun 07 2021 06:16 AM AutomaticDHCP_Server#
- Cấu hình:
conf tip route 125.234.102.240 255.255.255.248 200.1.1.2endwri
- Kiểm tra:
Internet#show ip route staticCodes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGPD - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter areaN1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2E1 - OSPF external type 1, E2 - OSPF external type 2i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2ia - IS-IS inter area, * - candidate default, U - per-user static routeo - ODR, P - periodic downloaded static route, H - NHRP, l - LISPa - application route+ - replicated route, % - next hop overrideGateway of last resort is not set125.0.0.0/29 is subnetted, 1 subnetsS 125.234.102.240 [1/0] via 200.1.1.2Internet#
9. Tạo các default route và thực hiện NAT trên overload trên Firewall đảm bảo tất cả các PC có thể ping được 8.8.8.8
- Tạo default route:
conf tip route 0.0.0.0 0.0.0.0 200.1.1.1endwri
conf tip route 0.0.0.0 0.0.0.0 125.234.102.241endwri
conf tip route 0.0.0.0 0.0.0.0 192.168.200.1endwri
- NAT overload trên Firewall:
conf tinterface Ethernet0/1ip nat insideexitinterface Ethernet0/2ip nat outsideexitip nat inside source list 1 interface Ethernet0/2 overloadaccess-list 1 permit anyaccess-list 1 deny anyendwri
conf t
ip route 192.168.100.0 255.255.255.0 192.168.200.2
ip route 192.168.101.0 255.255.255.0 192.168.200.2
ip route 192.168.102.0 255.255.255.0 192.168.200.2
ip route 192.168.103.0 255.255.255.0 192.168.200.2
end
wri
- Kiểm tra:
PC3> ping 8.8.8.884 bytes from 8.8.8.8 icmp_seq=1 ttl=252 time=2.684 ms84 bytes from 8.8.8.8 icmp_seq=2 ttl=252 time=3.233 ms84 bytes from 8.8.8.8 icmp_seq=3 ttl=252 time=2.536 ms84 bytes from 8.8.8.8 icmp_seq=4 ttl=252 time=2.128 ms84 bytes from 8.8.8.8 icmp_seq=5 ttl=252 time=2.252 msPC3>
PC4> ping 8.8.8.884 bytes from 8.8.8.8 icmp_seq=1 ttl=252 time=3.107 ms84 bytes from 8.8.8.8 icmp_seq=2 ttl=252 time=3.087 ms84 bytes from 8.8.8.8 icmp_seq=3 ttl=252 time=2.000 ms84 bytes from 8.8.8.8 icmp_seq=4 ttl=252 time=2.140 ms84 bytes from 8.8.8.8 icmp_seq=5 ttl=252 time=2.865 msPC4>
- Kiểm tra bảng NAT trên Firewall:
Firewall#show ip nat translationsPro Inside global Inside local Outside local Outside globalicmp 125.234.102.243:13030 192.168.102.1:13030 8.8.8.8:13030 8.8.8.8:13030icmp 125.234.102.243:13286 192.168.102.1:13286 8.8.8.8:13286 8.8.8.8:13286icmp 125.234.102.243:13542 192.168.102.1:13542 8.8.8.8:13542 8.8.8.8:13542icmp 125.234.102.243:13798 192.168.102.1:13798 8.8.8.8:13798 8.8.8.8:13798icmp 125.234.102.243:14054 192.168.102.1:14054 8.8.8.8:14054 8.8.8.8:14054icmp 125.234.102.243:10470 192.168.103.104:10470 8.8.8.8:10470 8.8.8.8:10470icmp 125.234.102.243:10726 192.168.103.104:10726 8.8.8.8:10726 8.8.8.8:10726icmp 125.234.102.243:10982 192.168.103.104:10982 8.8.8.8:10982 8.8.8.8:10982icmp 125.234.102.243:11238 192.168.103.104:11238 8.8.8.8:11238 8.8.8.8:11238icmp 125.234.102.243:11494 192.168.103.104:11494 8.8.8.8:11494 8.8.8.8:11494Firewall#
- Internet
- ISP-Router
- Firewall
- Core
- DHCP Server
- Acc01
- Acc02
conf t
hostname Internet
interface Loopback8
no shutdown
ip address 8.8.8.8 255.0.0.0
exit
interface et0/0
ip address 200.1.1.1 255.255.255.252
no sh
exit
ip route 125.234.102.240 255.255.255.248 200.1.1.2
end
wri
conf t
hostname ISP-Router
interface et0/0
ip address 200.1.1.2 255.255.255.252
no sh
exit
interface et0/1
ip address 125.234.102.241 255.255.255.248
exit
ip route 0.0.0.0 0.0.0.0 200.1.1.1
no sh
end
wri
conf t
hostname Firewall
interface et0/2
ip address 125.234.102.243 255.255.255.248
no sh
exit
interface et0/1
ip address 192.168.200.1 255.255.255.248
no sh
exit
interface Ethernet0/1
ip nat inside
interface Ethernet0/2
ip nat outside
ip nat inside source list 1 interface Ethernet0/2 overload
ip route 0.0.0.0 0.0.0.0 125.234.102.241
ip route 192.168.100.0 255.255.255.0 192.168.200.2
ip route 192.168.101.0 255.255.255.0 192.168.200.2
ip route 192.168.102.0 255.255.255.0 192.168.200.2
ip route 192.168.103.0 255.255.255.0 192.168.200.2
access-list 1 permit any
access-list 1 deny any
end
wri
conf t
hostname Core
interface Ethernet0/1
no switchport
ip address 192.168.200.2 255.255.255.248
no sh
exit
vlan 100
vlan 101
vlan 102
vlan 103
vlan 500
exit
interface Ethernet0/0
switchport mode access
switchport access vlan 100
exit
interface Ethernet0/2
switchport mode access
switchport access vlan 500
exit
interface Ethernet0/3
switchport mode access
switchport access vlan 500
exit
interface Vlan100
ip address 192.168.100.254 255.255.255.0
exit
interface Vlan101
ip address 192.168.101.254 255.255.255.0
ip helper-address 192.168.100.100
exit
interface Vlan102
ip address 192.168.102.254 255.255.255.0
ip helper-address 192.168.100.100
exit
interface Vlan103
ip address 192.168.103.254 255.255.255.0
ip helper-address 192.168.100.100
exit
interface Ethernet1/1
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan all
exit
interface Ethernet1/2
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan all
exit
ip route 0.0.0.0 0.0.0.0 192.168.200.1
end
wri
conf t
hostname DHCP_Server
int et0/0
ip address 192.168.100.100 255.255.255.0
no sh
exit
ip route 0.0.0.0 0.0.0.0 192.168.100.254
ip dhcp pool vlan_101
network 192.168.101.0 255.255.255.0
dns-server 8.8.8.8
default-router 192.168.101.254
lease 0 0 10
exit
ip dhcp pool vlan_102
network 192.168.102.0 255.255.255.0
dns-server 8.8.8.8
default-router 192.168.102.254
lease 0 0 10
exit
ip dhcp pool vlan_103
network 192.168.103.0 255.255.255.0
dns-server 8.8.8.8
default-router 192.168.103.254
lease 0 0 10
exit
ip dhcp excluded-address 192.168.103.1 192.168.103.103
ip dhcp excluded-address 192.168.103.254
end
wri
conf t
hostname Acc01
interface Ethernet0/0
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan all
exit
interface Ethernet0/1
switchport mode access
switchport access vlan 101
exit
interface Ethernet0/2
switchport mode access
switchport access vlan 101
end
wri
conf t
hostname Acc02
interface Ethernet0/0
switchport trunk encapsulation dot1q
switchport mode trunk
switchport trunk allowed vlan all
exit
interface Ethernet0/2
switchport mode access
switchport access vlan 102
exit
interface Ethernet0/3
switchport mode access
switchport access vlan 103
end
wri
10. Cấu hinh trên Core switch phải đảm bảo các PC trong LAN truy cập 8.8.8.8 phải đi đúng thứ tự Core -> Firewall -> ISP-Router -> Internet; tuy nhiên khi Firewall down các PC có thể truy cập được 8.8.8.8 theo thứ tự Core -> ISP-Router -> Internet
- Kiểm tra trước khi cấu hình:
Chúng ta thấy các gói tin đã đi đúng yêu cầu ban đầu: Core -> Firewall -> ISP-Router -> InternetPC1> tracer 8.8.8.8trace to 8.8.8.8, 8 hops max, press Ctrl+C to stop1 192.168.101.254 1.291 ms 1.047 ms 0.968 ms2 192.168.200.1 1.814 ms 1.523 ms 1.661 ms3 125.234.102.241 2.160 ms 2.112 ms 1.928 ms4 *200.1.1.1 2.586 ms (ICMP type:3, code:3, Destination port unreachable) *PC1>
- Cấu hình:
interface Vlan500ip address 125.234.102.242 255.255.255.248no shutexitip route 0.0.0.0 0.0.0.0 125.234.102.241 10endwri
interface Ethernet0/0ip nat outsideexitinterface Ethernet0/1ip nat insideexitip nat inside source list LAN-to-INTERNET interface Ethernet0/0 overloadip access-list extended LAN-to-INTERNETdeny ip 125.234.102.240 0.0.0.7 anypermit ip any anyexitip route 192.168.100.0 255.255.255.0 125.234.102.242ip route 192.168.101.0 255.255.255.0 125.234.102.242ip route 192.168.102.0 255.255.255.0 125.234.102.242ip route 192.168.103.0 255.255.255.0 125.234.102.242endwri
- Giải thích access-list:
- Kiểm tra sau khi cấu hình
Core#ping 8.8.8.8Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
Core#ping 8.8.8.8 source vlan 101Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:Packet sent with a source address of 192.168.101.254!!!!!Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/2 msCore#
PC1> tracer 8.8.8.8trace to 8.8.8.8, 8 hops max, press Ctrl+C to stop1 192.168.101.254 1.016 ms 0.841 ms 0.948 ms2 125.234.102.241 1.687 ms 1.561 ms 1.470 ms3 *200.1.1.1 2.417 ms (ICMP type:3, code:3, Destination port unreachable) *PC1>
P/s: Đã đúng yêu cầu tuy nhiên chúng ta có thể làm thêm IP SLA Tracking để kiểm tra IP đầu xa, nếu ping đến không được thì sẽ tư động điều chỉnh bản route cho phù hợp
11. IP SLA Tracking
- Cấu hình:
ip sla 2001icmp-echo 192.168.200.1threshold 5frequency 10exit!ip sla schedule 2001 life forever start-time now!track 1 ip sla 2001 reachabilityexit!no ip route 0.0.0.0 0.0.0.0 192.168.200.1ip route 0.0.0.0 0.0.0.0 192.168.200.1 track 1endwri
- Kiểm tra:
Core#show ip sla configuration 2001IP SLAs Infrastructure Engine-IIIEntry number: 2001Owner:Tag:Operation timeout (milliseconds): 5000Type of operation to perform: icmp-echoTarget address/Source address: 192.168.200.1/0.0.0.0Type Of Service parameter: 0x0Request size (ARR data portion): 28Verify data: NoVrf Name:Schedule:Operation frequency (seconds): 10 (not considered if randomly scheduled)Next Scheduled Start Time: Start Time already passedGroup Scheduled : FALSERandomly Scheduled : FALSELife (seconds): ForeverEntry Ageout (seconds): neverRecurring (Starting Everyday): FALSEStatus of entry (SNMP RowStatus): ActiveThreshold (milliseconds): 5Distribution Statistics:Number of statistic hours kept: 2Number of statistic distribution buckets kept: 1Statistic distribution interval (milliseconds): 20Enhanced History:History Statistics:Number of history Lives kept: 0Number of history Buckets kept: 15History Filter Type: NoneCore#
Core#show ip sla statisticsIPSLAs Latest Operation StatisticsIPSLA operation id: 2001Latest RTT: 1 millisecondsLatest operation start time: 08:18:23 EET Wed Jun 9 2021Latest operation return code: OKNumber of successes: 31Number of failures: 6Operation time to live: ForeverCore#
Core#debug ip routingIP routing debugging is onCore#
Core#conf tint et0/1shutCore(config-if)#*Jun 9 06:24:31.200: is_up: Ethernet0/1 0 state: 6 sub state: 1 line: 0*Jun 9 06:24:31.200: RT: interface Ethernet0/1 removed from routing table*Jun 9 06:24:31.200: RT: del 192.168.200.0 via 0.0.0.0, connected metric [0/0]*Jun 9 06:24:31.200: RT: delete subnet route to 192.168.200.0/29*Jun 9 06:24:31.200: RT: del 192.168.200.2 via 0.0.0.0, connected metric [0/0]*Jun 9 06:24:31.200: RT: delete subnet route to 192.168.200.2/32*Jun 9 06:24:31.200: RT: del 0.0.0.0 via 192.168.200.1, static metric [1/0]*Jun 9 06:24:31.200: RT: delete network route to 0.0.0.0/0*Jun 9 06:24:31.200: RT: default path has been cleared*Jun 9 06:24:31.200: RT:Core(config-if)#updating static 0.0.0.0/0 (0x0):via 125.234.102.241*Jun 9 06:24:31.200: RT: add 0.0.0.0/0 via 125.234.102.241, static metric [10/0]*Jun 9 06:24:31.200: RT: default path is now 0.0.0.0 via 125.234.102.241Core(config-if)#*Jun 9 06:24:33.194: %LINK-5-CHANGED: Interface Ethernet0/1, changed state to administratively downCore(config-if)#*Jun 9 06:24:33.194: is_up: Ethernet0/1 0 state: 6 sub state: 1 line: 0*Jun 9 06:24:34.199: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/1, changed state to down*Jun 9 06:24:34.199: is_up: Ethernet0/1 0 state: 6 sub state: 1 line: 0Core(config-if)#*Jun 9 06:24:36.256: %TRACKING-5-STATE: 1 ip sla 2001 reachability Up->DownCore(config-if)#
Xong!