Linux/Netzwerk/Konfiguration: Unterschied zwischen den Versionen
Zeile 17: | Zeile 17: | ||
# Systemd: [https://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_modern_network_configuration_without_gui Debian reference Doc Chapter 5] | # Systemd: [https://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_modern_network_configuration_without_gui Debian reference Doc Chapter 5] | ||
== Multiple | == Multiple addresses == | ||
; Multiple IP addresses on one Interface | ; Multiple IP addresses on one Interface | ||
Interface aliasing allows one interface to have multiple IP addresses. This is useful when more than one server is to be visible ''via'' the Internet. Note that virtual hosts can support multiple Apache servers with a single IP address. Apache responds to the domain name supplied by the client in the HTTP header. In many other situations, one external IP is needed for each server using a port. | Interface aliasing allows one interface to have multiple IP addresses. This is useful when more than one server is to be visible ''via'' the Internet. Note that virtual hosts can support multiple Apache servers with a single IP address. Apache responds to the domain name supplied by the client in the HTTP header. In many other situations, one external IP is needed for each server using a port. | ||
=== Legacy method === | === Legacy method === |
Version vom 16. Dezember 2024, 13:14 Uhr
Linux/Netzwerk/Konfiguration
Beschreibung
- Tipp
- Bezüglich einer aktuellen Anleitung für Debian zum Thema Netzwerk lesen Sie Debian Administratorhandbuch — Konfigurieren des Netzwerks
- Tipp
- Unter systemd kann networkd für die Netzwerkverwaltung genutzt werden
- siehe systemd-networkd(8)
/etc/network/interfaces
siehe /etc/network/interfaces
3 ways to configure the network
- The interfaces configuration file at /etc/network/interfaces (this page): for basic or simple configurations (e.g. workstation)
- NetworkManager: This is the default for Laptop configuration
- Systemd: Debian reference Doc Chapter 5
Multiple addresses
- Multiple IP addresses on one Interface
Interface aliasing allows one interface to have multiple IP addresses. This is useful when more than one server is to be visible via the Internet. Note that virtual hosts can support multiple Apache servers with a single IP address. Apache responds to the domain name supplied by the client in the HTTP header. In many other situations, one external IP is needed for each server using a port.
Legacy method
This /etc/network/interfaces text assigns three IP addresses to eth0.
auto eth0 allow-hotplug eth0 iface eth0 inet static address 192.168.1.42/24 gateway 192.168.1.1 auto eth0:0 allow-hotplug eth0:0 iface eth0:0 inet static address 192.168.1.43/24 auto eth0:1 allow-hotplug eth0:1 iface eth0:1 inet static address 192.168.1.44/24
An alias interface should not have "gateway" or "dns-nameservers"; dynamic IP assignment is permissible.
The above configuration is the previous traditional method that reflects the traditional use of ifconfig to configure network devices. ifconfig has introduced the concept of aliased or virtual interfaces. Those types of virtual interfaces have names of the form interface:integer and ifconfig treats them very similarly to real interfaces.
Nowadays ifupdown uses the ip utility from the iproute2 package instead of ifconfig. The newer ip utility does not use the same concept of aliases or virtual interfaces. However, it supports assigning arbitrary names to the interfaces (they're called labels). ifupdown uses this feature to support aliased interfaces while using ip.
iproute2 method
Also, ifupdown supports specifying multiple interfaces by repeating iface sections with the same interface name. The key difference from the method described above is that all such sections are treated by ifupdown as just one interface, so user can't add or remove them individually. However, up/down commands, as well as scripts, are called for every section as it used to be.
Note however that this method is dangerous! Certain driver/hardware combinations may sometimes fail to bring the link up if no labels are assigned to the alias interfaces. (Seen this on Debian Wheezy and Jessie with RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 01) auto-negotiating to 10/full. A similar warning from another person exists in the history of this page.)
This /etc/network/interfaces text assigns three IP addresses to eth0.
auto eth0 allow-hotplug eth0 iface eth0 inet static address 192.168.1.42/24 gateway 192.168.1.1
iface eth0 inet static address 192.168.1.43/24
iface eth0 inet static address 192.168.1.44/24
# adding IP addresses from different subnets is also possible iface eth0 inet static address 10.10.10.14/24
Manual approach:
auto eth0 allow-hotplug eth0 iface eth0 inet static address 192.168.1.42/24 gateway 192.168.1.1 up ip addr add 192.168.1.43/24 dev $IFACE label $IFACE:0 down ip addr del 192.168.1.43/24 dev $IFACE label $IFACE:0 up ip addr add 192.168.1.44/24 dev $IFACE label $IFACE:1 down ip addr del 192.168.1.44/24 dev $IFACE label $IFACE:1 up ip addr add 10.10.10.14/24 dev $IFACE label $IFACE:2 down ip addr del 10.10.10.14/24 dev $IFACE label $IFACE:2