-
网络参数设置
- nmtui设置:dns服务器、ip地址、子网掩码、网关、主机
- 永久设置主机名,配置文件/etc/hostname(默认不存在)
- [root@localhost ~]# echo ‘Server’ > /etc/hostname
[root@localhost ~]# cat /etc/hostname
Server - nmcli永久设置
- 查看
- [root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
System eth0 84a4d039-0c51-4767-928b-ad563f300f07 ethernet eth0 //网卡名称System eth0
virbr0 77032656-17ba-40d3-a121-a979389b7386 bridge virbr0 - 更改
- [root@localhost ~]# nmcli connection modify ‘System eth0’ ipv4.method manual ipv4.addresses 10.211.55.21/24 ipv4.gateway 10.211.55.1 connection.autoconnect yes
- 激活
- [root@localhost ~]# nmcli connection up ‘System eth0’
-
dns服务器
- 配置文件/etc/resolv.conf
- [root@localhost ~]# echo ‘nameserver 223.5.5.5’ > /etc/resolv.conf
[root@localhost ~]# cat /etc/resolv.conf
nameserver 223.5.5.5
-
查看网关
- route
- [root@localhost ~]# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default gateway 0.0.0.0 UG 100 0 0 eth0
10.211.55.0 0.0.0.0 255.255.255.0 U 100 0 0 eth0
192.168.122.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
-
链路聚合
- 备份网卡,提高可靠性
- 作用
-
- 轮询式(roundrobin)的流量负载均衡
-
- 热备份(activebackup)连接冗余
- 操作步骤:
-
- 虚拟新网卡team0
- [root@Server ~]# nmcli connection add type team ifname team0 con-name team0 autoconnect yes config ‘{“runner”:{“name”:“activebackup”}}’
连接 “team0” (02b45fd8-410c-4920-aea0-f0d3dd5ffa2c) 已成功添加。 -
- 添加成员
- [root@Server ~]# nmcli connection add type team-slave ifname eth1 con-name team0-1 master team0
连接 “team0-1” (e3a9017d-3c2b-4474-b134-1ce7ac2a9d62) 已成功添加。
[root@Server ~]# nmcli connection add type team-slave ifname eth2 con-name team0-2 master team0
连接 “team0-2” (399703ff-ed17-4dab-9172-d02caae65bb7) 已成功添加。 -
- 配置team0并激活
- [root@Server ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses 10.211.55.55/24 autoconnect yes
[root@Server ~]# nmcli connection up team0
连接已成功激活(master waiting for slaves)(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/10) - 如果配置错误可以删除
- nmcli connection delete team0
- nmcli connection delete team0-1
- nmcli connection delete team0-2
-
- 查看team0状态
- [root@Server ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
eth1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eth1 -
- 测试切换
- [root@Server ~]# ifconfig eth1 down
[root@Server ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
eth1
link watches:
link summary: down
instance[link_watch_0]:
name: ethtool
link: down
down count: 1
eth2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eth2
应用管理-综合串讲
最新推荐文章于 2024-09-14 20:37:51 发布