---
# System prepended metadata

title: Setting bridge network on Ubuntu 22.04 using netplan+networkd
tags: [tutorials]

---

# Setting bridge network on Ubuntu 22.04 using netplan+networkd

## Get your ethernet mac address
```bash=
ip a
```
```bash=
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master br0 state UP group default qlen 1000
    link/ether 5c:xx:xx:xx:xx:fa brd ff:ff:ff:ff:ff:ff
```

Remember the 5c:xx:xx:xx:xx:fa address

## Edit netplan

Go to the netplan folder and check
```bash=
cd /etc/netplan
ls
```

Create 01-network.yaml and keep only one .yaml file
```bash=
vim /etc/netplan/01-network.yaml
```
Write the yaml
* replace eth0 with your network interface
    * `ip a` may show
* replace 192.168.50.20 with the static ip your host should have
* you may change the nameservers
* **Change the macaddress into your ethernet interface macaddress**
```yaml=
network:
  version: 2
  renderer: networkd
  ethernets:
    eth0:
      dhcp4: false
      dhcp6: false
  bridges:
    br0:
      interfaces: [eth0]
      addresses: [192.168.50.20/24]
      macaddress: 5c:xx:xx:xx:xx:fa
      routes:
        - to: default
          via: 192.168.50.1
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8, 8.8.4.4]
      parameters:
        stp: true
        forward-delay: 4
      dhcp4: false
      dhcp6: false
```

## Apply netplan

```bash=
sudo netplan generate
sudo netplan apply
```

## Done!