debian:base-debian:networking-debian

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revision Both sides next revision
debian:base-debian:networking-debian [2019/05/03 14:10]
michael
debian:base-debian:networking-debian [2021/05/28 13:40]
michael
Line 3: Line 3:
 {{ :linux:linux_networking.png?nolink&400 |}} {{ :linux:linux_networking.png?nolink&400 |}}
  
-===== Statische IP - Beispiel Netzkonfiguration für Ubuntu =====+ 
 +===== 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 ''/etc/network/interfaces'' to configure the network. 
 +Netplan configuration files are written in YAML syntax with a ''.yaml'' file extension. To configure a network interface with Netplan, you need to create a YAML description for the interface, and Netplan will generate the required configuration files for the chosen renderer tool. 
 +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: 
 + 
 +<code> 
 +# ip link 
 +</code> 
 + 
 +The command prints a list of all the available network interfaces. In this example, the name of the interface is ''ens3'': 
 + 
 +<sxh bash; first-line: 1> 
 +1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 
 +    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 
 +2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 
 +    link/ether 08:00:27:6c:13:63 brd ff:ff:ff:ff:ff:ff 
 +</sxh> 
 + 
 +Netplan configuration files are stored in the ''/etc/netplan'' directory. You’ll probably find one or more YAML files in this directory. The name of the file may differ from setup to setup. Usually, the file is named either ''01-netcfg.yaml'', ''50-cloud-init.yaml'', or ''NN_interfaceName.yaml'', but in your system it may be different. 
 + 
 +If your Ubuntu cloud instance is provisioned with cloud-init, you’ll need to disable it. To do so create the following file: 
 + 
 +<code> 
 +# vim /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg 
 +</code> 
 + 
 +network: {config: disabled} 
 + 
 + 
 +To assign a static IP address on the network interface, open the YAML configuration file with your text editor : 
 + 
 +<code> 
 +# vim /etc/netplan/01-netcfg.yaml 
 +</code> 
 + 
 +<sxh bash; first-line: 1> 
 +network: 
 +  version: 2 
 +  renderer: networkd 
 +  ethernets: 
 +    ens3: 
 +      dhcp4: yes 
 +</sxh> 
 + 
 +Before changing the configuration, let’s explain the code in a short. 
 + 
 +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 (''ethernets''), you can specify one or more network interfaces. In this example, we have only one interface ens3 that is configured to obtain IP addressing from a DHCP server ''dhcp4: yes''
 + 
 +To assign a static IP address to ''ens3'' interface, edit the file as follows: 
 + 
 +  * Set DHCP to ''dhcp4: no''
 +  * Specify the static IP address. Under ''addresses:'' you can add one or more IPv4 or IPv6 IP addresses that will be assigned to the network interface. 
 +  * Specify the gateway. 
 +  * Under ''nameservers'', set the IP addresses of the nameservers. 
 + 
 +<sxh bash; first-line: 1> 
 +network: 
 +  version: 2 
 +  renderer: networkd 
 +  ethernets: 
 +    ens3: 
 +      dhcp4: no 
 +      addresses: 
 +        - 192.168.121.221/24 
 +      gateway4: 192.168.121.1 
 +      nameservers: 
 +          addresses: [8.8.8.8, 1.1.1.1] 
 +</sxh> 
 + 
 +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: 
 + 
 +<code> 
 +# netplan apply 
 +</code> 
 + 
 +Verify the changes by typing: 
 + 
 +<code> 
 +ip addr show dev ens3 
 +</code> 
 + 
 +<sxh bash; first-line: 1> 
 +2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 
 +    link/ether 08:00:27:6c:13:63 brd ff:ff:ff:ff:ff:ff 
 +    inet 192.168.121.221/24 brd 192.168.121.255 scope global dynamic ens3 
 +       valid_lft 3575sec preferred_lft 3575sec 
 +    inet6 fe80::5054:ff:feb0:f500/64 scope link  
 +       valid_lft forever preferred_lft forever 
 +</sxh> 
 + 
 +<wrap em>That’s it! You have assigned a static IP to your Ubuntu server.</wrap> 
 + 
 +</WRAP> 
 + 
 + 
 + 
 + 
 + 
 + 
 + 
 + 
 +===== Statische IP - Beispiel Netzkonfiguration bis Ubuntu 16.04 / Debian X =====
  
 Dies ist eine Beispielkonfiguration, in der zwei Interfaces **eth0** und **eth1** <wrap em>mit statischer IP</wrap> und Angaben definiert wurden. Man kann nach diesem Beispiel noch beliebig weitere Interfaces erstellen. Dies ist eine Beispielkonfiguration, in der zwei Interfaces **eth0** und **eth1** <wrap em>mit statischer IP</wrap> und Angaben definiert wurden. Man kann nach diesem Beispiel noch beliebig weitere Interfaces erstellen.
  • debian/base-debian/networking-debian.txt
  • Last modified: 2021/05/28 13:43
  • by michael