建立HOST主機橋接網路

brctl addbr br0 brctl addif br0 enp0s3 ifconfig enp0s3 0.0.0.0 dhclient br0

設定固定IP的 Bridge 網路

sudo cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yamlbak

sudo vi /etc/netplan/50-cloud-init.yaml

network:
  version: 2
  renderer: networkd

  ethernets:
    enp0s3:
      dhcp4: false 
      dhcp6: false 
      #addresses: [192.168.1.239/24]
      #gateway4: 192.168.1.1
      #mtu: 1500
      #nameservers:
      #  addresses: [8.8.8.8]

  bridges:
    br0:
      interfaces: [enp0s3]
      addresses: [192.168.43.65/24]
      gateway4: 192.168.43.1
      mtu: 1500
      nameservers:
        addresses: [8.8.8.8]
      parameters:
        stp: true
        forward-delay: 4
      dhcp4: no
      dhcp6: no

接著我們可以把HOST機同往段的網路設定,使用pipework 加入 container

Last updated