<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Chisolum Odoabuchi</title>
    <description>The latest articles on DEV Community by Chisolum Odoabuchi (@soldev_f).</description>
    <link>https://dev.to/soldev_f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3608044%2Fd586aa7b-a9bc-49cc-9319-0501fe0c6cd7.png</url>
      <title>DEV Community: Chisolum Odoabuchi</title>
      <link>https://dev.to/soldev_f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/soldev_f"/>
    <language>en</language>
    <item>
      <title>VPC creation on Linux</title>
      <dc:creator>Chisolum Odoabuchi</dc:creator>
      <pubDate>Wed, 12 Nov 2025 18:47:04 +0000</pubDate>
      <link>https://dev.to/soldev_f/vpc-creation-on-linux-1kc9</link>
      <guid>https://dev.to/soldev_f/vpc-creation-on-linux-1kc9</guid>
      <description>&lt;p&gt;This project demonstrates how to simulate Virtual Private Clouds (VPCs) using Linux network namespaces, virtual Ethernet (veth) pairs, and bridges. Each VPC contains public and private subnets, with routing, NAT, and isolation configured to mimic cloud VPC behavior (similar to AWS VPC).&lt;/p&gt;

&lt;p&gt;Features&lt;br&gt;
Create multiple isolated VPCs with their own bridges and routing rules.&lt;/p&gt;

&lt;p&gt;Add public and private subnets to each VPC automatically.&lt;/p&gt;

&lt;p&gt;Configure NAT for outbound Internet access via the host’s interface.&lt;/p&gt;

&lt;p&gt;Enable IP forwarding for cross-network communication.&lt;/p&gt;

&lt;p&gt;Automate setup and teardown using a Makefile for testing.&lt;/p&gt;

&lt;p&gt;Easily extend to simulate VPC peering and routing policies.&lt;/p&gt;

&lt;p&gt;Project Structure&lt;br&gt;
├── Makefile&lt;br&gt;
├── vpcctl.py&lt;br&gt;
├── README.md&lt;br&gt;
├── cleanup.sh&lt;br&gt;
├── policies.json&lt;/p&gt;

&lt;p&gt;Prerequisites&lt;br&gt;
Make sure the following are installed on your Linux host:&lt;/p&gt;

&lt;p&gt;Python 3.8 or higher&lt;/p&gt;

&lt;p&gt;iproute2 utilities (ip, ip netns, etc.)&lt;/p&gt;

&lt;p&gt;iptables&lt;/p&gt;

&lt;p&gt;bridge-utils&lt;/p&gt;

&lt;p&gt;make&lt;/p&gt;

&lt;p&gt;sudo privileges&lt;/p&gt;

&lt;p&gt;Usage&lt;br&gt;
You can either run commands directly with vpcctl.py or automate everything using the Makefile. Option 1: Using the Makefile To create and test everything automatically:&lt;/p&gt;

&lt;p&gt;This will:&lt;/p&gt;

&lt;p&gt;Create two VPCs (vpc1 and vpc2) with their bridges.&lt;/p&gt;

&lt;p&gt;Add public and private subnets to each.&lt;/p&gt;

&lt;p&gt;Enable NAT for Internet-bound traffic.&lt;/p&gt;

&lt;p&gt;Display the final namespace and route configurations.&lt;/p&gt;

&lt;p&gt;To clean up everything:&lt;/p&gt;

&lt;p&gt;make clean&lt;br&gt;
Option 2: Using Python Script Directly You can also run individual operations with Python:&lt;/p&gt;

&lt;p&gt;Create a new VPC&lt;br&gt;
sudo python3 vpcctl.py create-vpc vpc1 --base-cidr 10.10.0.0/16&lt;br&gt;
Add a public subnet&lt;br&gt;
sudo python3 vpcctl.py add-subnet vpc1 public --type public --base-cidr 10.10.0.0/16&lt;br&gt;
Add a private subnet&lt;br&gt;
sudo python3 vpcctl.py add-subnet vpc1 private --type private --base-cidr 10.10.0.0/16&lt;br&gt;
View network namespaces&lt;br&gt;
ip netns list&lt;br&gt;
Check routes inside a subnet&lt;br&gt;
sudo ip netns exec vpc1-public ip route&lt;br&gt;
Delete a VPC&lt;br&gt;
sudo python3 vpcctl.py delete-vpc vpc1&lt;br&gt;
Testing &amp;amp; Verification&lt;br&gt;
After running make all, verify the following:&lt;/p&gt;

&lt;p&gt;Namespace Check&lt;br&gt;
ip netns list&lt;br&gt;
You should see something like:&lt;/p&gt;

&lt;p&gt;vpc1-public&lt;br&gt;
vpc1-private&lt;br&gt;
vpc2-public&lt;br&gt;
vpc2-private&lt;br&gt;
Routing Check&lt;br&gt;
sudo ip netns exec vpc1-private ip route&lt;br&gt;
You should see:&lt;/p&gt;

&lt;p&gt;default via 10.10.0.1 dev veth-private&lt;br&gt;
10.10.0.0/24 dev veth-private proto kernel scope link src 10.10.0.2&lt;br&gt;
Ping Test (Public ↔ Private)&lt;br&gt;
sudo ip netns exec vpc1-public ping -c 2 10.10.0.2&lt;br&gt;
Internet Connectivity (via NAT)&lt;br&gt;
sudo ip netns exec vpc1-public ping -c 2 8.8.8.8&lt;br&gt;
(works only if host Internet and NAT are active)&lt;/p&gt;

&lt;p&gt;Makefile Commands Overview&lt;br&gt;
Command Description&lt;br&gt;
make all    Builds and tests all VPCs with subnets.&lt;br&gt;
make vpc1   Creates VPC1 with public and private subnets.&lt;br&gt;
make vpc2   Creates VPC2 with public and private subnets.&lt;br&gt;
make clean  Removes all VPC namespaces, bridges, and iptables rules.&lt;br&gt;
Example Output (abridged)&lt;/p&gt;

&lt;p&gt;Creating VPC 'vpc2' with bridge 'br-vpc2'...&lt;br&gt;
IP forwarding enabled.&lt;br&gt;
NAT configured for outbound traffic via wlp2s0&lt;br&gt;
Bridge 'br-vpc2' created and ready.&lt;br&gt;
Adding public and private subnets to vpc2...&lt;br&gt;
Subnet vpc2-public added with IP 10.20.0.1/24&lt;br&gt;
Subnet vpc2-private added with IP 10.20.1.1/24&lt;br&gt;
VPC2 setup complete.&lt;br&gt;
Cleanup&lt;br&gt;
To delete all configurations and restore your host networking:&lt;/p&gt;

&lt;p&gt;make clean&lt;br&gt;
This removes:&lt;/p&gt;

&lt;p&gt;All network namespaces (ip netns delete)&lt;/p&gt;

&lt;p&gt;All VPC bridges&lt;/p&gt;

&lt;p&gt;Related veth pairs&lt;/p&gt;

&lt;p&gt;NAT and iptables rules&lt;/p&gt;

&lt;p&gt;Notes&lt;/p&gt;

&lt;p&gt;The project uses hardcoded CIDRs (10.10.0.0/16, 10.20.0.0/16, etc.) for clarity. These can be customized in the Makefile or passed as CLI arguments.&lt;/p&gt;

&lt;p&gt;Works best on Ubuntu/Debian-based systems with systemd networking.&lt;/p&gt;

&lt;p&gt;Run all commands with sudo for full permissions.&lt;/p&gt;

</description>
      <category>networking</category>
      <category>python</category>
      <category>linux</category>
      <category>cloudcomputing</category>
    </item>
  </channel>
</rss>
