Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

VXLAN Overlay Network Setup

Download as pdf or txt
Download as pdf or txt
You are on page 1of 14

VXLAN Overlay Network Setup

implement overlay network like VXLAN to connect two VM residing in two different laptop

To connect two virtual machines (VMs) residing on two different laptops using an overlay network like
VXLAN (Virtual Extensible LAN), you will essentially create a virtual Layer 2 (L2) network that extends
over a Layer 3 (L3) infrastructure (e.g., the Internet or a local network). VXLAN encapsulates Layer 2
traffic inside Layer 3 packets using UDP, which allows communication between VMs across different
physical locations.

Requirements:

1. Two laptops, each running a virtualization platform (e.g., VirtualBox, VMware, or KVM).
2. VXLAN configuration tools: This can be done using Linux tools (e.g., `ip`, `iproute2`) or a
virtual switch like Open vSwitch (OVS).
3. Connectivity between laptops: Both laptops need to have IP-level connectivity, either on the
same local network or through the Internet.
4. Linux distribution on the VMs with necessary networking tools installed.

Steps:

1. Ensure connectivity between the laptops

Make sure that both laptops can communicate with each other at the IP layer. You can use the
Internet or local network for this.
Ensure you can ping the other laptop from each machine.
If using the Internet, check if NAT or firewalls are allowing the necessary UDP ports for
VXLAN (default port: 4789).

2. Install necessary networking tools on both laptops

You will need Linux utilities like `ip`, `bridge-utils`, and `iproute2` for VXLAN. You can also use Open
vSwitch for more advanced VXLAN configuration.

bash

# Install necessary packages


sudo apt-get update
sudo apt-get install iproute2 bridge-utils

Optionally, for Open vSwitch:

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 1/14
bash

sudo apt-get install openvswitch-switch

3. Configure VXLAN on each laptop

Option 1: Using `iproute2` (for Linux VMs)

1. On Laptop 1:
Create a VXLAN interface on the first laptop.

bash

sudo ip link add vxlan0 type vxlan id 42 dev eth0 dstport 4789
sudo ip link set vxlan0 up

Replace `eth0` with the actual network interface used to connect to the second laptop.
Create a bridge interface and attach the VM’s network interface and the VXLAN interface to
it.

bash

sudo brctl addbr br0


sudo brctl addif br0 vxlan0
sudo brctl addif br0 eth0
sudo ip link set br0 up

Now, VMs connected to `br0` will be bridged to the VXLAN network.

2. On Laptop 2:
Repeat the same process on the second laptop.

bash

sudo ip link add vxlan0 type vxlan id 42 dev eth0 dstport 4789
sudo ip link set vxlan0 up
sudo brctl addbr br0
sudo brctl addif br0 vxlan0
sudo brctl addif br0 eth0
sudo ip link set br0 up

3. Assign Multicast/Unicast IP Addresses


VXLAN works with either unicast or multicast IPs.
If both laptops are on the same network, multicast is supported.

For unicast setup (e.g., over the Internet):

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 2/14
bash

sudo ip addr add 192.168.1.10/24 dev vxlan0

On the other laptop:

bash

sudo ip addr add 192.168.1.20/24 dev vxlan0

Option 2: Using Open vSwitch (OVS)

1. Install Open vSwitch:

bash

sudo apt-get install openvswitch-switch

2. Create VXLAN tunnel on both laptops:

On both laptops, create an OVS bridge and VXLAN interface:

bash

sudo ovs-vsctl add-br br0


sudo ovs-vsctl add-port br0 vxlan0 -- set interface vxlan0 type=vxlan
options:remote_ip=<other_laptop_ip> options:key=42

Replace `<other_laptop_ip>` with the IP address of the second laptop.

3. Connect VMs to the OVS bridge:


Attach the VM network interfaces to the bridge using `ovs-vsctl` commands.

bash

sudo ovs-vsctl add-port br0 eth0

4. Configure VMs to use VXLAN bridge

Attach each VM’s virtual network interface to the VXLAN bridge (`br0`), either by editing the VM
configuration or using the virtualization platform's network settings.

5. Test connectivity

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 3/14
Once the VXLAN overlay network is up, test connectivity between the VMs:

bash

ping <VM_IP_on_other_laptop>

Troubleshooting:

Ensure that firewalls on both laptops allow UDP traffic on port 4789.
Make sure both laptops can reach each other at the IP layer (verify with `ping`).
If using NAT or routing between the laptops, ensure that the public IP addresses are being
properly routed.

By following these steps, you should be able to create a VXLAN-based overlay network to connect VMs
on different laptops.

How to make VPN access to other laptop ?

To create a VPN (Virtual Private Network) to access another laptop securely, you'll need to set up a VPN
server on one of the laptops and connect to it from the other laptop using a VPN client. VPN allows
you to securely connect two devices over the internet or a private network, making it seem like they
are on the same local network. Here are the general steps to set up VPN access:

Requirements:

1. Two laptops with internet access.


2. A VPN server installed on one laptop.
3. A VPN client installed on the other laptop.
4. A public IP address for the laptop hosting the VPN server (or use dynamic DNS if the public IP
changes).
5. Configure firewall rules to allow VPN traffic.

Steps for Setting up a VPN

Option 1: Using OpenVPN

OpenVPN is one of the most popular and widely used VPN solutions.

Step 1: Install OpenVPN on the server laptop

1. Install OpenVPN on the laptop that will act as the server (Laptop 1).

For Linux:

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 4/14
bash

sudo apt-get update


sudo apt-get install openvpn easy-rsa

For Windows, you can download OpenVPN from the official website.

2. Set up the CA (Certificate Authority) and generate certificates and keys:

Initialize the Easy-RSA environment:

bash

make-cadir ~/openvpn-ca
cd ~/openvpn-ca

Build the Certificate Authority (CA):

bash

./easyrsa init-pki
./easyrsa build-ca

Generate the server certificate and key:

bash

./easyrsa gen-req server nopass


./easyrsa sign-req server server

Generate the client certificate and key (for Laptop 2):

bash

./easyrsa gen-req client1 nopass


./easyrsa sign-req client client1

Generate Diffie-Hellman key exchange parameters:

bash

./easyrsa gen-dh

3. Configure the OpenVPN server:

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 5/14
Open the OpenVPN server configuration file:

bash

sudo nano /etc/openvpn/server.conf

Add the following configuration:

vbnet

port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3

Start the OpenVPN service:

bash

sudo systemctl start openvpn@server


sudo systemctl enable openvpn@server

Step 2: Configure Firewall (on the server laptop)

1. Ensure the firewall allows UDP traffic on port 1194 (default for OpenVPN).

On Linux:

bash

sudo ufw allow 1194/udp


sudo ufw enable

On Windows, open the firewall settings and allow incoming traffic on port 1194.

2. If the server is behind a NAT or router, you may need to forward port 1194 from the router to the
server’s IP address.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 6/14
Step 3: Install OpenVPN Client on Laptop 2 (Client)

1. Install the OpenVPN client:

For Linux:

bash

sudo apt-get install openvpn

For Windows, download and install the OpenVPN client.

2. Transfer the client configuration file (`client1.ovpn`) from the server laptop to the client laptop.

Create the client configuration:

vbnet

client
dev tun
proto udp
remote <server_public_ip> 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
remote-cert-tls server
cipher AES-256-CBC
verb 3

3. Connect to the VPN server using the client configuration file:

On Linux:

bash

sudo openvpn --config client1.ovpn

On Windows, use the OpenVPN GUI to load the `client1.ovpn` configuration file and
connect.

Step 4: Test the VPN Connection

1. On Laptop 2 (the client), test connectivity to Laptop 1 (the server) by checking the VPN IP
assigned (e.g., `10.8.0.X`).
2. You should be able to ping the server’s VPN IP and access services on Laptop 1 as if it were on
the same local network.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 7/14
bash

ping 10.8.0.1

If the ping is successful, the VPN connection is established successfully.

Option 2: Using WireGuard (A Simpler and Faster VPN)

WireGuard is another modern VPN solution that's easier to set up and faster than OpenVPN. Here's a
brief guide for setting it up:

1. Install WireGuard on both laptops:

For Linux:

bash

sudo apt install wireguard

For Windows, download the WireGuard client from here.

2. On Laptop 1 (server), generate key pairs and configure WireGuard:

bash

wg genkey | tee server_private.key | wg pubkey > server_public.key


wg genkey | tee client_private.key | wg pubkey > client_public.key

Configure `/etc/wireguard/wg0.conf`:

ini

[Interface]
PrivateKey = <server_private_key>
Address = 10.0.0.1/24
ListenPort = 51820

[Peer]
PublicKey = <client_public_key>
AllowedIPs = 10.0.0.2/32

Start the WireGuard interface:

bash

sudo wg-quick up wg0

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 8/14
3. On Laptop 2 (client), configure the WireGuard client:

ini

[Interface]
PrivateKey = <client_private_key>
Address = 10.0.0.2/24

[Peer]
PublicKey = <server_public_key>
Endpoint = <server_public_ip>:51820
AllowedIPs = 0.0.0.0/0

4. Start the WireGuard client on Laptop 2 and test the connection.

WireGuard is simpler and faster, while OpenVPN offers more flexibility and compatibility with more
platforms. Both will allow you to securely access the other laptop remotely over the VPN.

do the same in windows

Setting up a VPN between two Windows laptops can be done using OpenVPN or WireGuard, as these
are widely supported and open-source VPN solutions. Below are the steps for setting up a VPN using
OpenVPN and WireGuard in a Windows environment.

Option 1: Using OpenVPN on Windows

Step 1: Install OpenVPN on Both Laptops

1. Download OpenVPN for Windows from the OpenVPN website and install it on both laptops (the
server and the client).

2. During the installation, make sure to include the OpenVPN Easy-RSA package, which will be
used to generate the certificates and keys.

Step 2: Set Up the VPN Server on Laptop 1

1. Generate Certificates and Keys:


Open Command Prompt as Administrator on Laptop 1.
Navigate to the EasyRSA directory in the OpenVPN installation folder (e.g., `C:\Program
Files\OpenVPN\easy-rsa`).

bash

cd "C:\Program Files\OpenVPN\easy-rsa"

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 9/14
Initialize the Public Key Infrastructure (PKI):

bash

EasyRSA-Start.bat
./easyrsa init-pki

Build the Certificate Authority (CA):

bash

./easyrsa build-ca

Generate the server certificate and key:

bash

./easyrsa gen-req server nopass


./easyrsa sign-req server server

Generate Diffie-Hellman key:

bash

./easyrsa gen-dh

2. Configure the OpenVPN Server:

Navigate to the OpenVPN configuration directory (e.g., `C:\Program Files\OpenVPN\config`)


and create a new configuration file named `server.ovpn`.

Add the following configuration:

vbnet

port 1194
proto udp
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh2048.pem
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 8.8.8.8"
keepalive 10 120
cipher AES-256-CBC
user nobody
group nogroup
persist-key
persist-tun

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 10/14
status openvpn-status.log
verb 3

Save this configuration file as `server.ovpn`.

3. Start the OpenVPN Server:


Launch the OpenVPN GUI as an Administrator.
Right-click the OpenVPN icon in the system tray and select "Start OpenVPN on this config
file" to start the server.

Step 3: Set Up the VPN Client on Laptop 2

1. Generate the Client Certificate and Key:


On Laptop 1 (server laptop), generate the client certificate and key by running:

bash

./easyrsa gen-req client1 nopass


./easyrsa sign-req client client1

Copy the `client1.crt`, `client1.key`, and `ca.crt` files to Laptop 2.

2. Create Client Configuration:

On Laptop 2 (client laptop), navigate to the OpenVPN configuration directory (`C:\Program


Files\OpenVPN\config`).

Create a configuration file named `client1.ovpn` with the following content:

vbnet

client
dev tun
proto udp
remote <server_public_ip> 1194
resolv-retry infinite
nobind
persist-key
persist-tun
ca ca.crt
cert client1.crt
key client1.key
remote-cert-tls server
cipher AES-256-CBC
verb 3

Replace `<server_public_ip>` with the public IP address of the VPN server (Laptop 1).

3. Start the VPN Client:


Launch the OpenVPN GUI as an Administrator on Laptop 2.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 11/14
Right-click the OpenVPN icon in the system tray and select "Start OpenVPN on this config
file" to connect to the VPN server.

Step 4: Test the VPN Connection

1. Once connected, you should be able to ping the VPN server's internal VPN IP address (e.g.,
`10.8.0.1`).

bash

ping 10.8.0.1

2. Verify that the VPN is working by checking your new IP and access to remote resources.

Option 2: Using WireGuard on Windows

WireGuard is a more modern and lightweight alternative to OpenVPN, providing faster speeds and a
simpler configuration.

Step 1: Install WireGuard on Both Laptops

1. Download the WireGuard client for Windows from the WireGuard website and install it on both
laptops.

Step 2: Set Up the VPN Server on Laptop 1

1. Generate Keys:
Open the WireGuard client on Laptop 1 (server laptop).
Generate a key pair by clicking "Generate Key" for the server.
Copy the Public Key and Private Key to a notepad for later use.

2. Configure the WireGuard Server:

In the WireGuard client, click Add Tunnel and create a new tunnel with the following
configuration:

makefile

[Interface]
PrivateKey = <server_private_key>
Address = 10.0.0.1/24
ListenPort = 51820

[Peer]
PublicKey = <client_public_key>
AllowedIPs = 10.0.0.2/32

Replace `<server_private_key>` with the private key generated earlier and


`<client_public_key>` with the public key from the client (Laptop 2).

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 12/14
Click Save to create the server tunnel.

3. Start the WireGuard Server:


Activate the server tunnel by clicking the Activate button in the WireGuard client.

Step 3: Set Up the VPN Client on Laptop 2

1. Generate Keys:
Open the WireGuard client on Laptop 2 (client laptop) and generate a new key pair.
Copy the Public Key and Private Key for later use.

2. Configure the WireGuard Client:

In the WireGuard client, click Add Tunnel and create a new tunnel with the following
configuration:

makefile

[Interface]
PrivateKey = <client_private_key>
Address = 10.0.0.2/24

[Peer]
PublicKey = <server_public_key>
Endpoint = <server_public_ip>:51820
AllowedIPs = 0.0.0.0/0

Replace `<client_private_key>` with the private key generated on the client and
`<server_public_key>` with the public key of the server. Set `<server_public_ip>` to the
public IP address of Laptop 1.

3. Start the WireGuard Client:


Activate the client tunnel by clicking the Activate button in the WireGuard client.

Step 4: Test the VPN Connection

Once the client is connected to the server, you should be able to access resources on Laptop 1. You
can test the connection by pinging the VPN IP address of Laptop 1:

bash

ping 10.0.0.1

Conclusion

Both OpenVPN and WireGuard allow you to set up a VPN on Windows. OpenVPN provides more
features and compatibility, while WireGuard is faster and simpler to configure. After setting up either

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 13/14
solution, your laptops should be securely connected via VPN, enabling remote access and secure data
transfer.
‫ يمكن أن تصدر عن‬ChatGPT ‫ لذلك يجب التحقق من المعلومات المهمة‬.‫بعض األخطاء‬.

Printed using Save ChatGPT as PDF, powered by PDFCrowd HTML to PDF API. 14/14

You might also like