Files
Statische-IP-mit-Netplan-ko…/README.md
2026-06-04 05:27:07 +00:00

103 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Home Server IP ändert sich nach Neustart
## Was war das Problem?
Ubuntu 24.04 nutzt **Netplan** zur Netzwerkkonfiguration.
Es gab zwei widersprüchliche Netplan-Dateien:
| Datei | Inhalt | Problem |
|---|---|---|
| `01-static.yaml` | Feste IP für `ens18` | Falsches Interface (Interface heißt `eno1`) |
| `50-cloud-init.yaml` | DHCP für `eno1` | Überschrieb die statische Konfig |
`cloud-init` hat die DHCP-Datei bei jedem Boot neu erstellt → der Server bekam jedes Mal eine zufällige IP vom Router.
---
## Angewandte Lösung
### 1. cloud-init für Netzwerk deaktiviert
```bash
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network.cfg
```
### 2. DHCP-Datei gelöscht
```bash
rm /etc/netplan/50-cloud-init.yaml
```
### 3. Statische Konfig korrigiert (`/etc/netplan/01-static.yaml`)
```yaml
network:
version: 2
ethernets:
eno1:
dhcp4: no
addresses:
- 192.168.178.57/24
routes:
- to: default
via: 192.168.178.1
nameservers:
addresses: [192.168.178.1, 8.8.8.8]
```
### 4. Berechtigungen gesetzt und angewendet
```bash
chmod 600 /etc/netplan/01-static.yaml
netplan apply
```
---
## Wenn das Problem wieder auftritt
### Schritt 1 Aktuelle IP und Interface prüfen
```bash
ip addr show eno1
```
Richtige IP: `192.168.178.57`
Wenn `dynamic` in der Ausgabe steht → DHCP ist wieder aktiv.
### Schritt 2 Netplan-Dateien prüfen
```bash
cat /etc/netplan/*.yaml
```
Es darf **nur eine Datei** existieren (`01-static.yaml`) mit `dhcp4: no`.
Wenn `50-cloud-init.yaml` wieder da ist → cloud-init hat sie neu erstellt.
### Schritt 3 cloud-init-Sperre prüfen
```bash
cat /etc/cloud/cloud.cfg.d/99-disable-network.cfg
```
Ausgabe muss sein: `network: {config: disabled}`
Wenn die Datei fehlt → neu anlegen:
```bash
echo "network: {config: disabled}" > /etc/cloud/cloud.cfg.d/99-disable-network.cfg
```
### Schritt 4 DHCP-Datei wieder löschen
```bash
rm -f /etc/netplan/50-cloud-init.yaml
```
### Schritt 5 Statische Konfig prüfen und anwenden
```bash
cat /etc/netplan/01-static.yaml # Inhalt kontrollieren
chmod 600 /etc/netplan/01-static.yaml
netplan apply
ip addr show eno1 # Prüfen: kein "dynamic", valid_lft forever
```
---
## Server-Infos
| Eigenschaft | Wert |
|---|---|
| Betriebssystem | Ubuntu 24.04.4 LTS |
| Hostname | minecraft |
| Netzwerkkarte | `eno1` (MAC: `ac:e2:d3:05:b8:46`) |
| Feste IP | `192.168.178.57` |
| Gateway / DNS | `192.168.178.1` (Fritzbox) |
| Netplan-Konfig | `/etc/netplan/01-static.yaml` |