Skip to content

Instantly share code, notes, and snippets.

@suuhm
Last active March 6, 2025 04:23
Show Gist options
  • Save suuhm/053f819b000bee4af922d66ff6c5d32e to your computer and use it in GitHub Desktop.
Save suuhm/053f819b000bee4af922d66ff6c5d32e to your computer and use it in GitHub Desktop.
Setup OpenWrt 23.05 LXC Container in Proxmox - Updated Version: 2024
#!/bin/bash
# Setting Up OpenWRT on a Virtual Machine with Proxmox
# Based on: https://community.bigbeartechworld.com/t/setting-up-openwrt-on-a-virtual-machine-with-proxmox/257
# Set your wished version:
export VER="23.05"
export ARCH="amd64"
export INDEX_URL="https://images.linuxcontainers.org/images/openwrt/$VER/$ARCH/default"
#export BUILDDATE=$(date -d "yesterday" '+%Y%m%d')
export BUILDDATE=$(curl -sL $INDEX_URL | grep "<a href=" | sed -E 's/.*<a href="([^"]+)".*/\1/' | sort | tail -n 1 | tr -d \/)
export BD_URL="$INDEX_URL/$BUILDDATE"
echo; echo "[*] Setting Up OpenWRT Version $VER on a Virtual Machine with Proxmox"
echo "[*] Downloading by $BD_URL/ "
sleep 2
wget $BD_URL/rootfs.tar.xz -O /var/lib/vz/template/cache/OpenWrt-$VER.tar.xz
# lvm disk: 1G - RAM 1G - CPU 1Core 64bit
#
pct create 202 /var/lib/vz/template/cache/OpenWrt-$VER.tar.xz --arch $ARCH --hostname OpenWrt-$VER --rootfs local-lvm:1 --memory 1024 --cores 1 --ostype unmanaged --unprivileged 1
echo -e "
Add network on interface and setup network file via dhcp
(vi /etc/config/network):
config interface 'wrtb'
option type 'bridge'
option ifname 'eth0'
option proto 'dhcp'
"
exit 0;
@walterzilla
Copy link

walterzilla commented Sep 8, 2024

@rickicode script seems unable to download OpenWRT image:

Please enter the Container ID you want to use: 100
Please enter the Container Name (hostname) [OpenWrt-23.05]: openwrt
Available disks:
1. local
Please select the disk (1-1): 1
Formatting '/var/lib/vz/images/100/vm-100-disk-0.raw', fmt=raw size=1073741824 preallocation=off
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: 586dfa43-6d64-4d0a-9acb-3dea5f275d96
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376
unable to create CT 100 - can't find file '/var/lib/vz/template/cache/OpenWrt-23.05.tar.xz'

Maybe just missing something like wget $BD_URL/rootfs.tar.xz -O /var/lib/vz/template/cache/OpenWrt-$VER.tar.xz?

@jaminmc
Copy link

jaminmc commented Mar 4, 2025

I created a new script that downloads the current, or snapshot from OpenWrt directly, and it allows you to specify all the options as prompts. Including the Interface/bridge for WAN, and LAN, Autodetect next available container ID, and even specify what IPv4 subnet you want to use. If you want to install the Snapshot version, it will even prompt you if you want it to auto install LuCi.

https://gist.github.com/jaminmc/7e786a8947746439f7b8a8e2726e629d

@bao3
Copy link

bao3 commented Mar 6, 2025

I created a new script that downloads the current, or snapshot from OpenWrt directly, and it allows you to specify all the options as prompts. Including the Interface/bridge for WAN, and LAN, Autodetect next available container ID, and even specify what IPv4 subnet you want to use. If you want to install the Snapshot version, it will even prompt you if you want it to auto install LuCi.

https://gist.github.com/jaminmc/7e786a8947746439f7b8a8e2726e629d

Thanks ~~~~ good work~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment