Update tech_docs/virtualization/proxmox_dhcp.md
This commit is contained in:
@@ -1,73 +1,113 @@
|
||||
For your standalone Proxmox setup, switching between static and dynamic IP configurations and managing virtual bridges are important tasks. Below, I'll provide a concise guide to handle these changes effectively and safely.
|
||||
|
||||
**Prerequisites:**
|
||||
* You have SSH access to your Proxmox host.
|
||||
* You have `sudo` privileges or are logged in as root.
|
||||
* You know the name of your physical network interface connected to `vmbr0` (e.g., `enp3s0`, `eth0`). You can find this using `ip a`.
|
||||
|
||||
---
|
||||
|
||||
### Switching from Static IP to DHCP:
|
||||
|
||||
- **Backup Configurations:** Always backup configuration files before making changes (`cp /etc/network/interfaces /etc/network/interfaces.bak`).
|
||||
**Caution:** Changing network configurations can disrupt connectivity. Ensure you have a way to regain access (e.g., direct console access) if something goes wrong.
|
||||
|
||||
```bash
|
||||
cp /etc/network/interfaces /etc/network/interfaces.bak
|
||||
```
|
||||
1. **Backup Configurations:**
|
||||
Always backup configuration files before making changes. This allows for easy rollback if needed.
|
||||
```bash
|
||||
cp /etc/network/interfaces /etc/network/interfaces.bak
|
||||
```
|
||||
|
||||
**Update Network Interface Configuration:**
|
||||
Open `/etc/network/interfaces` in a text editor:
|
||||
```bash
|
||||
vim /etc/network/interfaces
|
||||
```
|
||||
- Change the `vmbr0` configuration from static to DHCP:
|
||||
```bash
|
||||
auto vmbr0
|
||||
iface vmbr0 inet dhcp
|
||||
bridge-ports enp3s0
|
||||
bridge-stp off
|
||||
bridge-fd 0
|
||||
```
|
||||
- Save the changes and exit the editor.
|
||||
|
||||
- **Restart Networking to Apply Changes:**
|
||||
- Apply the new network settings:
|
||||
```bash
|
||||
systemctl restart networking
|
||||
```
|
||||
|
||||
- **Find the New DHCP-Assigned IP Address:**
|
||||
- After the network restarts, check the assigned IP:
|
||||
```bash
|
||||
ip addr show vmbr0
|
||||
```
|
||||
|
||||
- **Update `/etc/hosts` with the New IP:**
|
||||
- Edit the `/etc/hosts` file to replace the old static IP with the new one:
|
||||
```bash
|
||||
nano /etc/hosts
|
||||
```
|
||||
- Modify the line with the old IP to the new one you just obtained:
|
||||
```plaintext
|
||||
192.168.86.62 whitebox.foxtrot.lan whitebox # Old IP
|
||||
192.168.x.x whitebox.foxtrot.lan whitebox # New DHCP IP
|
||||
```
|
||||
- Save and exit.
|
||||
|
||||
### Creating a New Virtual Bridge (`vmbrX`):
|
||||
|
||||
- **Add a New Virtual Bridge Configuration:**
|
||||
- Edit `/etc/network/interfaces`:
|
||||
2. **Update Network Interface Configuration:**
|
||||
Open `/etc/network/interfaces` in your preferred text editor (e.g., `vim` or `nano`):
|
||||
```bash
|
||||
vim /etc/network/interfaces
|
||||
```
|
||||
- Add a new bridge configuration at the end of the file:
|
||||
```bash
|
||||
auto vmbrX # Replace X with the next available number
|
||||
iface vmbrX inet manual
|
||||
bridge-ports none
|
||||
Locate the `vmbr0` configuration block and change it from static to DHCP. **Replace `<YOUR_PHYSICAL_NIC_HERE>` with your actual physical network interface name (e.g., `enp3s0`, `eth0`).**
|
||||
|
||||
**Before (Example Static):**
|
||||
```
|
||||
auto vmbr0
|
||||
iface vmbr0 inet static
|
||||
address 192.168.86.62/24
|
||||
gateway 192.168.86.1
|
||||
bridge-ports enp3s0
|
||||
bridge-stp off
|
||||
bridge-fd 0
|
||||
```
|
||||
- Save and exit the editor.
|
||||
|
||||
- **Activate the New Bridge:**
|
||||
- Restart the networking service to bring up the new bridge:
|
||||
**After (Example DHCP):**
|
||||
```
|
||||
auto vmbr0
|
||||
iface vmbr0 inet dhcp
|
||||
bridge-ports <YOUR_PHYSICAL_NIC_HERE>
|
||||
bridge-stp off
|
||||
bridge-fd 0
|
||||
```
|
||||
Save the changes and exit the editor.
|
||||
|
||||
3. **Restart Networking to Apply Changes:**
|
||||
Apply the new network settings. This will temporarily disrupt network connectivity.
|
||||
```bash
|
||||
systemctl restart networking
|
||||
```
|
||||
|
||||
4. **Find the New DHCP-Assigned IP Address:**
|
||||
After the network restarts, check the assigned IP address for `vmbr0`:
|
||||
```bash
|
||||
ip a show vmbr0
|
||||
```
|
||||
Note down the new IP address.
|
||||
|
||||
5. **Update `/etc/hosts` with the New IP:**
|
||||
Edit the `/etc/hosts` file to replace the old static IP with the new DHCP-assigned one. This is crucial for services and SSH access that rely on hostname resolution.
|
||||
```bash
|
||||
nano /etc/hosts
|
||||
```
|
||||
Find the line containing your Proxmox host's old IP and hostname (e.g., `192.168.86.62 whitebox.foxtrot.lan whitebox`) and **replace** the old IP address with the new one you just obtained.
|
||||
|
||||
**Example:**
|
||||
```plaintext
|
||||
# Before (your line will vary):
|
||||
# 192.168.86.62 whitebox.foxtrot.lan whitebox
|
||||
|
||||
# After (replace the old IP with your new DHCP IP):
|
||||
192.168.X.Y whitebox.foxtrot.lan whitebox
|
||||
```
|
||||
Save and exit.
|
||||
|
||||
---
|
||||
|
||||
### Creating a New Virtual Bridge (`vmbrX`):
|
||||
|
||||
This process creates an isolated virtual bridge, typically used for internal VM communication, not directly connected to a physical network interface.
|
||||
|
||||
1. **Add a New Virtual Bridge Configuration:**
|
||||
Edit `/etc/network/interfaces`:
|
||||
```bash
|
||||
vim /etc/network/interfaces
|
||||
```
|
||||
Add a new bridge configuration at the end of the file. To find the next available number for `vmbrX`, check existing `vmbr` entries in this file (e.g., if you have `vmbr0` and `vmbr1`, use `vmbr2`).
|
||||
|
||||
```bash
|
||||
auto vmbrX # Replace X with the next available number (e.g., vmbr1, vmbr2)
|
||||
iface vmbrX inet manual
|
||||
bridge-ports none # 'none' indicates it's not bound to a physical port
|
||||
bridge-stp off
|
||||
bridge-fd 0
|
||||
```
|
||||
Save and exit the editor.
|
||||
|
||||
2. **Activate the New Bridge:**
|
||||
Restart the networking service to bring up the new bridge.
|
||||
```bash
|
||||
systemctl restart networking
|
||||
```
|
||||
You can verify the bridge creation with `ip a show vmbrX` or `brctl show`.
|
||||
|
||||
---
|
||||
|
||||
### General Notes:
|
||||
|
||||
* **Validation:** After any network changes, always verify connectivity and functionality of your Proxmox host and virtual machines.
|
||||
* **Reverting Changes:** If you encounter issues, you can revert your `/etc/network/interfaces` file by copying the backup: `cp /etc/network/interfaces.bak /etc/network/interfaces` and then restarting the networking service.
|
||||
* **Console Access:** For critical network changes, having direct console access (physical keyboard/monitor or iLO/iDRAC/IPMI) is highly recommended as a fallback.
|
||||
Reference in New Issue
Block a user