Update docs/tech_docs/OpenWrt.md

This commit is contained in:
2024-04-22 00:15:39 +00:00
parent da330fb768
commit befbbdb2c2

View File

@@ -15,61 +15,38 @@
- [pct commands](https://git.crazystorm.xyz/medusa/the_information_nexus/src/branch/main/docs/tech_docs/pct.md)
---
# Proxmox Container Setup Guide
This guide provides step-by-step instructions for setting up OpenWRT, Kali Linux, and Alpine Linux containers on Proxmox.
## OpenWRT Container Setup
### Commands
### Create and Configure the OpenWRT Container
```bash
# 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 changeme --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 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
### Start the Container and Access the Console
```bash
pct start 100
```
# Access the container's console
```bash
pct console 100
```
# Update and install packages
### Update and Install Packages
```bash
opkg update
```
```bash
opkg install qemu-ga
```
```bash
reboot
```
# Network and firewall configuration
### Network and Firewall Configuration
```bash
vi /etc/config/network
```
```bash
/etc/init.d/network restart
```
```bash
vi /etc/config/firewall
```
```bash
/etc/init.d/firewall restart
```
```bash
vi /etc/config/firewall
```
```bash
uci add firewall rule
uci set firewall.@rule[-1].name='Allow-SSH'
uci set firewall.@rule[-1].src='wan'
@@ -90,108 +67,67 @@ 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'
```
```bash
uci commit firewall
/etc/init.d/firewall restart
```
```bash
/etc/init.d/firewall restart
```
---
## Alpine Container Setup
### Commands
### Create and Configure the Alpine Container
```bash
# Create and configure the Alpine container
pct create 300 /var/lib/vz/template/cache/alpine-rootfs.tar.xz --unprivileged 1 --arch amd64 --ostype alpine --hostname alpine-0 --password changeme --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
pct create 300 /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
### Enter the Container
```bash
pct enter 300
```
# System update and Docker installation
### System Update and Package Installation
```bash
sed -i '/^#.*community/s/^#//' /etc/apk/repositories
```
```bash
apk update && apk upgrade
apk add qemu-guest-agent docker openssh sudo
```
```bash
apk add qemu-guest-agent newt curl openssh mc sudo build-base gcc abuild binutils binutils-doc gcc-doc docker
```
### Start and Enable Docker Service
```bash
rc-service docker start
```
```bash
rc-update add docker default
```
# Configure network and SSH
### Configure Network
```bash
setup-interfaces
```
```bash
service networking restart
```
```bash
apk add openssh
```
### Configure and Start SSH Service
```bash
rc-update add sshd
```
```bash
service sshd start
```
# Configure and start SSH service
```bash
vi /etc/ssh/sshd_config
```
```bash
service sshd restart
```
# Create a system user and add them to the docker group and sudoers
### Create a System User and Add to Docker Group and Sudoers
```bash
adduser -s /bin/ash medusa
```
```bash
addgroup medusa docker
echo "medusa ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/medusa
```
```bash
visudo
```
# Test Docker installation
### Test Docker Installation
```bash
docker run hello-world
```
---
## Kali Linux Container Setup
# Create and configure the Kali Linux container
### Create and Configure the Kali Linux Container
```bash
pct create 200 /var/lib/vz/template/cache/kali-default-rootfs.tar.xz --unprivileged 1 --arch amd64 --ostype debian --hostname kali-0 --password changeme --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 200 /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
```
With these steps, you'll have OpenWRT, Alpine Linux with Docker, and Kali Linux containers set up on your Proxmox environment. Remember to adjust the configurations, usernames, and passwords according to your specific requirements and security best practices.