Ubuntu server20.04命令及网络配置

浏览次数:
AI摘要

Linux双网卡绑定实现就是使用两块网卡虚拟成为一块网卡,这个聚合起来的设备看起来是一个单独的以太网接口设备。

摘要由作者通过智能技术生成

1.设置root用户密码后可切换到root登录

sudo passwd root,su root

2.在Ubuntu20.04版本中使用netplan管理网络,netplan 配置文件:/etc/netplan/*.yaml,文件名每个不一样

1).修改网卡配置,编辑网络配置文件vim /etc/netplan/00-installer-config.yaml

Ubuntu server20.04常用命令及网络配置(图1)

2).加载刚刚修改的配置文件信息,执行netplan apply

3.安装ifconfig、netstat命令,执行apt install net-tools

4.修改镜像源地址,执行vim /etc/apt/sources.list 修改好后执行apt update更新源

5.DNS服务器设置,vi /etc/systemd/resolved.conf 在其中添加dns信息DNS=114.114.114.114

依次执行如下命令:systemctl restart systemd-resolved ,systemctl enable systemd-resolved ,mv /etc/resolv.conf  /etc/resolv.conf.bak ,ln -s /run/systemd/resolve/resolv.conf /etc/再查看/etc/resolv.conf文件就可以看到新的dns信息已经写入其中了

6.配置网卡绑定以及静态路由

双网卡绑定:

Ubuntu server20.04常用命令及网络配置(图2)

多网卡绑定:

Ubuntu server20.04常用命令及网络配置(图3)

重载内核bonding模块执行modprobe bonding,查看bond模式执行cat /proc/net/bonding/bond0