Overview
This document describes a method for simulating multiple servers belonging to different network domains on a single Linux host. Each simulated server runs inside its own Linux network namespace and is connected to a dedicated VLAN.
- Training and demonstration environments
Each namespace behaves as an independent server with:
- Its own IP address
- Its own MAC address
- An SSH service
- A simple HTTP server
Network Topology
The Linux host uses the following interfaces:
| Interface | Purpose |
|---|---|
| ens3 | Management interface (DHCP) |
| ens4 | Bond member |
| ens5 | Bond member |
| bond0 | LACP bond carrying VLANs |
| vlan111-vlan132 | VLAN interfaces mapped to namespaces |
Netplan Configuration
| |
Installing Required Packages
Install the required networking tools:
| |
Create the namespace initialization script:
| |
Namespace Initialization Script
The following script creates one namespace per VLAN interface, assigns an IP address, starts an HTTP service, and launches an SSH daemon.
Example Namespace Mapping
| Namespace | IP Address | Gateway |
|---|---|---|
| vlan111 | 172.16.111.101/24 | 172.16.111.1 |
| vlan112 | 172.16.112.101/24 | 172.16.112.1 |
| vlan121 | 172.16.121.101/24 | 172.16.121.1 |
| vlan122 | 172.16.122.101/24 | 172.16.122.1 |
| vlan131 | 172.16.131.101/24 | 172.16.131.1 |
| vlan132 | 172.16.132.101/24 | 172.16.132.1 |
The script performs the following operations:
- Creates a network namespace.
- Moves the VLAN interface into the namespace.
- Assigns IP and MAC addresses.
- Configures the default route.
- Starts an HTTP server.
- Starts an SSH daemon.
HTTP Server
Each namespace runs a lightweight Python HTTP server that returns information about:
- Namespace name
- Hostname
- Client IP address
Example response:
| |
Python Web Server
| |
Validation
Verify that the namespaces were created successfully:
| |
Access a namespace shell:
| |
Test connectivity:
| |
Test SSH access:
| |
This approach provides a lightweight and scalable platform for emulating servers across multiple isolated network domains while maintaining realistic Layer 2 and Layer 3 behavior.
The content of this post was created by the author; AI was used for editing and restructuring.