7.5 KiB
pct create 100 /var/lib/vz/template/cache/openwrt-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype unmanaged --hostname openwrt-0 \
--password fuzzy817 --tag network --storage local-lvm --memory 256 --swap 128 \
--rootfs local-lvm:1,size=512M --net0 name=eth0,bridge=vmbr0,firewall=1 \
--net1 name=eth1,bridge=vmbr1,firewall=1 --cores 1 --cpuunits 500 --onboot 1 --debug 0
pct start 100
pct create 110 /var/lib/vz/template/cache/kali-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype debian --hostname kali-0 \
--password fuzzy817 --tag tools --storage zfs-disk0 --cores 2 \
--memory 2048 --swap 1024 --rootfs local-lvm:1,size=64G \
--net0 name=eth0,bridge=vmbr0,firewall=1 --cpuunits 1500 --onboot 1 \
--debug 0 --features nesting=1,keyctl=1
pct start 110
pct create 120 /var/lib/vz/template/cache/alpine-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype alpine --hostname alpine-0 \
--password fuzzy817 --tag docker --storage local-lvm --cores 2 \
--memory 1024 --swap 256 --rootfs local-lvm:1,size=8G \
--net0 name=eth0,bridge=vmbr0,firewall=1 --cpuunits 1000 --onboot 1 \
--debug 0 --features nesting=1,keyctl=1
pct start 120
Proxmox Container Setup Guide
Introduction
This guide provides detailed instructions for configuring OpenWRT, Alpine Linux, and Kali Linux containers on a Proxmox VE environment. Each section covers the creation, configuration, and basic setup steps necessary to get each type of container up and running, tailored for use in a lab setting.
Links
- Split A GPU Between Multiple Computers - Proxmox LXC (Unprivileged)
- Must-Have OpenWrt Router Setup For Your Proxmox
- Docker on Proxmox LXC 🚀 Zero Bloat and Pure Performance!
Prerequisites
- Proxmox VE installed on your server
- Access to Proxmox web interface or command-line interface
- Container templates downloaded (OpenWRT, Alpine, Kali Linux)
Container Configuration
OpenWRT Container Setup
Description
This section details setting up an OpenWRT container designed for network routing and firewall tasks.
Create and Configure the OpenWRT Container
pct create 100 /var/lib/vz/template/cache/openwrt-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype unmanaged --hostname openwrt-0 \
--password <password> --tag network --storage local-lvm --memory 256 --swap 128 \
--rootfs local-lvm:1,size=512M --net0 name=eth0,bridge=vmbr0,firewall=1 \
--net1 name=eth1,bridge=vmbr1,firewall=1 --cores 1 --cpuunits 500 --onboot 1 --debug 0
Start the Container and Access the Console
pct start 100
pct console 100
Update and Install Packages
opkg update
opkg install qemu-ga
reboot
Network and Firewall Configuration
Configure network settings and firewall rules:
vi /etc/config/network
/etc/init.d/network restart
vi /etc/config/firewall
/etc/init.d/firewall restart
# Setting up firewall rules using UCI
uci add firewall rule
uci set firewall.@rule[-1].name='Allow-SSH'
uci set firewall.@rule[-1].src='wan'
uci set firewall.@rule[-1].proto='tcp'
uci set firewall.@rule[-1].dest_port='22'
uci set firewall.@rule[-1].target='ACCEPT'
uci add firewall rule
uci set firewall.@rule[-1].name='Allow-HTTPS'
uci set firewall.@rule[-1].src='wan'
uci set firewall.@rule[-1].proto='tcp'
uci set firewall.@rule[-1].dest_port='443'
uci set firewall.@rule[-1].target='ACCEPT'
uci add firewall rule
uci set firewall.@rule[-1].name='Allow-HTTP'
uci set firewall.@rule[-1].src='wan'
uci set firewall.@rule[-1].proto='tcp'
uci set firewall.@rule[-1].dest_port='80'
uci set firewall.@rule[-1].target='ACCEPT'
uci commit firewall
/etc/init.d/firewall restart
Alpine Container Setup
Description
Set up an Alpine Linux container optimized for running Docker, ensuring lightweight deployment and management of Docker applications.
Create and Configure the Alpine Container
pct create 120 /var/lib/vz/template/cache/alpine-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype alpine --hostname alpine-0 \
--password <password> --tag docker --storage local-lvm --cores 2 \
--memory 1024 --swap 256 --rootfs local-lvm:1,size=8G \
--net0 name=eth0,bridge=vmbr0,firewall=1 --keyctl 1 --nesting 1 \
--cpuunits 1000 --onboot 1 --debug 0
Enter the Container
pct enter 120
System Update and Package Installation
Enable community repositories and install essential packages:
sed -i '/^#.*community/s/^#//' /etc/apk/repositories
apk update && apk upgrade
apk add qemu-guest-agent docker openssh sudo
Start and Enable Docker Service
rc-service docker start
rc-update add docker default
Configure Network
Set up network interfaces and restart networking services:
setup-interfaces
service networking restart
Configure and Start SSH Service
rc-update add sshd
service sshd start
vi /etc/ssh/sshd_config
service sshd restart
Create a System User and Add to Docker Group and Sudoers
adduser -s /bin/ash medusa
addgroup medusa docker
echo "medusa ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/medusa
Test Docker Installation
docker run hello-world
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
[Portainer Dashboard](https://localhost:9443)
Kali Linux Container Setup
Description
Configure a Kali Linux container tailored for security testing and penetration testing tools.
Create and Configure the Kali Linux Container
pct create 110 /var/lib/vz/template/cache/kali-default-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype debian --hostname kali-0 \
--password <password> --tag tools --storage local-lvm --cores 2 \
--memory 2048 --swap 1024 --rootfs local-lvm:1,size=10G \
--net0 name=eth0,bridge=vmbr0,firewall=1 --cpuunits 1500 --onboot 1 \
--debug 0 --features nesting=1,keyctl=1
Conclusion
Follow these steps to successfully set up and configure OpenWRT, Alpine, and Kali Linux containers on Proxmox. Adjust configurations according to your specific needs and ensure all passwords are secure before deploying containers in a production environment.
pct create 100 /var/lib/vz/template/cache/openwrt-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype unmanaged --hostname openwrt-0 \
--password <password> --tag network --storage local-lvm --memory 256 --swap 128 \
--rootfs local-lvm:1,size=512M --net0 name=eth0,bridge=vmbr0,firewall=1 \
--net1 name=eth1,bridge=vmbr1,firewall=1 --cores 1 --cpuunits 500 --onboot 1 --debug 0
pct create 110 /var/lib/vz/template/cache/kali-default-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype debian --hostname kali-0 \
--password <password> --tag tools --storage local-lvm --cores 2 \
--memory 2048 --swap 1024 --rootfs local-lvm:1,size=10G \
--net0 name=eth0,bridge=vmbr0,firewall=1 --cpuunits 1500 --onboot 1 \
--debug 0 --features nesting=1,keyctl=1
pct create 120 /var/lib/vz/template/cache/alpine-rootfs.tar.xz \
--unprivileged 1 --arch amd64 --ostype alpine --hostname alpine-0 \
--password <password> --tag docker --storage local-lvm --cores 2 \
--memory 1024 --swap 256 --rootfs local-lvm:1,size=8G \
--net0 name=eth0,bridge=vmbr0,firewall=1 --keyctl 1 --nesting 1 \
--cpuunits 1000 --onboot 1 --debug 0