Cau Hinh VLAN

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Cấu hình INSIDE

1. Định danh VLANs


Switch>en
Switch#conf t
Switch(config)hostname MainSW
MainSW(config)#VLAN 10 /* Fa0/1 */
MainSW(config)#exit
MainSW(config)#VLAN 20 /* Fa0/2 */
MainSW(config)#exit
MainSW(config)#VLAN 30 /* Fa0/3 */
MainSW(config)#exit
MainSW#show vlan brief /* Hiện thị các VLAN đã active */

2. Define Access Ports and Trunk Ports


MainSW(config)#interface fastethernet0/1 (int f0/1)
MainSW(config-if)#switchport access vlan 10
MainSW(config-if)#switchport mode access /* Mode truy cập */
MainSW(config-if)#exit

Tương tự cho VLAN 20 và VLAN 30

MainSW(config)#exit
MainSW#show vlan brief /* Hiển thị các VLAN đã active */

MainSW(config)#interface gigabitethernet 0/1 (int g0/1)


MainSW(config-if)#no shutdown
MainSW(config-if)#switchport mode trunk /*mode Trung kế */
MainSW#copy running-config startup-config

3. Configure router with dot1Q encapsulation by making each of sub-interfaces


Router>enable
Router#configure terminal
Router(config)#interface gigabitEthernet 0/0
Router(config-if)#no shutdown

Router(config)#interface gigabitethernet 0/0.10


Router(config-subif)#encapsulation dot1Q 10
/* Sử dụng giao thức VTP duy trì cấu hình của VLAN và đồng nhất mạng */
Router(config-subif)#ip address 192.168.10.1 255.255.255.0
/* Tương tự với VLAN 20 và VLAN 30 với address lần lượt: 192.168.20.1/24 và
192.168.30.1/24 */

Router(config)#exit
Router#show run

4. Configure access-list
//Chặn VLAN20 và VLAN30 vào VLAN10, cho phép VLAN tới Router.
router>en
router#conf t
router(config)#access-list 10 deny 192.168.20.2 0.0.0.255
router(config)#access-list 10 deny 192.168.30.2 0.0.0.255
router(config)#int g0/0.10
router(config-subif)#ip access-group 10 in
router(config-subif)#ex
router(config)#access-list 10 permit 192.168.10.2 0.0.0.255
router(config)#int g0/0.10
router(config-subif)#ip access-group 10 out

Tương tự cho VLAN 20 và VLAN 30

interface fastethernet0/6
switchport access vlan 30
switchport mode access
exit

no switchport

You might also like