A script to automatically fix network interface configuration in Proxmox VE (PVE) when PCIe network cards are plugged/unplugged or replaced, causing network card sequence numbers to change.
When using PCIe network cards in Proxmox VE, inserting/removing or replacing PCIe hardware can cause network card sequence numbers to change. For example, a network card that was previously enp3s0 might become enp6s0 after hardware changes, breaking the network configuration.
This script automatically:
- Detects RTL8111/8168/8211/8411 PCIe network cards
- Extracts the current PCIe sequence number
- Updates
/etc/network/interfaceswith the correct interface name - Optionally restarts networking services
- ✅ Automatic detection of RTL8111/8168/8211/8411 network cards
- ✅ Safe backup of current configuration before changes
- ✅ Dry-run mode to preview changes
- ✅ Systemd service for automatic boot-time execution
- ✅ Colored output for better readability
- ✅ Comprehensive error handling and logging
- ✅ Easy installation and uninstallation
pve-pcie-netfix.sh- Main scriptpve-pcie-netfix.service- Systemd service fileinstall.sh- Installation scriptREADME.md- This documentation
# Clone the repository
git clone https://github.com/gitsang/pve-pcie-netfix.git
cd pve-pcie-netfix
# Install the service (requires root)
sudo ./install.sh# Run the script manually
sudo ./pve-pcie-netfix.sh
# Dry run to see what would change
sudo ./pve-pcie-netfix.sh --dry-run
# Show current network status
sudo ./pve-pcie-netfix.sh --statusThe installation script will:
- Copy the script to
/usr/local/bin/ - Install the systemd service
- Enable automatic execution at boot
- Test the service
sudo ./install.shIf you prefer manual installation:
# Copy script to system directory
sudo cp pve-pcie-netfix.sh /usr/local/bin/
sudo chmod +x /usr/local/bin/pve-pcie-netfix.sh
# Install systemd service
sudo cp pve-pcie-netfix.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable pve-pcie-netfix.service
# Test the service
sudo systemctl start pve-pcie-netfix.service# Show help
./pve-pcie-netfix.sh --help
# Run normally (interactive)
sudo ./pve-pcie-netfix.sh
# Dry run (no changes made)
sudo ./pve-pcie-netfix.sh --dry-run
# Show current network status
sudo ./pve-pcie-netfix.sh --status# Show help
./install.sh --help
# Install normally
sudo ./install.sh
# Install but don't enable auto-start
sudo ./install.sh --test-only
# Uninstall
sudo ./install.sh --uninstall-
Uses
lspcito find RTL8111/8168/8211/8411 network cards:lspci | grep Ethernet | grep "RTL8111/8168/8211/8411"
-
Extracts PCIe sequence number from output like:
06:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8211/8411 PCI Express Gigabit Ethernet Controller (rev 15)The sequence number is
6(from06:00.0).
The script updates /etc/network/interfaces by replacing the interface name in the bridge-ports line:
Before:
bridge-ports enp3s0
After:
bridge-ports enp6s0
- Backups are stored in
/etc/network/backup/ - Filename format:
interfaces_YYYYMMDD_HHMMSS - Automatic backup before any changes
The service runs at boot time before network services start:
- Service file:
/etc/systemd/system/pve-pcie-netfix.service - Execution order: After
network-pre.target, beforenetwork.target - Type:
oneshot(runs once and exits)
# Check service status
systemctl status pve-pcie-netfix.service
# View service logs
journalctl -u pve-pcie-netfix.service
# Start service manually
sudo systemctl start pve-pcie-netfix.service
# Enable/disable auto-start
sudo systemctl enable pve-pcie-netfix.service
sudo systemctl disable pve-pcie-netfix.serviceThe script works with standard PVE bridge configurations:
auto lo
iface lo inet loopback
iface enp6s0 inet manual
auto vmbr0
allow-hotplug vmbr0
iface vmbr0 inet static
address 192.168.5.200/24
gateway 192.168.5.1
bridge-ports enp6s0
bridge-stp off
bridge-fd 0
iface vmbr0 inet6 auto
source /etc/network/interfaces.d/*Currently supports Realtek network cards:
- RTL8111
- RTL8168
- RTL8211
- RTL8411
The detection pattern can be easily modified in the script to support other network cards.
-
Script requires root privileges
sudo ./pve-pcie-netfix.sh
-
No network card detected
- Verify your network card is supported
- Check with:
lspci | grep Ethernet
-
Service fails to start
# Check service logs journalctl -u pve-pcie-netfix.service # Check script logs sudo /usr/local/bin/pve-pcie-netfix.sh --dry-run
- Service logs:
journalctl -u pve-pcie-netfix.service - Network backups:
/etc/network/backup/ - System logs:
/var/log/syslog
- Automatic backups before any changes
- Dry-run mode to preview changes
- Validation of changes before applying
- Error handling with detailed messages
- Rollback capability using backup files
# Using the installation script
sudo ./install.sh --uninstall
# Manual uninstallation
sudo systemctl disable pve-pcie-netfix.service
sudo systemctl stop pve-pcie-netfix.service
sudo rm /etc/systemd/system/pve-pcie-netfix.service
sudo rm /usr/local/bin/pve-pcie-netfix.sh
sudo systemctl daemon-reload- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
# Test without making changes
sudo ./pve-pcie-netfix.sh --dry-run
# Test installation without enabling
sudo ./install.sh --test-onlyThis project is licensed under the MIT License - see the LICENSE file for details.
- Initial release
- Automatic RTL8111/8168/8211/8411 detection
- Systemd service integration
- Backup and safety features
- Comprehensive installation script
If you encounter issues:
- Check the Troubleshooting section
- Review service logs:
journalctl -u pve-pcie-netfix.service - Run in dry-run mode:
sudo ./pve-pcie-netfix.sh --dry-run - Open an issue on GitHub
- Designed for Proxmox VE environments
- Supports common Realtek network cards
- Follows systemd best practices