A tool for testing network behavior by deploying multiple containers with DHCP-assigned IP addresses to a local network.
go-ipocalypse creates a macvlan network and launches containers that:
- Obtain IP addresses via DHCP
- Can be configured with or without internet access
- Run custom testing workloads
- Scale up until the IP address space is exhausted
- Linux host with Docker installed
sudo
access (required for network configuration)ipcalc
package (will be automatically installed if missing)
git clone https://github.com/yourusername/go-ipocalypse
cd go-ipocalypse
go build
Basic usage:
sudo ./ipocalypse
-dockerfiles
(optional): Comma-separated list of directories containing Dockerfiles.- Must start with "ipocalypse".
- If not specified, automatically discovers all ipocalypse* directories.
-workers
(default: 5): Number of concurrent container launch workers-internet
(default: false): Enable internet access for containers
ipocalypse_basic_image
has no functionality beyond connecting to the local network. Add your own custom Dockerfiles to additional directories to deploy containers with other workloads. Additional directories must start withipocalypse_
to be discovered. Example:ipocalypse_<name_of_workload>
.
sudo ./ipocalypse -dockerfiles ipocalypse_basic_image,ipocalypse_workload1 -workers 10 -internet
ipocalypse will:
- Create a Docker macvlan network "ipocalypse_net"
- Set up a host macvlan interface for container communication
- Configure NAT if internet access is enabled
- Launch containers using images from all ipocalypse* directories until ip addresses are exhausted
To stop all running containers:
docker stop $(docker ps -a -q)
To remove all containers:
docker rm $(docker ps -a -q)
To clean up the network configuration:
sudo utils/cleanup_network.sh
- Create a new directory starting with "ipocalypse"
- Add a Dockerfile and any required scripts
- Ensure the container runs continuously and handles DHCP configuration
Example basic image structure:
ipocalypse_basic_image/
├── Dockerfile
└── entrypoint.sh
The entrypoint.sh
for the ipocalypse_basic_image ensures each container properly joins the network and maintains its network connection by handling:
1. Network Setup:
- Detects and configures the container's network interface
- Attempts to obtain an IP address via DHCP (tries up to 3 times)
- Handles cleanup of DHCP leases on container shutdown
2. Monitoring:
- Keeps the container running indefinitely
- Logs network status every 60 seconds
- Shows IP address and routing information
3. Error Handling:
- Provides detailed debugging output
- Gracefully handles failures in interface detection or DHCP
- Implements proper signal handling for clean container shutdown
Configure functionality for other container images by copying this script to new ipocalypse_* Dockerfile directories and modifying the script as needed.