- Fixed IP 設定方式
- DHCP 設定方式
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface vlan 1
Switch(config-if)#ip address 192.168.10.1 255.255.255.0
Switch(config-if)#no shutdown
Switch#
%LINK-5-CHANGED: Interface Vlan1, changed state to up
Switch(config-if)#exit
Switch(config)#ip default-gateway 192.168.10.254
Switch(config)#exit
Switch#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
no shutdown 指令是把interface vlan 1 給予啟動
下面的指令可以查到目前vlan 1 的IP 資訊
Switch#show interface vlan 1
Vlan1 is up, line protocol is down
Hardware is CPU Interface, address is 0001.6493.19a1 (bia 0001.6493.19a1)
Internet address is 192.168.10.1/24
MTU 1500 bytes, BW 100000 Kbit, DLY 1000000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
ARP type: ARPA, ARP Timeout 04:00:00
Switch>enable
Switch#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#interface vlan 1
Switch(config-if)#ip address dhcp
Switch(config-if)#no shutdown
Switch(config-if)#exit
Switch(config)#exit
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#copy running-config startup-config
Destination filename [startup-config]?
Building configuration...
[OK]
- 使用show dhcp lease 查詢取的ˊIP資訊
- Switch#show dhcp lease
Temp IP addr: 192.168.9.1 for peer on Interface: Vlan1
Temp sub net mask: 255.255.255.0
DHCP Lease server: 192.168.9.2 , state: Bound
DHCP Transaction id: 6C888578
Lease: 86400 secs, Renewal: 43200 secs, Rebind: 75600 secs
Temp default-gateway addr: 192.168.9.254
Next timer fires after: 11:59:58
Retry count: 0 Client-ID:cisco-0001.6493.19A1-Vlan1
Hostname: Switch
- 若是要更換IP請再interface vlan 1 內輸入shutdown給予disable後,再輸入no shutdown給予enable,這時就會自動向DHCP server要求提供IP。