Last active
March 19, 2025 09:41
-
-
Save QNimbus/90595213f7a765390a3fa6a9f02966fa to your computer and use it in GitHub Desktop.
Proxmox #proxmox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# network interface settings; autogenerated | |
# Please do NOT modify this file directly, unless you know what | |
# you're doing. | |
# | |
# If you want to manage parts of the network configuration manually, | |
# please utilize the 'source' or 'source-directory' directives to do | |
# so. | |
# PVE will preserve these directives, but will NOT read its network | |
# configuration from sourced files, so do not attempt to move any of | |
# the PVE managed interfaces into external files! | |
auto lo | |
iface lo inet loopback | |
# SFPP+ Ports | |
iface eno1 inet manual | |
iface eno2 inet manual | |
iface eno3 inet manual | |
iface eno4 inet manual | |
# RJ45 Ports | |
iface enp4s0 inet manual | |
iface enp5s0 inet manual | |
iface enp6s0 inet manual | |
iface enp7s0 inet manual | |
# WAN Interface | |
iface enp8s0 inet manual | |
auto bond0 | |
iface bond0 inet manual | |
bond-slaves eno1 eno2 eno3 eno4 enp7s0 | |
bond-mode active-backup | |
bond-miimon 500 | |
bond-primary eno1 | |
auto vmbr0 | |
iface vmbr0 inet manual | |
bridge-ports bond0 enp4s0 enp5s0 enp6s0 | |
bridge-stp off | |
bridge-fd 0 | |
bridge-vlan-aware yes | |
bridge-vids 2-4094 | |
post-up /sbin/bridge vlan add vid 30 dev enp6s0 pvid untagged | |
pre-down /sbin/bridge vlan del vid 30 dev enp6s0 pvid untagged | |
#Local network RJ45 | |
auto vmbr0.10 | |
iface vmbr0.10 inet static | |
address 10.10.0.2/24 | |
#SkyNet | |
auto vmbr0.100 | |
iface vmbr0.100 inet static | |
address 10.100.0.2/24 | |
gateway 10.100.0.11 | |
#SkyNet Management | |
auto vmbr1 | |
iface vmbr1 inet manual | |
bridge-ports enp8s0 | |
bridge-stp off | |
bridge-fd 0 | |
bridge-vlan-aware yes | |
bridge-vids 4,6 | |
#WAN (KPN PPPoE) | |
source /etc/network/interfaces.d/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# network interface settings; autogenerated | |
# Please do NOT modify this file directly, unless you know what | |
# you're doing. | |
# | |
# If you want to manage parts of the network configuration manually, | |
# please utilize the 'source' or 'source-directory' directives to do | |
# so. | |
# PVE will preserve these directives, but will NOT read its network | |
# configuration from sourced files, so do not attempt to move any of | |
# the PVE managed interfaces into external files! | |
auto lo | |
iface lo inet loopback | |
iface eno1 inet manual | |
auto vmbr0 | |
iface vmbr0 inet manual | |
bridge-ports eno1 | |
bridge-stp off | |
bridge-fd 0 | |
bridge-vlan-aware yes | |
bridge-vids 2-4094 | |
auto vmbr0.10 | |
iface vmbr0.10 inet static | |
address 10.10.0.3/24 | |
#SkyNet | |
auto vmbr0.100 | |
iface vmbr0.100 inet static | |
address 10.100.0.3/24 | |
gateway 10.100.0.11 | |
#SkyNet Management | |
source /etc/network/interfaces.d/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# network interface settings; autogenerated | |
# Please do NOT modify this file directly, unless you know what | |
# you're doing. | |
# | |
# If you want to manage parts of the network configuration manually, | |
# please utilize the 'source' or 'source-directory' directives to do | |
# so. | |
# PVE will preserve these directives, but will NOT read its network | |
# configuration from sourced files, so do not attempt to move any of | |
# the PVE managed interfaces into external files! | |
auto lo | |
iface lo inet loopback | |
auto eno1 | |
iface eno1 inet manual | |
auto eno2 | |
iface eno2 inet manual | |
iface enx620f58a7b3f5 inet manual | |
iface enxc6e7015760f0 inet manual | |
#auto bond0 | |
#iface bond0 inet manual | |
# bond-slaves eno1 eno2 | |
# bond-miimon 500 | |
# bond-mode 802.3ad | |
# bond-xmit-hash-policy layer2+3 | |
#LACP 802.3ad bonded interfaces | |
auto vmbr0 | |
iface vmbr0 inet manual | |
bridge-ports eno1 eno2 | |
bridge-stp off | |
bridge-fd 0 | |
bridge-vlan-aware yes | |
bridge-vids 2-4094 | |
#Physical network bridge (VLAN aware) | |
auto vmbr0.10 | |
iface vmbr0.10 inet static | |
address 10.10.0.4/24 | |
gateway 10.10.0.1 | |
#SkyNet | |
auto vmbr0.100 | |
iface vmbr0.100 inet static | |
address 10.100.0.4/24 | |
gateway 10.100.0.11 | |
#SkyNet Management | |
auto vmbr1 | |
iface vmbr1 inet static | |
bridge-ports none | |
bridge-stp off | |
bridge-fd 0 | |
#Proxmox internal network | |
source /etc/network/interfaces.d/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# --------------------------------------------------------------------- | |
# Hostname Change Script for Proxmox Nodes | |
# | |
# Author: B. van Wetten | |
# Creation Date: 2025-02-10 | |
# Last Update: 2025-02-10 | |
# | |
# Description: This script changes the Proxmox host/node hostname, | |
# backs up and restores QEMU configuration, updates /etc/hosts, | |
# restarts Proxmox services, checks for LXC containers, | |
# and optionally reboots the host. | |
# | |
# Usage: Run this script as root. | |
# | |
# Note: Ensure that you have backups and proper permissions before | |
# executing this script. | |
# | |
# Download: wget https://gist.githubusercontent.com/QNimbus/90595213f7a765390a3fa6a9f02966fa/raw/proxmox-node-rename.sh | |
# --------------------------------------------------------------------- | |
set -euo pipefail | |
# Ensure the script is run as root | |
if [[ $EUID -ne 0 ]]; then | |
echo "This script must be run as root." | |
exit 1 | |
fi | |
# Check for LXC containers on the host and display a caution if any are found. | |
check_lxc_containers() { | |
if command -v pct >/dev/null 2>&1; then | |
# 'pct list' prints a header line, so skip it | |
local lxc_count | |
lxc_count=$(pct list | tail -n +2 | wc -l) | |
if [[ "$lxc_count" -gt 0 ]]; then | |
echo "Caution: Detected ${lxc_count} LXC container(s) on this host." | |
echo "Migrating LXC containers has not been tested yet." | |
echo "Please ensure you have proper backups before proceeding." | |
echo | |
fi | |
else | |
echo "Warning: 'pct' command not found. Skipping LXC container check." | |
fi | |
} | |
check_lxc_containers | |
change_hostname() { | |
local original_hostname | |
original_hostname=$(hostname) | |
read -rp "Enter new hostname: " new_hostname | |
if [[ -z "$new_hostname" ]]; then | |
echo "Error: New hostname cannot be empty." | |
exit 1 | |
fi | |
local qemu_src="/etc/pve/nodes/${original_hostname}/qemu-server" | |
local qemu_tmp="/tmp/qemu" | |
local qemu_dst="/etc/pve/nodes/${new_hostname}/qemu-server" | |
# Backup QEMU configuration if available | |
if [[ -d "$qemu_src" && "$(ls -A "$qemu_src" 2>/dev/null)" ]]; then | |
echo "Backing up QEMU configs from ${qemu_src} to ${qemu_tmp}..." | |
mkdir -p "$qemu_tmp" | |
cp -a "$qemu_src/"* "$qemu_tmp/" | |
else | |
echo "No QEMU configurations found. Skipping backup." | |
fi | |
# Change the system hostname | |
echo "Changing hostname from ${original_hostname} to ${new_hostname}..." | |
hostnamectl set-hostname "$new_hostname" | |
# Update /etc/hosts with a word-boundary based replacement | |
echo "Updating /etc/hosts..." | |
sed -i "s/\b${original_hostname}\b/${new_hostname}/g" /etc/hosts | |
# Restart Proxmox services | |
local services=("pveproxy.service" "pvebanner.service" "pve-cluster.service" "pvestatd.service" "pvedaemon.service") | |
echo "Restarting Proxmox services..." | |
for service in "${services[@]}"; do | |
if systemctl restart "$service"; then | |
echo "Successfully restarted $service." | |
else | |
echo "Warning: Failed to restart $service." | |
fi | |
done | |
# Update node directory and restore QEMU configuration if backup exists | |
if [[ -d "$qemu_tmp" && "$(ls -A "$qemu_tmp" 2>/dev/null)" ]]; then | |
echo "Creating new node directory for ${new_hostname}..." | |
mkdir -p "$qemu_dst" | |
cp -a "$qemu_tmp/"* "$qemu_dst/" | |
echo "QEMU configuration moved to ${qemu_dst}." | |
else | |
echo "No QEMU backup found. Skipping restore." | |
fi | |
echo "Hostname update completed successfully." | |
} | |
change_hostname | |
# Prompt the user to reboot the host | |
read -rp "Do you want to reboot the host now? (y/N): " reboot_choice | |
reboot_choice=${reboot_choice,,} # Convert input to lowercase | |
if [[ "$reboot_choice" == "y" || "$reboot_choice" == "yes" ]]; then | |
echo "Rebooting host..." | |
reboot | |
else | |
echo "Reboot canceled. Please reboot the host manually later to apply all changes." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment