linux_netzwerkkonfiguration
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
| linux_netzwerkkonfiguration [2023-04-22 21:40:58] – [Netplan (ab Ubuntu 18.04)] sysop | linux_netzwerkkonfiguration [2024-07-07 02:32:03] (aktuell) – [Wechseln von dhcpcd/networking zu networkd] manfred | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== Linux Netzwerkkonfiguration ====== | ||
| + | |||
| + | > ip link set dev enp6s0 down | ||
| + | > ip link set dev enp6s0 up | ||
| + | > ip a | ||
| + | |||
| + | * [[Netzwerkkarten bündeln - Bonding]] | ||
| + | |||
| + | > ls -l / | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 em1 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 em2 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 em3 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 em4 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 lo -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 p1p1 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 p1p2 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 p2p1 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 p2p2 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 p3p1 -> ../ | ||
| + | lrwxrwxrwx 1 root root 0 Oct 17 13:00 p3p2 -> ../ | ||
| + | |||
| + | |||
| + | ===== zusätzliche IP's auf eine Netzwerkkarte konfigurieren (Alias-IP) ===== | ||
| + | |||
| + | |||
| + | ==== mit ifconfig ==== | ||
| + | |||
| + | setzen: | ||
| + | > ifconfig eth0:0 192.168.1.40/ | ||
| + | |||
| + | entfernen: | ||
| + | > ifconfig eth0:0 down | ||
| + | |||
| + | |||
| + | ==== mit ip ==== | ||
| + | |||
| + | setzen: | ||
| + | > ip addr add 192.168.1.40/ | ||
| + | |||
| + | oder Linux-2.0-kompatibel (mit Label): | ||
| + | > ip addr add 192.168.1.40/ | ||
| + | |||
| + | entfernen: | ||
| + | > ip addr add 192.168.1.40/ | ||
| + | oder | ||
| + | > ip addr add 192.168.1.40/ | ||
| + | |||
| + | |||
| + | ===== Wechsel zu systemd-networkd und systemd-resolved oder unbound ===== | ||
| + | |||
| + | |||
| + | ==== mit unbound ==== | ||
| + | |||
| + | * unbound config: ''/ | ||
| + | * resolv.conf config: ''/ | ||
| + | |||
| + | apt install unbound | ||
| + | systemctl disable systemd-resolved | ||
| + | systemctl enable unbound | ||
| + | |||
| + | unlink / | ||
| + | <code ini / | ||
| + | nameserver ::1 | ||
| + | nameserver 127.0.0.1 | ||
| + | options edns0 trust-ad | ||
| + | search fritz.box | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== mit systemd-resolved ==== | ||
| + | |||
| + | * systemd-resolved config: ''/ | ||
| + | * resolv.conf config: ''/ | ||
| + | |||
| + | apt install systemd-resolved | ||
| + | systemctl disable unbound | ||
| + | systemctl enable systemd-resolved | ||
| + | |||
| + | ln -fs / | ||
| + | |||
| + | ==== networkd config ==== | ||
| + | |||
| + | //anpassen je nachdem, welcher dns, siehe oben// | ||
| + | |||
| + | * systemd-networkd config: ''/ | ||
| + | |||
| + | systemctl disable network-manager | ||
| + | systemctl disable networking | ||
| + | systemctl enable systemd-networkd | ||
| + | apt purge dhcpcd5 openresolv isc-dhcp-client isc-dhcp-common ifupdown | ||
| + | reboot now && exit | ||
| + | |||
| + | |||
| + | ===== Netplan (ab Ubuntu 18.04) ===== | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | * **[[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | alle Netplan-Konfigurationen aufrufen: | ||
| + | > vi / | ||
| + | > vi / | ||
| + | > vi / | ||
| + | |||
| + | die Netplan-Konfigurationen starten/ | ||
| + | > netplan generate | ||
| + | > netplan apply | ||
| + | |||
| + | > netplan try | ||
| + | |||
| + | ein NIC hoch- bzw. runterfahren: | ||
| + | > ip link set enp0s3 up | ||
| + | > ip link set enp0s3 down | ||
| + | |||
| + | NameServer anzeigen: | ||
| + | > systemd-resolve --status | ||
| + | |||
| + | eine IP von einem NIC entfernen: | ||
| + | > ip address del 123.123.123.123/ | ||
| + | |||
| + | Die IP wird zwar beim Bootvorgang nicht mehr geladen, wenn die Konfiguration fehlt aber will man eine IP von einem laufenden System entfernen, dann geht das nicht, wenn man einfach nur die Konfigurationsdatei entfernt und '' | ||
| + | |||
| + | |||
| + | ==== statische Netzwerkkonfiguration ==== | ||
| + | |||
| + | <file yaml / | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | enp59s0f0: | ||
| + | addresses: [192.168.24.21/ | ||
| + | #gateway4: 192.168.24.1 | ||
| + | routes: | ||
| + | - to: default | ||
| + | via: 192.168.24.1 | ||
| + | nameservers: | ||
| + | search: [domain.net] | ||
| + | addresses: [192.168.110.170, | ||
| + | </ | ||
| + | |||
| + | > mv / | ||
| + | > vi / | ||
| + | <file yaml / | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | eth0: | ||
| + | dhcp4: no | ||
| + | dhcp-identifier: | ||
| + | addresses: | ||
| + | - 10.10.10.2/ | ||
| + | gateway4: 10.10.10.1 | ||
| + | nameservers: | ||
| + | addresses: | ||
| + | - 10.10.10.1 | ||
| + | - 1.1.1.1 | ||
| + | </ | ||
| + | |||
| + | > netplan generate | ||
| + | > netplan apply | ||
| + | |||
| + | Hier wird der Ethernetschnittstelle '' | ||
| + | |||
| + | |||
| + | ==== DHCP Netzwerkkonfiguration ==== | ||
| + | |||
| + | > mv / | ||
| + | > vi / | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | eth0: | ||
| + | addresses: [] | ||
| + | dhcp4: true | ||
| + | optional: true | ||
| + | |||
| + | > netplan generate | ||
| + | > netplan apply | ||
| + | | ||
| + | > netplan ip leases eth0 | ||
| + | # This is private data. Do not parse. | ||
| + | ADDRESS=192.168.1.90 | ||
| + | NETMASK=255.255.255.0 | ||
| + | ROUTER=192.168.1.254 | ||
| + | SERVER_ADDRESS=192.168.1.4 | ||
| + | NEXT_SERVER=192.168.1.4 | ||
| + | BROADCAST=192.168.1.255 | ||
| + | T1=43200 | ||
| + | T2=75600 | ||
| + | LIFETIME=86400 | ||
| + | DNS=192.168.1.4 | ||
| + | DOMAINNAME=lan | ||
| + | HOSTNAME=rechnervonfritz | ||
| + | CLIENTID=ffb6820feb00020000ab1263b9c5e8a84783fe | ||
| + | |||
| + | |||
| + | ==== Netzwerkkonfiguration mit DHCP (IPv4) und SLAAC (IPv6) ==== | ||
| + | |||
| + | <file yaml / | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | eth0: | ||
| + | optional: true | ||
| + | dhcp-identifier: | ||
| + | dhcp4: true | ||
| + | dhcp6: true | ||
| + | ipv6-privacy: | ||
| + | accept-ra: true | ||
| + | nameservers: | ||
| + | addresses: | ||
| + | - 2606: | ||
| + | - 1.1.1.1 | ||
| + | - 2606: | ||
| + | - 1.0.0.1 | ||
| + | |||
| + | </ | ||
| + | |||
| + | > netplan generate | ||
| + | > netplan apply | ||
| + | |||
| + | |||
| + | ==== Netzwerkkonfiguration mit statischer IPv4 und SLAAC (IPv6) ==== | ||
| + | |||
| + | <file yaml / | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | eth0: | ||
| + | optional: true | ||
| + | dhcp-identifier: | ||
| + | dhcp4: false | ||
| + | dhcp6: true | ||
| + | ipv6-privacy: | ||
| + | accept-ra: true | ||
| + | addresses: | ||
| + | - 10.0.0.64/ | ||
| + | gateway4: 10.0.0.1 | ||
| + | nameservers: | ||
| + | addresses: | ||
| + | - 2606: | ||
| + | - 1.1.1.1 | ||
| + | - 2606: | ||
| + | - 1.0.0.1 | ||
| + | |||
| + | </ | ||
| + | |||
| + | > netplan generate | ||
| + | > netplan apply | ||
| + | |||
| + | |||
| + | ==== Bond ==== | ||
| + | |||
| + | <file yaml / | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | enp59s0f0: | ||
| + | dhcp4: no | ||
| + | dhcp6: no | ||
| + | enp59s0f1: | ||
| + | dhcp4: no | ||
| + | dhcp6: no | ||
| + | bonds: | ||
| + | bond0: | ||
| + | interfaces: | ||
| + | - enp59s0f0 | ||
| + | - enp59s0f1 | ||
| + | addresses: [192.168.24.21/ | ||
| + | gateway4: 192.168.24.1 | ||
| + | nameservers: | ||
| + | search: [domain.net] | ||
| + | addresses: | ||
| + | - 192.168.110.170 | ||
| + | - 192.168.110.171 | ||
| + | </ | ||
| + | |||
| + | > netplan generate | ||
| + | > netplan apply | ||
| + | |||
| + | |||
| + | ==== Bond + LACP ==== | ||
| + | |||
| + | LACP wird mit der Option '' | ||
| + | |||
| + | <file yaml / | ||
| + | network: | ||
| + | version: 2 | ||
| + | renderer: networkd | ||
| + | ethernets: | ||
| + | enp59s0f0: | ||
| + | dhcp4: no | ||
| + | dhcp6: no | ||
| + | enp59s0f1: | ||
| + | dhcp4: no | ||
| + | dhcp6: no | ||
| + | bonds: | ||
| + | bond0: | ||
| + | interfaces: | ||
| + | - enp59s0f0 | ||
| + | - enp59s0f1 | ||
| + | parameters: | ||
| + | mode: 802.3ad | ||
| + | lacp-rate: fast | ||
| + | mii-monitor-interval: | ||
| + | addresses: [192.168.24.21/ | ||
| + | gateway4: 192.168.24.1 | ||
| + | nameservers: | ||
| + | search: [domain.net] | ||
| + | addresses: | ||
| + | - 192.168.110.170 | ||
| + | - 192.168.110.171 | ||
| + | </ | ||
| + | |||
| + | > netplan generate | ||
| + | > netplan apply | ||
| + | > cat / | ||
| + | 802.3ad 4 | ||
| + | |||
| + | |||
| + | ===== Performance der Netzverbindung Testen ===== | ||
| + | |||
| + | |||
| + | ==== Allgemeines ==== | ||
| + | |||
| + | Zum Test des physikalischen Durchsatzes der Netzwerkleitung kann das Tool iperf genutzt werden. Dieses beinhaltet eine Server und eine Client Komponente und kann den Durchsatz des Netzwerkes unabhängig von der Leistungsfähigkeit des lokalen Dateisystems testen. | ||
| + | |||
| + | > aptitude update && aptitude install iperf | ||
| + | |||
| + | |||
| + | ==== Verwendung von iperf ==== | ||
| + | |||
| + | |||
| + | === Auf dem Server auszuführen === | ||
| + | |||
| + | > iperf -s -w 65536 -p 12345 | ||
| + | |||
| + | * -s als Server starten | ||
| + | * -w < | ||
| + | * -p < | ||
| + | |||
| + | |||
| + | === Auf dem Client auszuführen === | ||
| + | |||
| + | > iperf -c 10.10.5.100 -w 65536 -p 12345 -t 60 | ||
| + | |||
| + | oder | ||
| + | > iperf -c 10.10.5.100 -w 65536 -p 12345 -t 60 -P 4 | ||
| + | |||
| + | * -c < | ||
| + | * -w < | ||
| + | * -p < | ||
| + | * -t < | ||
| + | * [-P < | ||
| + | |||
| + | |||
| + | ===== Predictable Network Interface Naming - Consistent Network Device Naming ===== | ||
| + | |||
| + | * [[http:// | ||
| + | * [[https:// | ||
| + | |||
| + | // | ||
| + | // | ||
| + | |||
| + | Standard bis Ubuntu 12.04 (// | ||
| + | > lshw -businfo -C network | ||
| + | Bus info Device | ||
| + | ======================================================= | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | |||
| + | Standard ab Ubuntu 14.04 (// | ||
| + | > lshw -businfo -C network | ||
| + | Bus info Device | ||
| + | ======================================================= | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | pci@0000: | ||
| + | |||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | |||
| + | ==== Alte Netzwerkinterface Namen wiederherstellen (Predictable Network Interface Naming) ==== | ||
| + | |||
| + | Quelle: [[https:// | ||
| + | |||
| + | <file bash / | ||
| + | ... | ||
| + | GRUB_CMDLINE_LINUX=" | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | > apt-get purge biosdevname | ||
| + | > update-initramfs -u | ||
| + | > update-grub | ||
| + | > reboot | ||
| + | |||
| + | |||
| + | ==== Kernel/ | ||
| + | |||
| + | |||
| + | === ab Ubuntu 14.04 === | ||
| + | |||
| + | das Paket '' | ||
| + | > apt purge biosdevname | ||
| + | > update-initramfs -u | ||
| + | update-initramfs: | ||
| + | |||
| + | im Bootloader deaktivieren: | ||
| + | <file bash / | ||
| + | ... | ||
| + | GRUB_CMDLINE_LINUX=" | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | > mv / | ||
| + | > update-grub2 | ||
| + | |||
| + | **Netzwerkkonfiguration anpassen:** | ||
| + | Vor dem Neustart sollte noch in der Konfigurationsdatei ''/ | ||
| + | |||
| + | ...zum Beispiel so: | ||
| + | <file bash / | ||
| + | ... | ||
| + | auto eth0 | ||
| + | iface eth0 inet dhcp | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | > reboot | ||
| + | |||
| + | |||
| + | ==== BIOS/ | ||
| + | |||
| + | [[https:// | ||
| + | - __Onboard-NIC__: | ||
| + | - __PCI-NIC__: | ||
| + | |||
| + | |||
| + | === ab Ubuntu 14.04 === | ||
| + | |||
| + | das Paket '' | ||
| + | > apt update | ||
| + | > apt upgrade | ||
| + | > apt install biosdevname | ||
| + | > update-initramfs -u | ||
| + | update-initramfs: | ||
| + | |||
| + | im Bootloader deaktivieren: | ||
| + | <file bash / | ||
| + | ... | ||
| + | GRUB_CMDLINE_LINUX=" | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | > mv / | ||
| + | > update-grub2 | ||
| + | |||
| + | **Netzwerkkonfiguration anpassen:** | ||
| + | Vor dem Neustart sollte noch in der Konfigurationsdatei ''/ | ||
| + | |||
| + | ...zum Beispiel so: | ||
| + | <file bash / | ||
| + | ... | ||
| + | auto em1 | ||
| + | iface em1 inet dhcp | ||
| + | |||
| + | auto p1p1 | ||
| + | iface p1p1 inet dhcp | ||
| + | ... | ||
| + | </ | ||
| + | |||
| + | > reboot | ||
| + | |||
| + | |||
| + | ===== virtuelles NIC mit eigener MAC-Adresse ===== | ||
| + | |||
| + | das virtuelle NIC hat hier den Namen '' | ||
| + | > ip link add link eth0 address 00: | ||
| + | > ifconfig mac0 up | ||
| + | |||
| + | > vi / | ||
| + | ... | ||
| + | | ||
| + | auto mac0 | ||
| + | iface mac0 inet manual | ||
| + | pre-up ip link add mac0 link eth0 type macvlan mode bridge | ||
| + | post-down ip link del mac0 link eth0 type macvlan mode bridge | ||
| + | |||
| + | > ip a | ||
| + | ... | ||
| + | | ||
| + | 31: mac0@eth0: < | ||
| + | link/ether 32: | ||
| + | inet 192.168.1.185/ | ||
| + | | ||
| + | |||
| + | |||
| + | ===== Bridge ===== | ||
| + | |||
| + | '' | ||
| + | > brctl addbr br0 | ||
| + | > ifconfig eth0 0.0.0.0 promisc | ||
| + | > brctl addif br0 eth0 | ||
| + | > ip a add 192.168.1.1/ | ||
| + | > ifconfig br0 up | ||
| + | |||
| + | siehe: [[http:// | ||
| + | |||
| + | Nur TAP (OSI/ | ||
| + | |||
| + | |||
| + | ==== Linux Ubuntu 16.04.6 LTS ==== | ||
| + | |||
| + | Eine Bridge ohne IP-Adresse konfigurieren | ||
| + | |||
| + | > brctl addbr br0 | ||
| + | > brctl addif br0 tap0 | ||
| + | > ifup br0 | ||
| + | > ifconfig br0 up | ||
| + | > brctl show | ||
| + | |||
| + | > vi / | ||
| + | ... | ||
| + | | ||
| + | auto tap0 | ||
| + | iface tap0 inet static | ||
| + | pre-up ip tuntap add mode tap name tap0 | ||
| + | address 10.10.1.201 | ||
| + | netmask 255.255.255.0 | ||
| + | # | ||
| + | auto br0 | ||
| + | iface br0 inet manual | ||
| + | bridge_ports tap0 | ||
| + | bridge_stp on | ||
| + | |||
| + | > ip link show | ||
| + | |||
