首先查看网卡信息
root@it:~# ip add
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:2d:79:40 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.21/24 brd 192.168.121.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe2d:7940/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
link/ether 00:0c:29:2d:79:4a brd ff:ff:ff:ff:ff:ff
4: eth2:
link/ether 00:0c:29:2d:79:54 brd ff:ff:ff:ff:ff:ff
在 /etc/netplan/ 目录下的 00-installer-config.yaml (该文件每个人都会不一样)
root@it:~# vim /etc/netplan/00-installer-config.yaml
network:
version: 2
ethernets:
eth0:
addresses:
- 192.168.121.21/24
gateway4: 192.168.121.2
nameservers:
addresses:
- 8.8.8.8
eth1:
addresses:
- 192.168.121.22/24
gateway4: 192.168.121.2
nameservers:
addresses:
- 114.114.114.114
eth2:
addresses:
- 192.168.121.23/24
gateway4: 192.168.121.2
nameservers:
addresses:
- 114.114.144.144
加载配置
root@it:~# netplan apply
root@it:~# ip add
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:2d:79:40 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.21/24 brd 192.168.121.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe2d:7940/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
link/ether 00:0c:29:2d:79:4a brd ff:ff:ff:ff:ff:ff
inet 192.168.121.22/24 brd 192.168.121.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe2d:794a/64 scope link
valid_lft forever preferred_lft forever
4: eth2:
link/ether 00:0c:29:2d:79:54 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.23/24 brd 192.168.121.255 scope global eth2
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe2d:7954/64 scope link tentative
valid_lft forever preferred_lft forever
查看绑定的网卡信息
root@it:~# ip add
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:2d:79:40 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.21/24 brd 192.168.121.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe2d:7940/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
link/ether 00:0c:29:2d:79:4a brd ff:ff:ff:ff:ff:ff
4: eth2:
link/ether 00:0c:29:2d:79:54 brd ff:ff:ff:ff:ff:ff
在 /etc/netplan/ 目录下新建一个以 .yaml 结尾的文件
root@it:~# cd /etc/netplan/
root@it:/etc/netplan# touch bond.yaml
编辑该文件
root@it:/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模式
加载配置
root@it:/etc/netplan# netplan apply
root@it:/etc/netplan# ip add
1: lo:
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:
link/ether 00:0c:29:2d:79:40 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.21/24 brd 192.168.121.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe2d:7940/64 scope link
valid_lft forever preferred_lft forever
3: eth1:
link/ether 3e:ba:29:6c:0d:e4 brd ff:ff:ff:ff:ff:ff
4: eth2:
link/ether 3e:ba:29:6c:0d:e4 brd ff:ff:ff:ff:ff:ff
5: bond0:
link/ether 3e:ba:29:6c:0d:e4 brd ff:ff:ff:ff:ff:ff
inet 192.168.121.100/24 brd 192.168.121.255 scope global bond0
valid_lft forever preferred_lft forever
inet6 fe80::3cba:29ff:fe6c:de4/64 scope link
valid_lft forever preferred_lft forever
手机扫一扫
移动阅读更方便
你可能感兴趣的文章