Linux Servers act as switches and routers

Source: Internet
Author: User
Tags switches

For ease of work, multiple virtual machines are deployed under vshpere because they are test systems because they are physically disconnected from the production network. Therefore, how to use these virtual machines to build the necessary network environment, become my concern.

In fact, the switch router is essentially an operating system, but this operating system is specifically customized optimization, so we can also use the server to achieve network deployment of switches and routers.

Here are some implementation procedures:


I. Linux acting as a switch configuration


1. Create a VLAN

Vconfig eth0//eth0 Real physical network card; 10 is the VLAN number; eth0 is trunk port ifconfig eth0.10//activating the VLAN

2. Create Bridge

Brctl ADDBR brvlan10 brctl addif brvlan10 eth0.10//Bundle VLAN with bridge brctl addif brvlan10 eth1//eth1 is an access port for VLAN10

3. Configure the Gateway

Ifconfig brvlan10 172.16.1.254/24


4. Create multiple VLANs

Vconfig eth0 20ifconfig eth0.20brctl addbr brvlan20brctl addif brvlan20 eth2

At this point, the eth0 is the port of the trunk vlan10 and Vlan20, and the peer-to-peer physical port should support the trunk ports of these two VLANs


Note: In Linux, to establish a VLAN first, and the VLAN and the physical port bundle, the switch is two layer exchange, processing is a data frame, so as long as the previous two steps to achieve the same VLAN data exchange. In this example, adding a gateway is using this Linux as a three-tier interchange.


Two. Linux acts as a router configuration


1. Under Linux, turn on soft route forwarding

1. Modify the configuration file/etc/sysctl.conf

2. Change Net.ipv4.ip_forward=0 to Net.ipv4.ip_forward=1

3. Sysctl–p make configuration effective


2. Add the route entry as required, as follows:

Route add-net 192.168.1.1/24 GW 172.16.1.254




Three. Things that ESXi should be aware of

The "Virtual machine Port Group" where eth0 should be set "VLAN ID" to "All (4095)"





Reference pages:

http://blog.csdn.net/dog250/article/details/7354590

Http://www.it165.net/os/html/201208/3088.html


This article is from the "Dot Drop" blog, please be sure to keep this source http://chiweiwei.blog.51cto.com/2686252/1621330

Linux Servers act as switches and routers

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.