====== Linux - /etc/network/interfaces ======
===== Netzwerk-Konfiguration mit ifupdown =====
Die Netzwerk-Konfiguration via **ifupdown** kommt unter **Debian** und **Ubuntu bis 16.04** zum Einsatz. Unter Ubuntu wurde diese dann durch **netplan** abgelöst.
Die Datei **/etc/network/interfaces** enthält die Netzwerk-Konfiguration.
----
===== Netzwerk-Konfiguration nach Installation =====
Nach der Installation enthält die Date **/etc/network/interfaces** folgenden Inhalt.
==== Ubuntu / Debian Desktop ====
Im Desktopbetrieb ist hier nur die **Loopback-Schnittstelle** hinterlegt. Alles andere wird vom **NetworkManager** verwaltet.
rsb@debian:# cat /etc/network/interfaces \\
# This file describes the network interfaces available on your system \\
# and how to activate them. For more information, see interfaces(5). \\
\\
source /etc/network/interfaces.d/* \\
\\
# The loopback network interface \\
auto lo \\
iface lo inet loopback \\
==== Ubuntu / Debian Server ====
rsb@debian:# cat /etc/network/interfaces \\
# This file describes the network interfaces available on your system \\
# and how to activate them. For more information, see interfaces(5). \\
\\
source /etc/network/interfaces.d/* \\
\\
# The loopback network interface \\
auto lo \\
iface lo inet loopback \\
\\
# The primary network interface \\
allow-hotplug ens192 \\
iface ens192 inet static \\
address 10.10.10.10/24 \\
gateway 10.10.10.1 \\
# dns-* options are implemented by the resolvconf package, if installed \\
dns-nameservers 10.10.10.100 \\
dns-search linux42.de \\
===== Vorlagen mit Erläuterung =====
Es folgen zwei Standard-Konfiguration mit Erklärung der einzelnen Möglichkeiten
==== Vorlage DHCP ====
Eine **DHCP-Konfiguration** auf Basis von **IPv4/IPv6** sieht wie folgt aus:
auto lo ens192 \\
\\
# Loopback-Interface \\
iface lo inet loopback \\
\\
# DHCP IPv4 / IPv6 \\
iface ens192 inet dhcp \\
iface ens192 inet6 dhcp \\
==== Vorlage statische IP ====
Eine **statische Konfiguration** auf Basis von **IPv4 und IPv6** sieht wie folgt aus:
auto lo ens192 \\
\\
# Loopback-Interface \\
iface lo inet loopback \\
\\
# Statis IPv4/IPv6 \\
allow-hotplug ens192 \\
iface ens192 inet static \\
address 10.10.10.10/24 \\
#address 10.10.10.10 \\
#netmask 255.255.255.0 \\
gateway 10.10.10.1 \\
dns-nameservers 10.10.10.100 \\
dns-search linux42.de \\
\\
iface ens192 inet6 static \\
address fe80:0000:0001:0011:0111:1111:0000:0001 \\
netmask 64 \\
gateway fe80:db7::1 \\
==== Erläuterungen ====
| ** Konfiguration ** | ** Erläuterung ** |
| auto lo ens192 | Automatisches aktivieren beim Systemstart der Inteface lo und ens192 |
| iface lo inet loopback | Definition des Loopback-Interfaces |
| iface ens192 inet dhcp | Interface ens192 soll seine IPv4-Adresse via DHCP beziehen |
| allow-hotplug ens192 | Erlaubt das aktivieren des Interfaces ens192 durch ein Kernel-Ereignis |
| iface ens192 inet static | Interface ens192 soll eine statische IP-Adresse erhalten |
| address 10.10.10.10/24 | Statische IP-Adresse gefolgt vom Subnetz in CIDR-Präfix Schreibweise (z.B. /24) |
| address 10.10.10.10 | Alternative Schreibweise IP-Adresse ohne Subnetz |
| netmask 255.255.255.0 | Wird die Adresse ohne Subnetz angegeben wird diese getrennt über netmask angegeben |
| gateway 10.0.0.1 | Das Standard-Gateway für die IPv4 Adresse |
| dns-nameservers 10.10.10.100 | IP-Adressen der Nameserver durch Leerzeichen getrennt |
| dns-search linux42.de | Such-Domains (Search-Domains) |
| iface ens192 inet6 dhcp | Interface ens192 soll seine IPv6-Adresse via DHCP beziehen |
| address fe80:0000:0001:0011:0111:1111:0000:0001 | IPv6 Adresse |
| netmask 64 | IPv6 Netzmaske |
| gateway fe80:db7::1 | IPv6 Gateway |
==== Tabelle CIDR ====
Zur Hilfestellung hier noch eine Präfix-Tabelle für die Netze ab /24
| ** CIDR-Präfix ** | ** IPv4 Subnetzmaske ** |
| /24 | 255.255.255.0 |
| /25 | 255.255.255.128 |
| /26 | 255.255.255.192 |
| /27 | 255.255.255.224 |
| /28 | 255.255.255.240 |
| /29 | 255.255.255.248 |
| /30 | 255.255.255.252 |
| /31 | 255.255.255.254 |
| /32 | 255.255.255.255 |
----
===== Abschluss der Konfiguration =====
Um die Änderung an einem Interface zu aktivieren wird dieses herunter- und wieder hochgefahren
sudo ifdown ens192 \\
sudo ifup ens192 \\
Weitere Informationen zu **ifupdown** unter [[wiki:linux:konfiguration:linux-ifupdown|]]
Soll die komplette Konfiguration neu eingelesen und aktiviert werden geschieht dies mit
sudo service networking restart
----
====== Zusammenhängende Beiträge ======
[[wiki:linux:konfiguration:linux-ifupdown|]] \\
[[wiki:linux:konfiguration:linux-etc-network-interfaces|]] \\
----
{{page>impressum:ausschluss#Haftungsausschluss}}
----
~~DISCUSSION~~