- Points
- 178
To assign a static IP address to a VM in Proxmox VE, you'll need to configure the network settings inside the VM's operating system. Here’s a step-by-step guide on how to do this, assuming you're using AlmaLinux (or a similar Linux distribution):
or
1. Access the VM Console
- Open Proxmox VE Web Interface:
- Navigate to your Proxmox VE web interface.
- Select Your VM:
- Click on the VM you want to configure.
- Open the Console:
- Go to the "Console" tab to access the VM’s console.
2. Configure Network Settings Inside the VM
You need to configure the network settings inside the VM's operating system to assign the static IP address. Here’s how to do it for AlmaLinux and similar Linux distributions:For AlmaLinux 8 (or CentOS/RHEL 8)
- Log into the VM:
- Log in using your root or a user with sudo privileges.
- Edit the Network Configuration File:
- The network configuration files are located in /etc/sysconfig/network-scripts/. Find the appropriate file, usually named ifcfg-eth0 or ifcfg-enp0s3 (the name might differ based on your network interface).
Code:
nano /etc/sysconfig/network-scripts/ifcfg-eth0
Code:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
- Modify the Configuration File:
- Change the file to configure the static IP. Here’s an example configuration for a static IP:
Code:TYPE=Ethernet BOOTPROTO=static NAME=eth0 DEVICE=eth0 ONBOOT=yes IPADDR=31.172.XX.XXX NETMASK=255.255.255.0 GATEWAY=31.172.XX.X DNS1=8.8.8.8 DNS2=8.8.4.4
- Replace eth0 with your network interface name if it's different, and set the IPADDR, NETMASK, GATEWAY, DNS1, and DNS2 values according to your network configuration.
- Change the file to configure the static IP. Here’s an example configuration for a static IP:
- Restart the Network Service:
- Apply the changes by restarting the network service:
Code:systemctl restart network
- Alternatively, you can reboot the VM:
Code:reboot
- Apply the changes by restarting the network service:
For AlmaLinux 9 (or CentOS/RHEL 9)
- Log into the VM:
- Log in using your root or a user with sudo privileges.
- Use nmcli to Configure Network:
- For newer systems using NetworkManager, you can configure the static IP using nmcli:
Code:nmcli con show
Code:nmcli con mod "YourConnectionName" ipv4.addresses 31.172.XX.XXX/24 nmcli con mod "YourConnectionName" ipv4.gateway 31.172.XX.X nmcli con mod "YourConnectionName" ipv4.dns "8.8.8.8 8.8.4.4" nmcli con mod "YourConnectionName" ipv4.method manual nmcli con up "YourConnectionName"
- Replace "YourConnectionName" with the actual name of your network connection.
- For newer systems using NetworkManager, you can configure the static IP using nmcli:
3. Verify the Static IP Configuration
- Check the IP Address:
- Use the ip command to verify the IP address:
Code:ip a
- Ensure the interface has the correct static IP assigned.
- Use the ip command to verify the IP address:
- Test Connectivity:
- Test network connectivity to ensure the VM can reach external networks:
Code:ping -c 4 google.com
- Test connectivity to other devices on your network.
- Test network connectivity to ensure the VM can reach external networks:
4. Proxmox VE Network Configuration (Optional)
If you need to ensure that your VM is properly connected to the Proxmox network bridge:- Check Network Configuration:
- Verify that the VM's network adapter is connected to the correct bridge (e.g., vmbr0):
- Go to the "Hardware" tab of your VM in the Proxmox web interface.
- Ensure the network device is set to the correct bridge.
- Verify that the VM's network adapter is connected to the correct bridge (e.g., vmbr0):
- Apply and Save Changes:
- Make sure any changes are applied and saved.
Summary
- Configure the VM's network interface inside the OS to use a static IP address.
- Restart the network service or reboot the VM to apply the changes.
- Verify the IP address and network connectivity.