Is it possible to set up internet access with OpenWrt running in a Proxmox virtual machine on a Raspberry Pi 4?
Details: I have one computer connected via LAN to a Raspberry Pi 4 with OpenWrt installed. From this Pi, I get internet via Wi-Fi. If I install Proxmox on the Raspberry Pi 4 and then create a virtual machine with OpenWrt inside it, will I be able to configure network forwarding to provide internet access from the main computer?
Yes, this is quite possible to set up. You can install Proxmox on a Raspberry Pi 4, create a virtual machine with OpenWrt inside it, and properly configure the network bridge to provide internet access from the main computer through your Wi-Fi network. For this, you will need to properly configure network interfaces in Proxmox, set up the virtual bridge, and specify the correct network settings in the OpenWrt VM.
Contents
- Setting up Proxmox on Raspberry Pi 4
- Creating an OpenWrt Virtual Machine
- Network Configuration in Proxmox
- OpenWrt VM Configuration
- Internet Forwarding from the Main Computer
- Testing and Troubleshooting
Setting up Proxmox on Raspberry Pi 4
First, you need to install Proxmox VE on your Raspberry Pi 4. The installation process includes several important steps:
- System Preparation: Make sure you have the latest version of Raspberry Pi OS (64-bit for better performance) installed
- Proxmox Installation: Follow the official instructions for installing Proxmox on ARM architecture
- System Update: After installation, update all packages to the latest versions
Important: Proxmox on Raspberry Pi 4 requires sufficient RAM (minimum 4GB recommended, 8GB better) and an SSD drive for stable operation.
After installing Proxmox, you will need to configure the network interfaces. It’s important to correctly identify which interface is physical (e.g., eth0 for LAN) and which will be used for Proxmox management.
Creating an OpenWrt Virtual Machine
Creating an OpenWrt virtual machine in Proxmox includes the following steps:
- Download OpenWrt Image: Download the latest OpenWrt image for x86_64 architecture
- Create VM: In the Proxmox web interface, select “Create VM”
- Configure Parameters:
- Type: QEMU/KVM Virtual Machine
- OS: Linux 5.x - 2.6 (64-bit)
- RAM: 512MB-1GB (depending on your needs)
- CPU: 1-2 cores
- Disk: 4-8GB
- Network: Configure the first network adapter
# Example command for creating VM via command line
qm create 100 --memory 512 --cores 2 --net0 virtio,bridge=vmbr0
qm set 100 --scsi0 local-lvm:vm-100-disk-0,4G
qm importdisk 100 /path/to/openwrt.img local-lvm
Network Configuration in Proxmox
Proper network configuration is a key aspect for providing internet access. Here are the main steps:
Setting up the Network Bridge
Open the network configuration file:
nano /etc/network/interfaces
Add the following configuration for the bridge:
auto vmbr0
iface vmbr0 inet static
address 192.168.1.1/24
gateway 192.168.1.254
bridge-ports eth0
bridge-stp off
bridge-fd 0
where:
eth0is your physical network interface192.168.1.1/24is the bridge IP address192.168.1.254is your main router/Gateway
Setting up NAT for Internet Access
If your main computer gets internet via Wi-Fi, you need to configure NAT:
# Install iptables
apt install iptables
# Configure NAT
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
iptables -A FORWARD -i vmbr0 -o wlan0 -j ACCEPT
iptables -A FORWARD -i wlan0 -o vmbr0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Save rules
iptables-save > /etc/iptables/rules.v4
OpenWrt VM Configuration
After creating the VM and booting OpenWrt, you need to configure the network inside the virtual machine:
- Connect to the VM via console or SSH
- Open the network configuration file:
nano /etc/config/network
- Configure interfaces:
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config device
option name 'br-lan'
option type 'bridge'
list ports 'eth0'
config interface 'lan'
option type 'bridge'
option ifname 'br-lan'
option proto 'static'
option ipaddr '192.168.100.1'
option netmask '255.255.255.0'
option gateway '192.168.1.1'
option dns '8.8.8.8 8.8.4.4'
- Restart the network:
/etc/init.d/network restart
Internet Forwarding from the Main Computer
To provide internet access from your main computer through your configuration:
- Configure the main computer to use a static IP address in the same subnet as the OpenWrt VM
- Specify the gateway as the OpenWrt VM IP address (192.168.100.1)
- Configure DNS servers (you can use the same ones as in OpenWrt)
Example configuration on the main computer (Linux):
ip addr add 192.168.100.100/24 dev eth0
ip route add default via 192.168.100.1
echo "nameserver 192.168.100.1" > /etc/resolv.conf
Additional Settings
If you need a more complex scenario with routing between networks:
# Enable packet forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# Configure routing in OpenWrt
uci add dhcp host
uci set dhcp.@host[-1].ip='192.168.100.100'
uci set dhcp.@host[-1].mac='MAC_OF_YOUR_COMPUTER'
uci set dhcp.@host[-1].name='main-pc'
uci commit dhcp
Testing and Troubleshooting
Connection Testing
- Test OpenWrt VM availability from the main computer:
ping 192.168.100.1
- Test internet access from the OpenWrt VM:
ping 8.8.8.8 curl google.com
- Test internet access from the main computer:
ping 8.8.8.8 curl google.com
Common Issues
-
No internet access:
- Check NAT settings in Proxmox
- Make sure forwarding is enabled:
cat /proc/sys/net/ipv4/ip_forward - Check routing:
ip route show
-
No connection to OpenWrt VM:
- Check subnet IP addresses
- Make sure the vmbr0 bridge is properly configured
- Check firewall in Proxmox and OpenWrt
-
Performance issues:
- Increase allocated RAM for the VM
- Use an SSD drive
- Optimize Wi-Fi settings
Tip: For network monitoring, use
iftopandnethogsto track traffic and identify bottlenecks.
Sources
- Proxmox VE Documentation - Network Configuration
- OpenWrt Documentation - Network Configuration
- Raspberry Pi 4 Proxmox Installation Guide
- Linux IP Forwarding and NAT Configuration
- Virtual Bridging with Proxmox
Conclusion
Setting up internet access with OpenWrt running in a Proxmox virtual machine on a Raspberry Pi 4 is quite feasible and provides flexible network management capabilities. Key points for successful setup include:
- Proper network bridge configuration in Proxmox
- Setting up NAT for traffic forwarding through Wi-Fi
- Correct network configuration inside the OpenWrt VM
- Thorough testing of all network connections
To get started, install Proxmox on your Raspberry Pi 4, create a VM with OpenWrt, and gradually configure network parameters, testing each stage. If problems arise, use diagnostic tools to identify and resolve issues.
This configuration will allow you to use your Raspberry Pi 4 as a flexible network node with virtualization capabilities, opening up additional opportunities for experimenting and developing your networking skills.