Netplan - Définir une IP fixe
Define a fixed IP with Netplan
https://gist.github.com/jdavidzapatab/cf5db0beb6ab4d7e90ba01033aa06a1f
Find the Newtwork Interface name
Capture the network interface name. It is NOT the lo but something like eth0 or ens160.
Create or Edit a Netplan configuration file
The contents should be like this:
network:
version: 2
renderer: networkd
ethernets:
eth0:
addresses:
- 192.168.1.70/24
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
routes:
- to: default
via: 192.168.1.1
Notice here the eth0. Replace it with your network interface name. Also, set the static IPv4 address in the addresses section, with the correct submask bits size (/24 in this case). The correct IP to set depends on your network configuration so use one that works for you. Also in the routes section, in via, set the correct IPv4 for your Gateway (Router).
Apply the netplan changes
Create a bond - Agregation of two network cards
Netplan can create an agregation of 2 (or more) network cards.
Sources
- https://www.server-world.info/en/note?os=Ubuntu_22.04&p=bonding
- https://geekmungus.co.uk/?p=3981
Netplan config file
Confirm network cards names with this command : ip address show
Create or edit /etc/netplan/00-installer-config.yaml and adapt with the configuration below :
# change all like follows
# replace the interface name, IP address, DNS, Gateway to your environment value
# for [mode] section, set a mode you'd like to use
network:
ethernets:
enp1s0:
dhcp4: false
dhcp6: false
enp7s0:
dhcp4: false
dhcp6: false
bonds:
bond0:
addresses: [10.0.0.30/24]
routes:
- to: default
via: 10.0.0.1
metric: 100
nameservers:
addresses: [10.0.0.10]
search: [srv.world]
interfaces:
- enp1s0
- enp7s0
parameters:
mode: balance-rr
mii-monitor-interval: 100
version: 2
Then apply the changes with this command : netplan apply
In this example, the bond will balance the charge between the two cards because we specified mode: balance-rr. But we can also use mode: active-backup if we want to have a spare network card. If the first is down, the second one will goes up with nearly no network down.