ubuntu centos 网卡配置模版

静态

network:
  version: 2
  renderer: NetworkManager
  ethernets:
    enp0s5:   # 网卡名称
      dhcp4: no     # 关闭dhcp
      dhcp6: no
      addresses: [10.211.55.10/24]  # 静态ip
      gateway4: 10.211.55.1     # 网关
      nameservers:
        addresses: [8.8.8.8, 114.114.114.114] #dns

ubuntu22.04
# This is the network config written by 'subiquity'
network:
  ethernets:
    ens160:
      dhcp4: no
      addresses: [10.126.154.2/24]
      routes:
        - to: default
          via: 10.126.154.1
      nameservers:
        addresses: [114.114.114.114] 
  version: 2

dhcp

network:
  ethernets:
    ens33:
      dhcp4: true
  version: 2

bond

root@ubuntu:/etc/netplan# modprobe  bonding 
root@ubuntu:/etc/netplan# lsmod  |grep bond
bonding               167936  0
root@ubuntu:/etc/netplan# vim bond.yaml 
network:
  version: 2
  ethernets:
    eth1:
      addresses: []         #绑定单网卡不需要写IP地址
      dhcp4: no
    eth2:
      addresses: []
      dhcp4: no

  bonds:
    bond0:
      addresses:
        - 192.168.121.100/24
      gateway4: 192.168.121.2
      nameservers:
        addresses:
          - 114.114.114.114
      interfaces:
        - eth1
        - eth2
      parameters:          #参数
        mode: balance-rr       #bond模式  802.3ad  

bonding

[root@ network-scripts]# cat ifcfg-bond0 
DEVICE=bond0
BOOTPROTO=none
TYPE=bond0
ONBOOT=yes
IPADDR=192.168.30.122
NETMASK=255.255.255.0

[root@ network-scripts]# cat ifcfg-eth1
DEVICE=eth1
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes

[root@ network-scripts]# cat ifcfg-eth2
DEVICE=eth2
BOOTPROTO=none
TYPE=Ethernet
MASTER=bond0
SLAVE=yes

[root@node network-scripts]# vim /etc/modprobe.d/bonding.conf
[root@node network-scripts]# cat /etc/modprobe.d/bonding.conf
alias bond0 bonding
options bonding mode=1 miimon=100

cat  /proc/net/bonding/bond0
文章作者: emporer
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 Emporer-Linux
喜欢就支持一下吧