ubuntu20.04 双网卡配置


代码如下

cat /etc/netplan/00-installer-config.yaml 
# This is the network config written by 'subiquity'
network:
  ethernets:
    eth0:
      dhcp4: true
      dhcp-identifier: mac
    eth1:
      dhcp4: true
      dhcp4-overrides:
        use-routes: false
      routes:
      - to: 192.168.68.0/24
        via: 192.168.68.1
        metric: 100
  version: 2

说明

  • eth0网卡开启DHCP,并设置dhcp-identifier,防止DHCP获取的IP一直改变
  • eth1网卡开启DHCP,关闭自动路由设置
  • eth1网卡设置路由网段192.168.68.0/24 网关192.168.68.1

文章作者: Mr.Pan
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Mr.Pan !