Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
debian:base-debian:networking-debian [2017/08/22 13:37] – michael | debian:base-debian:networking-debian [2021/05/28 15:43] (current) – [Netzkonfiguration ab Ubuntu 18.04 / Debian X] michael | ||
---|---|---|---|
Line 2: | Line 2: | ||
{{ : | {{ : | ||
+ | |||
+ | |||
+ | ===== Netzkonfiguration ab Ubuntu 18.04 / Debian X ===== | ||
+ | |||
+ | **Ubuntu 17.10 and later** uses **Netplan** as the default network management tool. The previous Ubuntu versions were using ifconfig and its configuration file ''/ | ||
+ | Netplan configuration files are written in YAML syntax with a '' | ||
+ | Netplan supports two renderers, NetworkManager and Systemd-networkd. NetworkManager is mostly used on Desktop machines, while the Systemd-networkd is used on servers without a GUI. | ||
+ | |||
+ | <WRAP center box 100%> | ||
+ | ==== Configuring Static IP address | ||
+ | |||
+ | On Ubuntu 20.04, the system identifies network interfaces using ‘predictable network interface names’. | ||
+ | |||
+ | The first step toward setting up a static IP address is identifying the name of the ethernet interface you want to configure. To do so, use the ip link command, as shown below: | ||
+ | |||
+ | < | ||
+ | # ip link | ||
+ | </ | ||
+ | |||
+ | The command prints a list of all the available network interfaces. In this example, the name of the interface is '' | ||
+ | |||
+ | <sxh plain; gutter: false;> | ||
+ | 1: lo: < | ||
+ | link/ | ||
+ | 2: ens3: < | ||
+ | link/ether 08: | ||
+ | </ | ||
+ | |||
+ | Netplan configuration files are stored in the ''/ | ||
---- | ---- | ||
- | ===== Statische IP - Beispiel Netzkonfiguration | + | If your Ubuntu cloud instance is provisioned with cloud-init, you’ll need to disable it. To do so create the following file: |
+ | |||
+ | < | ||
+ | # vim / | ||
+ | </ | ||
+ | |||
+ | <sxh bash; first-line: 1> | ||
+ | network: {config: disabled} | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | To assign a static IP address on the network interface, open the YAML configuration file with your text editor : | ||
+ | |||
+ | < | ||
+ | # vim / | ||
+ | </ | ||
+ | |||
+ | <sxh bash; first-line: 1> | ||
+ | network: | ||
+ | version: 2 | ||
+ | renderer: networkd | ||
+ | ethernets: | ||
+ | ens3: | ||
+ | dhcp4: yes | ||
+ | </ | ||
+ | |||
+ | Before changing the configuration, | ||
+ | |||
+ | Each Netplan Yaml file starts with the network key that has at least two required elements. The first required element is the version of the network configuration format, and the second one is the device type. The device type can be ethernets, bonds, bridges, or vlans. | ||
+ | |||
+ | The configuration above also has a line that shows the renderer type. Out of the box, if you installed Ubuntu in server mode, the renderer is configured to use networkd as the back end. | ||
+ | Under the device’s type ('' | ||
+ | |||
+ | To assign a static IP address to '' | ||
+ | |||
+ | * Set DHCP to '' | ||
+ | * Specify the static IP address. Under '' | ||
+ | * Specify the gateway. | ||
+ | * Under '' | ||
+ | |||
+ | <sxh bash; first-line: 1> | ||
+ | network: | ||
+ | version: 2 | ||
+ | renderer: networkd | ||
+ | ethernets: | ||
+ | ens3: | ||
+ | dhcp4: no | ||
+ | addresses: | ||
+ | - 192.168.121.221/ | ||
+ | gateway4: 192.168.121.1 | ||
+ | nameservers: | ||
+ | addresses: [8.8.8.8, 1.1.1.1] | ||
+ | </ | ||
+ | |||
+ | When editing Yaml files, make sure you follow the YAML code indent standards. If the syntax is not correct, the changes will not be applied. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Once done, save the file and apply the changes by running the following command: | ||
+ | |||
+ | < | ||
+ | # netplan apply | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | Verify the changes by typing: | ||
+ | |||
+ | < | ||
+ | # ip addr show dev ens3 | ||
+ | </ | ||
+ | |||
+ | <sxh plain; gutter: false;> | ||
+ | 2: ens3: < | ||
+ | link/ether 08: | ||
+ | inet 192.168.121.221/ | ||
+ | | ||
+ | inet6 fe80:: | ||
+ | | ||
+ | </ | ||
+ | |||
+ | <wrap em> | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===== Statische IP - Beispiel Netzkonfiguration | ||
Dies ist eine Beispielkonfiguration, | Dies ist eine Beispielkonfiguration, | ||
Line 39: | Line 161: | ||
broadcast 10.0.0.255 | broadcast 10.0.0.255 | ||
</ | </ | ||
+ | |||
+ | * **auto ethX** sorgt dafür, dass das NIC bei jedem Neustart mit gestartet wird | ||
+ | * **iface ethX inet static** definiert für das NIC eine statische IP | ||
+ | * **address abc.def.ghi.jkl** spezifiziert die IP | ||
+ | * **netmask** die Netzmaske | ||
+ | * **gateway** das Standardgateway | ||
+ | * **dns-nameservers** spezifiziert die DNS-Server. Es können beliebig viele eingetragen werden, diese werden dann der Reihe nach angefragt | ||
</ | </ | ||
Line 46: | Line 175: | ||
<wrap em>Zum übernehmen der Interface Änderungen unten schauen!</ | <wrap em>Zum übernehmen der Interface Änderungen unten schauen!</ | ||
- | ---- | ||
===== Dynamische IP - Beispiel Netzkonfiguration für Ubuntu ===== | ===== Dynamische IP - Beispiel Netzkonfiguration für Ubuntu ===== | ||
Line 76: | Line 204: | ||
</ | </ | ||
+ | |||
+ | * Nutzt man **iface ethX inet dhcp** versucht sich das NIC die Konfiguration über DHCP zu holen, dann darf aber nach dieser Zeile keine weiter Konfiguration für dieses NIC vorgenommen werden. | ||
</ | </ | ||
<wrap em>Zum übernehmen der Interface Änderungen unten schauen!</ | <wrap em>Zum übernehmen der Interface Änderungen unten schauen!</ | ||
- | ---- | ||
- | ===== Übernehmen der neuen Netzwerk | + | ===== Übernehmen der neuen Netzwerk |
Zum übernehmen / aktivieren der neuen Netzwerkkonfiguration, | Zum übernehmen / aktivieren der neuen Netzwerkkonfiguration, | ||
Line 88: | Line 217: | ||
# ifup eth0</ | # ifup eth0</ | ||
* '' | * '' | ||
+ | |||
+ | |||
+ | ===== Weiteres bezüglich Netzwerk Konfiguration ===== | ||
+ | |||
+ | <WRAP center box 100%> | ||
+ | ==== DNS-Config ==== | ||
+ | Neben der Konfiguration der DNS-Server in der Datei **/ | ||
+ | Hier trägt man einen DNS-Server mit | ||
+ | nameserver ip.adresse.des.servers | ||
+ | ein. | ||
+ | Hier ist Linux leider etwas inkonsequent! Gibt man DNS-Server in der **/ | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <WRAP center box 100%> | ||
+ | ==== IP Forwarding ==== | ||
+ | IP-Forwarding ist zuständig, dass IP-Pakete auf allen Netzwerkkarten weitergeleitet werden. | ||
+ | Das benötigt man zum Beispiel bei einem gehosteten Subnetz bei einem ISP. Da dies ein Kernelmodul ist, muss es in ''/ | ||
+ | net.ipv4.ip_forward=1 | ||
+ | |||
+ | Möchte man dieses Modul nur temporär aktivieren macht man dies über das Terminal: | ||
+ | # sysctl net.ipv4.ip_forward=1 | ||
+ | </ | ||
+ | |||
+ | ---- | ||
+ | |||
+ | <WRAP center box 100%> | ||
+ | ==== Statische Routen ==== | ||
+ | Nutzt man mehrere Netzwerke ergibt sich manchmal das Problem, dass der Server die Route in ein bestimmten Netz nicht findet, da zum Beispiel der " | ||
+ | Um trotzdem auf diese Netze zu kommen kann man statische Routen festlegen: | ||
+ | Dies geht temporär mit | ||
+ | sudo route add -net 10.8.0.0 netmask 255.255.255.0 gw vpn.server.i.p | ||
+ | Hierbei ist das LAN **10.8.0.0/ | ||
+ | Damit diese Routen persistent bleiben müssen sie in ohne '' | ||
+ | route add -net 10.8.0.0 netmask 255.255.255.0 gw vpn.server.i.p | ||
+ | </ | ||
+ | |||
+ | | ||
+ | |||