115 lines
3.4 KiB
Markdown
115 lines
3.4 KiB
Markdown
|
|
# VMID to IP Address Mapping System
|
||
|
|
|
||
|
|
## Overview
|
||
|
|
|
||
|
|
This document describes a systematic approach to mapping VMIDs to IP addresses for better network management and organization.
|
||
|
|
|
||
|
|
## Mapping Strategy
|
||
|
|
|
||
|
|
### Current Network: 192.168.11.0/24
|
||
|
|
|
||
|
|
For the 192.168.11.X network, we use VMID-based IP assignment:
|
||
|
|
|
||
|
|
| VMID Pattern | IP Mapping | Example | Notes |
|
||
|
|
|-------------|------------|---------|-------|
|
||
|
|
| **4-digit (2400-2499)** | Last 2 digits = last octet | VMID 2400 → 192.168.11.240 | Direct alignment |
|
||
|
|
| **4-digit (2500-2599)** | Last 2 digits = last octet | VMID 2500 → 192.168.11.250 | Direct alignment |
|
||
|
|
|
||
|
|
### Future Network Expansion
|
||
|
|
|
||
|
|
For future VLAN-based networks, use the following patterns:
|
||
|
|
|
||
|
|
| VMID Pattern | Network | IP Mapping | Example |
|
||
|
|
|-------------|---------|------------|---------|
|
||
|
|
| **3-digit (100-999)** | 192.168.0.X | Last 3 digits = last octet | VMID 101 → 192.168.0.101 |
|
||
|
|
| **4-digit (1000-1099)** | 192.168.1.X | Last 3 digits = last octet | VMID 1001 → 192.168.1.1 |
|
||
|
|
| **4-digit (1100-1199)** | 192.168.1.X | Last 2 digits = last octet | VMID 1101 → 192.168.1.101 |
|
||
|
|
| **5-digit (10000-10999)** | 192.168.10.X | Last 3 digits = last octet | VMID 10101 → 192.168.10.101 |
|
||
|
|
|
||
|
|
## Implementation
|
||
|
|
|
||
|
|
### Function: `vmid_to_ip()`
|
||
|
|
|
||
|
|
```bash
|
||
|
|
vmid_to_ip() {
|
||
|
|
local vmid=$1
|
||
|
|
local base_network="${2:-192.168.11}"
|
||
|
|
|
||
|
|
# For 4-digit VMIDs in 192.168.11.X network
|
||
|
|
if [[ $vmid =~ ^[0-9]{4}$ ]] && [[ "$base_network" == "192.168.11" ]]; then
|
||
|
|
local last_octet=$((vmid % 1000))
|
||
|
|
# Ensure last octet is in valid range (1-254, since .255 is broadcast)
|
||
|
|
if [[ $last_octet -ge 1 ]] && [[ $last_octet -le 254 ]]; then
|
||
|
|
echo "${base_network}.${last_octet}"
|
||
|
|
return 0
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
return 1
|
||
|
|
}
|
||
|
|
```
|
||
|
|
|
||
|
|
### Usage Example
|
||
|
|
|
||
|
|
```bash
|
||
|
|
# Get IP for VMID 2400
|
||
|
|
IP=$(vmid_to_ip 2400)
|
||
|
|
echo "$IP" # Output: 192.168.11.240
|
||
|
|
|
||
|
|
# Get IP for VMID 2401
|
||
|
|
IP=$(vmid_to_ip 2401)
|
||
|
|
echo "$IP" # Output: 192.168.11.241
|
||
|
|
```
|
||
|
|
|
||
|
|
## Current Allocations (192.168.11.0/24)
|
||
|
|
|
||
|
|
### Infrastructure IPs
|
||
|
|
- `.1` - Gateway (ER605-A)
|
||
|
|
- `.8` - Omada Controller
|
||
|
|
- `.10-14` - Proxmox Hosts (ml110, r630-01 through r630-04)
|
||
|
|
|
||
|
|
### Besu Validators (VMIDs 1000-1004)
|
||
|
|
- VMID 1000 → 192.168.11.100
|
||
|
|
- VMID 1001 → 192.168.11.101
|
||
|
|
- VMID 1002 → 192.168.11.102
|
||
|
|
- VMID 1003 → 192.168.11.103
|
||
|
|
- VMID 1004 → 192.168.11.104
|
||
|
|
|
||
|
|
### Besu Sentries (VMIDs 1500-1503)
|
||
|
|
- VMID 1500 → 192.168.11.150
|
||
|
|
- VMID 1501 → 192.168.11.151
|
||
|
|
- VMID 1502 → 192.168.11.152
|
||
|
|
- VMID 1503 → 192.168.11.153
|
||
|
|
|
||
|
|
### Besu RPC Nodes (VMIDs 2500-2502)
|
||
|
|
- VMID 2500 → 192.168.11.250
|
||
|
|
- VMID 2501 → 192.168.11.251
|
||
|
|
- VMID 2502 → 192.168.11.252
|
||
|
|
|
||
|
|
### ThirdWeb RPC Nodes (VMIDs 2400-2402)
|
||
|
|
- VMID 2400 → 192.168.11.240
|
||
|
|
- VMID 2401 → 192.168.11.241
|
||
|
|
- VMID 2402 → 192.168.11.242
|
||
|
|
|
||
|
|
## Benefits
|
||
|
|
|
||
|
|
1. **Predictable**: VMID directly maps to IP address
|
||
|
|
2. **Scalable**: Easy to determine IP from VMID
|
||
|
|
3. **Organized**: Logical grouping by VMID ranges
|
||
|
|
4. **Maintainable**: Simple rules for allocation
|
||
|
|
|
||
|
|
## Network Constraints
|
||
|
|
|
||
|
|
- **192.168.11.0/24** has 254 usable IPs (`.1` through `.254`)
|
||
|
|
- **`.255`** is the broadcast address (cannot be used)
|
||
|
|
- **`.254`** is the last usable host IP
|
||
|
|
|
||
|
|
## Future Considerations
|
||
|
|
|
||
|
|
When migrating to VLAN-based networks:
|
||
|
|
- Use separate subnets for different service types
|
||
|
|
- Apply VMID-based mapping per subnet
|
||
|
|
- Maintain clear documentation of allocations
|
||
|
|
- Reserve IP ranges for infrastructure (gateway, switches, etc.)
|