Search

Tuesday, November 25, 2008

Config switch vtp mode

สวัสดีครับ เทอมนี้ได้เรียน datacom 2 เป็นเรื่องเครือข่าย โดยเฉพาะ Lab ได้ config siwtch , router....


เข้าเรื่องกันเลยดีกว่าครับ

สำหรับการทำ vtp บน switch การทดลองนี้ผมใช้ CCNA Network Visualizer
ก่อนอื่นก็ทำการเชื่อมต่อ switch และ host แล้วกำหนด IP ให้กับ host ดังรูป
ในการทดลองนี้ผมให้
vlan1 ip 127.2.145.0
vlan2 ip 192.2.146.0


เสร็จแล้วก็จะทำการ แบ่ง vlan บน switch ทั้งสองตัวกัน
โดยตัวแรก ก็จะมี 2 vlan ตัวที่ 2 ก็จะมี 2 vlan เช่นกัน
โดยใช้คำสั่งต่อไปนี้





switch Con0 is now available



Press RETURN to get started!



switch>enable
switch#vlan database
switch(vlan)#vlan 2 name VLAN1
VLAN 2 modified:
Name: VLAN1
switch(vlan)#vlan 2 name VLAN2
VLAN 2 modified:
Name: VLAN2
switch(vlan)#exit
APPLY completed.
Exiting....
switch#


ที่นี้ก็ลอง แสดง vlan ที่เราสร้างไว้




switch Con0 is now available



Press RETURN to get started!



switch>enable
switch#vlan database
switch(vlan)#vlan 2 name VLAN1
VLAN 2 modified:
Name: VLAN1
switch(vlan)#vlan 2 name VLAN2
VLAN 2 modified:
Name: VLAN2
switch(vlan)#end
^
% Invalid input detected at '^' marker.
switch(vlan)#exit
APPLY completed.
Exiting....
switch#config t
Enter configuration commands, one per line. End with CNTL/Z
switch(config)#vtp ?
domain Set the name of the VTP administrative domain.
file Configure IFS filesystem file where VTP configuration is stored.
interface Configure interface as the preferred source for the VTP IP updater
address.
mode Configure VTP device mode
password Set the password for the VTP administrative domain
pruning Set the adminstrative domain to permit pruning
version Set the adminstrative domain to VTP version

switch(config)#vtp ?
domain Set the name of the VTP administrative domain.
file Configure IFS filesystem file where VTP configuration is stored.
interface Configure interface as the preferred source for the VTP IP updater
address.
mode Configure VTP device mode
password Set the password for the VTP administrative domain
pruning Set the adminstrative domain to permit pruning
version Set the adminstrative domain to VTP version

switch(config)#vtp mode server
Device mode already VTP SERVER.
switch(config)#exit
switch#sh 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
2 VLAN2 active
3 vlan2 active
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
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 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
------- --------- ----------------- ------------------------------------------


switch#

เพิ่ม port เข้าไปใน แต่ละ vlan


switch(config)#interface fastethernet 0/1
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 2
switch(config-if)#exit
switch(config)#interface fastethernet 0/2
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 2
switch(config-if)#exit
switch(config)#interface fastethernet 0/3
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 3
switch(config-if)#exit
switch(config)#interface fastethernet 0/4
switch(config-if)#switchport mode access
switch(config-if)#switchport access vlan 3
switch(config-if)#exit
switch(config)#exit
switch#sh vlan

VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
2 VLAN2 active Fa0/1, Fa0/2
3 vlan2 active Fa0/3, Fa0/4
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
2 enet 100002 1500 - - - - - 0 0
3 enet 100003 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

--More--

เสร็จแล้วก็ config ที่ switch ตัวที่ 2 ทำเหมือนกันกับตัวที่ 1

ต่อไปจะ config vpt



switch(config)#vtp mode server
Device mode already VTP SERVER.
switch(config)#vtp domain server1
Changing VTP domain name from NULL to server1
switch(config)#exit
switch#sh vtp status
VTP Version : 2
Configuration Revision : 4
Maximum VLANs supported locally : 64
Number of existing VLANs : 8
VTP Operating Mode : Server
VTP Domain Name : server1
VTP Pruning Mode : Disabled
VTP V2 Mode : Disabled
VTP Traps Generation : Disabled
MD5 digest : 0x70 0x01 0xF2 0x72 0x97 0xA1 0x35 0xEB
Configuration last modified by: 0.0.0.0 at 11-29-93 20:39:24
Local updater ID is 0.0.0.0 on interface Vl1 (lowest numbered VLAN interface
found)
switch#

Friday, November 14, 2008

Remove element array in php




////////////////////////////////// Lists(Numerical Arrays) /////////////////////////////////

/**

* A small function to remove an element from a list(numerical array)

* Arguments: $arr - The array that should be edited

* $value - The value that should be deleted.

* Returns : The edited array

*/

function array_remove($arr,$value) {

return array_values(array_diff($arr,array($value)));

}



////////////////////////////////// Associative Arrays //////////////////////////////////////

/**

* This function will remove all the specified keys from an array and return the final array.

* Arguments : The first argument is the array that should be edited

* The arguments after the first argument is a list of keys that must be removed.

* Example : array_remove_key($arr,"one","two","three");

* Return : The function will return an array after deleting the said keys

*/

function array_remove_key() {

$args = func_get_args();

$arr = $args[0];

$keys = array_slice($args,1);



foreach($arr as $k=>$v) {

if(in_array($k, $keys))

unset($arr[$k]);

}

return $arr;

}



/**

* This function will remove all the specified values from an array and return the final array.

* Arguments : The first argument is the array that should be edited

* The arguments after the first argument is a list of values that must be removed.

* Example : array_remove_value($arr,"one","two","three");

* Return : The function will return an array after deleting the said values

*/

function array_remove_value() {

$args = func_get_args();

$arr = $args[0];

$values = array_slice($args,1);



foreach($arr as $k=>$v) {

if(in_array($v, $values))

unset($arr[$k]);

}

return $arr;

}