Sample Code for VLAN configuration of a vswitch

Source: Internet
Author: User

A sample code for VLAN configuration problems of a vswitch. It is very common to set a VLAN name. According to the 51cto editor, the basic knowledge about VLAN settings of vswitches must be tested in order to make greater progress.

Apply to the port. First, set the VLAN name. Use the vlanvlan number namevlan name. Configure in privileged configuration mode:
1900 Switch (config) # vlan2nameaccounting
1900 Switch (config) # vlan3namemarketing

We have configured two new VLANs. Why does the VLAN Number of the switch start from 2? This is because, by default, all ports are not placed on VLAN1, so the configuration should start from 2. 1900 series switches can be configured with a maximum of 1024 VLANs, but only 64 switches can work at the same time. Of course, in theory, we should plan VLAN numbers based on our actual network needs.

After the VLAN name is configured, we need to enter each port to set the VLAN of the switch. In a vswitch, if you want to enter a port such as 4th, use interfaceEthernet0/4. Okay, let's make ports 2, 3, 4, and 5 belong to vlan2, port 17---22 belongs to VLAN3. The command is the vlan-membershipstatic/dynamicVLAN number. Either static or dynamic must be selected, followed by the vlan id Just configured. Okay. Let's see the result:
1900 Switch (config) # interfaceethernet0/2
1900 Switch (config-if) # vlan-membershipstatic2
1900 Switch (config-if) # inte0/3
1900 Switch (config-if) # vlan-membershipstatic2
1900 Switch (config-if) # inte0/4
1900 Switch (config-if) # vlan-membershipstatic2
1900 Switch (config-if) # inte0/5
1900 Switch (config-if) # vlan-membershipstatic2
1900 Switch (config-if) # inte0/17
1900 Switch (config-if) # vlan-membershipstatic3
............
1900 Switch (config-if) # inte0/22
1900 Switch (config-if) # vlan-membershipstatic3
1900 Switch (config-if )#

All right, we have defined the VLAN settings of the switch on the port of the switch. Here, we only configure static data. We will mention dynamic data later. So far, we have set the VLAN of the switch. How is it? It's not as complicated as you think. To verify our configuration, we use the showvlan command in privileged mode. The output is as follows:
1900 Switch (config) # showvlan
VLANNameStatusPorts
1defaultEnabled1, 6-16, 22-24, AUI, A, B
2accontingEnabled2-5
3marketingEnabled17-22
1002fddi-defaultsusponded
1003token-ring-defausu0000ded
1004fddinet-defaultsusponded
1005trnet-defaultsuincluded

This is A 24-port switch with AUI and two 100 m ports A and B. We can see that our settings are working properly. What should we do if we want to save runningconfigure? Of course, no, the switch is saved automatically in real time, so we don't need to use commands to save the settings.

Of course, you can also use the showvlanvlan number command to view a VLAN, such as showvlan2 and showvlan3. you can also use showvlan-membership, the change command mainly displays the static or dynamic VLAN of each port on the switch.

The above is the process of configuring a static VLAN for the switch. Let's look at the dynamic VLAN. Dynamic VLAN formation is very simple. When the port determines which VLAN it belongs to, a dynamic VLAN is formed. However, this does not mean that the layer remains unchanged. It is just a simple ing, which depends on the database created by the network administrator.

After the port assigned to the dynamic VLAN is activated, the switch caches the source MAC address of the initial frame. Then, the switch sends a request to an external server called the VMPSVLAN Management Policy server, VMPS contains a text file containing the MAC address for VLAN ing.

The switch downloads the file and verifies the MAC address in the file. If you find the MAC address in the file list, the switch assigns the port to the VLAN in the list. If there is no MAC address in the list, the switch will allocate the port to the default VLAN, assuming that the default VLAN has been defined ).

If there is no MAC address in the list and no default switch VLAN settings are defined, the port is not activated. This is a very good way to maintain network security. On the surface, dynamic VLAN has great advantages, but it also has a fatal disadvantage, that is, it is very difficult and tedious to create a database.

If there are thousands of workstations on the network, there will be a lot of input work to do. Even if someone is competent for this job, there will be many problems related to dynamic VLANs. In addition, it is time-consuming to keep the database up-to-date. So it is not often used. Here we will not explain it in detail. You can refer to the relevant CISCO documentation.

This is not as complicated as you think. We have already configured the VLAN, so another part of the VLAN cannot be ignored is the preliminary network planning. That is to say, which machines are in a VLAN, how their respective IP addresses, how subnet masks are allocated, and how VLANs communicate with each other. Only after the plan is planned can you easily save trouble in the configuration and future use and maintenance process.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.