关于ubtun20.04的网卡设置(多网卡 多IP 单网卡 多IP(子ip) bond)

目录:/etc/netplan

目录: /proc/sys/net/ipv4/conf

验证bond命令:watch -n 1 cat /proc/net/bonding/bond0

一. 单网卡+静态IP

1. vim 00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: no
      dhcp6: no   #关闭dhcp
      addresses:
      - 10.0.0.134/24 
      optional: true
      gateway4: 10.0.0.220
      nameservers:  #dns
          addresses: [114.114.114.114,8.8.8.8]
  version: 2

2. 重启 sudo netplan apply  

成功!

二 .单网卡多IP(子IP)

1.  vim 00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
  ethernets:
    ens33:
      dhcp4: no
      dhcp6: no
      addresses:
      - 10.0.0.134/24
      - 10.0.0.16/24
      optional: true
      gateway4: 10.0.0.220
      nameservers:
          addresses: [114.114.114.114,8.8.8.8]
  version: 2

 2. netplan apply 成功!

三. 多网卡多IP并且绑定bond

1. 适配器添加一块网卡

2. 查看新添加网卡名称

cd  /proc/sys/net/ipv4/conf

  vim 00-installer-config.yaml

network:
  ethernets:
    ens33:
      addresses: []         #绑定单网卡不需要写IP地址
      dhcp4: no
    ens38:
      addresses: []
      dhcp4: no

  bonds:
    bond0:
      addresses:
        - 10.0.0.134/24
      gateway4: 10.0.0.220
      #nameservers: 根据需求可以不要
        #addresses:
          #- 114.114.114.114
      interfaces:
        - ens33
        - ens38
      parameters:           #参数
        mode: active-backup #bond模式
        primary: ens33
        

    ens39: 
      dhcp4: no
      dhcp6: no
      addresses: 
        - 10.0.0.35/24
      gateway4: 10.0.0.220
      optional: true
      nameservers:
          addresses: [114.114.114.114,8.8.8.8]
  version: 2

此为bond6的配置 如果要配置其他自行更改:

如8023ad

network:
    version: 2
    renderer: networkd
    ethernets:
        enp2s0:
            dhcp4: no
        enp3s0:
            dhcp4: no
            optional: true
   bonds:
       #bond-lan:
        bond0:
            interfaces: [enp2s0, enp3s0]
            addresses: [192.168.93.2/24]
            parameters:
                mode: 802.3ad
                mii-monitor-interval:
                lacp-rate: fast
                transmit-hash-policy: layer2

验证bond: watch -n 1 cat /proc/net/bonding/bond0

 mac 与bond0相同

  • 3
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值