Build your own virtual local area network (VLAN) with ZeroTier

Straight to the point, what is a Virtual Local Area Network (VLAN):

The Chinese name of VLAN (Virtual Local Area Network) is "Virtual Local Area Network".
A virtual local area network (VLAN) is a group of logical devices and users. These devices and users are not limited by physical locations. They can be organized according to factors such as functions, departments, and applications. They communicate with each other as if they are in  It is the same in the same network segment , hence the name virtual local area network. VLAN is a relatively new technology, which works on  the second and third layers of the  OSI reference model . A VLAN is a broadcast domain , and the communication between VLANs is completed through routers on the third layer  . Compared with traditional  LAN technology , VLAN technology is more flexible, and it has the following advantages: The management overhead of moving, adding and modifying network equipment is reduced; broadcasting activities  can be controlled; and  network security can be improved.
In a computer network, a Layer 2 network can be divided into multiple different broadcast domains. A broadcast domain corresponds to a specific user group. By default, these different broadcast domains are isolated from each other. Communication between different broadcast domains needs to pass through one or more routers. Such a broadcast domain is called a VLAN.

Why VLANs are needed:

  • Simplify the management of multiple cloud servers : you can use 192.168.1.1 to access cloud server 1, and use 192.168.1.2 to access cloud server 2.
  • Simplify development and debugging : Intranet penetration through VLAN can enable mobile phones to debug applications on the development machine in different network environments, and nginx can be configured on the cloud server to offload a small number of requests to the development machine for direct production debugging .
  • Realize LAN connection in WAN : The effect is probably similar to various stand-alone game battle platforms, or just say hamachi.
  • .....(More uses of VLAN as you can imagine)

OK, next, a brief introduction to our protagonist today:  ZeroTier .

Official introduction:

ZeroTier transforms the entire world into a single data center or cloud region. Network all your devices, virtual machines, and applications like they’re all plugged into the same switch.

translate:

ZeroTier turns the entire world into a single data center or cloud region. Connect all devices, virtual machines, and applications as if they were all on the same switch.

To put it simply, it is a VLAN building tool, but different from general VLAN building tools (such as Hamachi, n2n, etc.), ZeroTier has several advantages:

  • Almost zero configuration : Traditional VLAN creation tools generally require self-built supernodes (such as n2n supernodes), and a series of configurations need to be performed on a server with a public network ip, which is generally discouraged for novices.
  • Custom ip can be fixed : Compared with Hamachi, through the self-built network, we can customize a fixed ip, you can use 192.168.1.1 to access cloud server 1, use 192.168.1.2 to access cloud server 2, It is convenient to remember, instead of generating random ip like 5.233.212.45 like Hamachi.
  • Cross-platform : ZeroTier provides clients for windows, macOS, linux, Android, iOS... almost all platforms, you can connect devices on any platform to VLAN.

Note: The establishment of VLAN referred to in this article refers to the VLAN established under ZeroTier’s official Earth network, and there is another strategy of self-built Moon network server. The functional differences between the two network strategies will not be described in this article. , Interested partners can check ZeroTier's official website by themselves.

After the introduction, let’s start to explain how to configure related configurations:

ZeroTier's VLAN configuration includes two parts,  Network configuration and Client configuration . The former can be understood as VLAN router configuration, and the configuration principle is probably similar to configuring a home router.

Network configuration:

1. Register a ZeroTier account here and log in

 

The registration process, here I directly log in with a certain song account, friends who do not have the qualifications can directly register an account (Is it necessary to take a separate screenshot for this process?)

2. After logging in, we can configure our network

After clicking Create Network, a new network will be generated in the list on the right, and click to enter the configuration details page for related configuration:

The basic configuration of the network is shown in the figure:

Client authorization and ip configuration reference

Other advanced configurations are unnecessary for us, and we can understand the configuration according to our own needs

Client configuration:

Here is a script to install the ZeroTier client with one click through chocolatey:

# If you have already installed choco, you don't need to execute the first line
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1 '))
choco install zerotier-one -y

After installation, find the newly installed application in the start menu to start

In the notification bar, operate the client and fill in the network id to join the network.

After installing the client and joining the virtual network for all your devices that need to join the virtual LAN, go back to the network management page again,  allow your devices to join the network , and you can configure static IP on the right .

Allow your server to access the VLAN and assign a static IP

Then test to ping a few machines:

Test ping, VLAN established successfully

 

Guess you like

Origin blog.csdn.net/leonnew/article/details/126642058