Netplan

静态 IP

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    end0:
      dhcp4: false
      dhcp6: false
      addresses:
        - 192.168.2.x/24
      routes:
        - to: 0.0.0.0/0
          via: 192.168.2.1
      nameservers:
        addresses: [192.168.2.1]
      link-local: [] # 禁用ipv6

多网口桥接上网

任意端口插入 wan 后另外一个端口可以用来给其他设备上网,建议设备里固定 ip 自动分配可能会有问题

  • 开启 ipv4 转发

    /etc/sysctl.conf

    net/ipv4/ip_forward=1
    
  • 桥接

    network:
      version: 2
      renderer: NetworkManager
      ethernets:
        end0:
          dhcp4: false
          dhcp6: false
        end1:
          dhcp4: false
          dhcp6: false
      bridges:
        br0:
          dhcp4: false
          dhcp6: false
          interfaces:
            - end0
            - end1
          addresses:
            - 192.168.2.x/24
          routes:
            - to: 0.0.0.0/0
              via: 192.168.2.1
          nameservers:
            addresses:
              - 223.5.5.5
              - 223.6.6.6