PDA

View Full Version : Cho tôi hỏi về cấu hình switch



MANET
21-10-2003, 12:11 PM
Chào các bạn vnpro!
Cac ban cho tôi hỏi. Khi cấu hình cho Switch: tôi thấy phải cấu hình IP;
câu lênh là: switch (config) # Ip address ipaddress subnetmask
nhưng tôi nghĩ: switch là thiết bị tầng 2. sao lại cần đến địa chỉ IP hả các bạn?
Giúp mình nhé!
Cảm ơn nhiều!

chipchipzzz
21-10-2003, 12:39 PM
Hi MANET,

Bạn lặp lại vấn đề cũ đã có bài thảo luận trong cùng box này
http://www.vnpro.org/forum/viewtopic.php?t=2021&highlight=
IP cấu hình trên Switch mục đích chính là để quản trị Switch từ xa

Ngoài các Switch hoạt động Layer 2 còn có các loại MultiLayer Switch bạn tham khảo thêm trong box CCNP Switching và các tài liệu sách vở liên quan đến Switches

Thân mến,

admin
13-01-2005, 11:29 PM
Hướng dẫn cấu hình Switch cơ bản
Người thực hiện: Trương Quang Dũng, CCNP
Nguồn: chuyenviet.com
----------------------------------------------------
Cấu hình Switch cơ bản

Mục tiêu bài Lab: Mô tả cách thức cấu hình các thông số cơ bản cho Catalys Switch với giao diện comman prompt (cách cấu hình này giống nhau đối với nhiều Series Catalys Switch)
Dùng máy trạm kết nối với Catalys Switch qua giao diện console, giao diện tươnmg tác người dùng sử dụng trình Hiper Terminal (một công cụ đuợc Windows hỗ trợ)

Bước 1: khởi động nguồn trên giao diện Hiper Terminal hiện ra các thông số khởi tạo trong quá trình khởi động Switch


% Please answer 'yes' or 'no'.
Would you like to enter the initial configuration dialog? [yes/no]: no


Press RETURN to get started!


00:04:13: %LINK-5-CHANGED: Interface Vlan1, changed state to administratively down
00:04:14: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan1, changed state to down
Switch>


*Người dùng sẽ được hỏi nếu muốn vào Config box để cấu hình tự động, trả lời NO
(vì mục đích của người dùng là muốn vào chế độ Config prompt
Bước 2: vào privilidge mode xem cấu hình mặc định của switch
Switch>enable
Switch#show running-config
Building configuration...


Current configuration : 1473 bytes
!
version 12.1
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Switch
!
!
ip subnet-zero
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
!
!
interface FastEthernet0/1
no ip address
!
interface FastEthernet0/2
no ip address
!
interface FastEthernet0/3
no ip address
!
interface FastEthernet0/4
no ip address
!
interface FastEthernet0/5
no ip address
!
interface FastEthernet0/6
no ip address
!
interface FastEthernet0/7
no ip address
!
interface FastEthernet0/8
no ip address
!
interface FastEthernet0/9
no ip address
!
interface FastEthernet0/10
no ip address
!
interface FastEthernet0/11
no ip address
!
interface FastEthernet0/12
no ip address
!
interface GigabitEthernet0/1
no ip address
!
interface GigabitEthernet0/2
no ip address
!
interface Vlan1
no ip address
shutdown
!
ip classless
ip http server
!
!
line con 0
line vty 5 15
!
end

Switch#


Bước 3: thiết lập thông số :hostname, enable password, console password, và virtual terminal password
*Chú ý: các loại password sử dụng mang tính chất Case Sensitive. Do đó người dùng cần phân biết các ký tự sử dụng:chữ viết hoa khác với chữ viêt thường
VD: password Cisco khác với cisco

Switch#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname Vnpro
Vnpro(config)#enable password cisco
Vnpro(config)#enable secret class
Vnpro(config)#line console 0
Vnpro(config-line)#password console
Vnpro(config-line)#login
Vnpro(config-line)#^Z
Vnpro#
00:07:30: %SYS-5-CONFIG_I: Configured from console by console
Vnpro#



Switch hỗ trợ các Virtual Line dùng cho các phiên telnet, Cần cấu hình password cho các line này mới có thể telnet vào Switch (trình tự cấu hình hỗ trợ telnet sẽ trình bày sau)
Để xem thông tin về các Virtual Line trên Switch: dùng lệnh “show line”

Vnpro#show line
Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
* 0 CTY - - - - - 0 0 0/0 -
1 VTY - - - - - 0 0 0/0 -
2 VTY - - - - - 0 0 0/0 -
3 VTY - - - - - 0 0 0/0 -
4 VTY - - - - - 0 0 0/0 -
5 VTY - - - - - 0 0 0/0 -
6 VTY - - - - - 0 0 0/0 -
7 VTY - - - - - 0 0 0/0 -
8 VTY - - - - - 0 0 0/0 -
9 VTY - - - - - 0 0 0/0 -
10 VTY - - - - - 0 0 0/0 -
11 VTY - - - - - 0 0 0/0 -
12 VTY - - - - - 0 0 0/0 -
13 VTY - - - - - 0 0 0/0 -
14 VTY - - - - - 0 0 0/0 -
15 VTY - - - - - 0 0 0/0 -
16 VTY - - - - - 0 0 0/0 -


Cấu hình password cho các line vty


Vnpro#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Vnpro(config)#line vty 0 4
Vnpro(config-line)#password cisco
Vnpro(config-line)#login
Vnpro(config-line)#^Z
Vnpro#
00:11:02: %SYS-5-CONFIG_I: Configured from console by console


*Kiểm tra cấu hình


Vnpro#show running-config
Building configuration...

Current configuration : 1625 bytes
!
version 12.1
no service pad
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
!
hostname Vnpro
!
enable secret 5 $1$7G8x$sH4X2m4gt7I.7MdGHMZmw0
enable password cisco
!
ip subnet-zero
!
!
spanning-tree mode pvst
spanning-tree extend system-id
!
!
interface FastEthernet0/1
no ip address
!
interface FastEthernet0/2
no ip address
!
interface FastEthernet0/3
no ip address

interface Vlan1
no ip address
shutdown
!
ip classless
ip http server
!
!
!
line con 0
password console
login
line vty 0 4
password cisco
login
!
end

Vnpro#

Cấu hình trên thiết bị Cisco, mỗi dòng lệnh do người dùng gõ vào, sau khi “enter” cấu hình hệ thống sẽ lập tức thay đổi.Vì vậy, đối với các hệ thống online, cần phải hết sức cẩn thận, trước khi thay đổi một thông số nào đó của thiết bị, cần phải sao lưu lại cấu hình ban đầu để có thể khôi phục lại khi cần thiết.

Bước 4: cấu hình Vlan.
*Kiếm tra cấu hình Vlan mặc định trên Switch
Vnpro#show vlan
show vlan

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, 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
Gi0/1, Gi0/2
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0

Remote SPAN VLANs
------------------------------------------------------------------------------



Mặc định trên Switch chỉ có Vlan 1 với tất cả các port đều nằm trong Vlan này, Vlan 1002 dành riêng cho FDDI, Vlan 1003 dành riêng cho TOKEN-RING…

Có hai cách tạo thêm Vlan
- Cách 1:Thao tác trên Vlan database

Vnpro#vlan database
Vnpro(vlan)#vtp domain Chuyenviet
Changing VTP domain name from NULL to Chuyenviet
Vnpro(vlan)#vtp server
Setting device to VTP SERVER mode.
Vnpro(vlan)#vlan 10 name Admin
VLAN 10 added:
Name: Admin
Vnpro(vlan)#vlan 20 name User
VLAN 20 added:
Name: User
Vnpro(vlan)#apply
APPLY completed.
Vnpro(vlan)#exit
APPLY completed.
Exiting....
Vnpro#



- Cách 2:Tưong tác trực tiếp đến Vlan cần tạo ra

Vnpro(config)#interface vlan 10
Vnpro(config-if)#exit
Vnpro(config)#
Vnpro(config)#interface vlan 20
Vnpro(config-if)#exit
Vnpro(config)#


Để gán các port vào các Vlan, thực hiện các bước sau:
Vd: gán các port fastethernet 2 vào Vlan 10, port fastetehnet 3 vào Vlan 20

Vnpro(config)#interface fastethernet0/2
Vnpro(config-if-range)#switchport access vlan 10
Vnpro(config-if-range)#exit
Vnpro(config)#interface fastethernet0/3
Vnpro(config-if-range)#switchport access vlan 20
Vnpro(config-if-range)#exit


Kiểm tra lại cấu hình Vlan

Vnpro#show vlan

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/4, Fa0/5, 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, Gi0/1, Gi0/2
10 Admin active Fa0/2
20 User active Fa0/3
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active

VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1 enet 100001 1500 - - - - - 0 0
10 enet 100010 1500 - - - - - 0 0
20 enet 100020 1500 - - - - - 0 0
1002 fddi 101002 1500 - - - - - 0 0
1003 tr 101003 1500 - - - - - 0 0
1004 fdnet 101004 1500 - - - ieee - 0 0
1005 trnet 101005 1500 - - - ibm - 0 0

Remote SPAN VLANs
------------------------------------------------------------------------------

Primary Secondary Type Ports
------- --------- ----------------- ------------------------------------------

Vnpro#


Cấu hình IP cho Vlan: cácVlan được cấu hình IP chỉ mang tính chất luận lý, IP này phục vụ cho việc quản lý, địa chỉ IP luận lý này còn có thể dùng để revert telnet vào Switch từ
xa


Vnpro#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
Vnpro(config)#interface vlan 10
Vnpro(config-if)#ip address 10.0.0.1 255.255.255.0
Vnpro(config-if)#no shutdown
Vnpro(config-if)#^Z
Vnpro#
00:14:43: %LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to down
00:14:43: %SYS-5-CONFIG_I: Configured from console by console
Vnpro#

Lưu cấu hình vào NVRAM

Vnpro#copy running-config starup-config
Destination filename [startup-config]?
Building configuration...
[OK]
Vnpro#

extreme
17-01-2005, 09:52 AM
cho mình hỏi ,liệu sw có thể nhận ip từ DHCP của router ko?

robedan
17-01-2005, 11:22 AM
chào extreme

Mình có cố gắng tìm kiếm thông tin cho phép cấu hình IP address cũa switch thông qua dhcp nhưng không tìm thấy. Có một lệnh là

ip address negotiated

nhưng lệnh này chỉ áp dụng cho các cổng serial. Mình không rõ là lệh này có trên switch hay không?

Theo robe thì trên switch không hỗ trợ dhcp client

extreme
17-01-2005, 10:46 PM
oh,vậy hả ,cám ơn robedan đã trả lời câu hỏi của mình