Ajouter une adresse ip fixe sur Ubuntu 20.04 |
Article original Publié le : 11 octobre 2020 Mise a jour le : – |
Je ne sais pas si c’est depuis la version 20.04, mais je ne connaissais pas l’attribution d’une ip via le fichier yaml d’où ce pense-bête (le temps d’ansibelisé tout ça !)
Après il y a toujours différentes façons ..
/!\ Attention a l’indentation 🙂
Éditer le ficher network-manager-all.yaml puis préfixé l’adresse ip comme ci dessous
1 |
$ sudo vim /etc/netplan/01-network-manager-all.yaml |
1 2 3 4 5 6 7 8 9 10 11 12 |
# Let NetworkManager manage all devices on this system network: version: 2 renderer: NetworkManager ethernets: enp0s3: dhcp4: no addresses: [192.168.100.1/24] gateway4: 192.168.100.100 nameservers: addresses: [1.1.1.1,1.0.0.1] dhcp6: no |
Une fois le fichier enregistré, il faut appliquer la nouvelle configuration réseau avec la commande netplan
Cela a un effet immédiat
1 |
$ sudo netplan apply |
Quelques infos sur cette commande
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ sudo netplan --help usage: /usr/sbin/netplan [-h] [--debug] ... Network configuration in YAML optional arguments: -h, --help show this help message and exit --debug Enable debug messages Available commands: help Show this help message apply Apply current netplan config to running system generate Generate backend specific configuration files from /etc/netplan/*.yaml info Show current netplan version and available features ip Retrieve IP information from the system try Try to apply a new netplan config to running system, with automatic rollback |
Enfin si on se sert pas de l’ipv6 on peut toujours le désactiver
1 |
$ echo "net.ipv6.conf.all.disable_ipv6 = 1" | sudo tee -a /etc/sysctl.conf |
1 |
$ sudo sysctl -p |