网站宣传文案,视频剪辑自学网站,华丰建设股份有限公司网站,企业内部网站建设方案目录 一.网络服务
开启network服务 网口IP配置 聚合口配置 前言
秋招拿到了科大讯飞的offer#xff0c;可是由于某些原因无法完成三方签署#xff0c;心情还是比较失落的#xff0c;或许写一篇技术博客#xff0c;活跃一下大脑思维也是一种不错的放松方式。 一.网络服务 …目录 一.网络服务
开启network服务 网口IP配置 聚合口配置 前言
秋招拿到了科大讯飞的offer可是由于某些原因无法完成三方签署心情还是比较失落的或许写一篇技术博客活跃一下大脑思维也是一种不错的放松方式。 一.网络服务
开启network服务 此脚本用于关闭NetworkManger服务重启network防止服务冲突导致IP配置无法生效 #!/bin/bash# 获取 NetworkManager 的 Active 状态去除括号
status$(systemctl status NetworkManager | grep Active: | awk {print $3} | tr -d ())# 检查状态是否不是 dead
if [ $status ! dead ]; thenecho NetworkManager is not dead. Stopping NetworkManager and restarting network...# 停止 NetworkManagersystemctl stop NetworkManager# 检查 systemctl stop 的退出状态if [ $? -ne 0 ]; thenecho Failed to stop NetworkManager.exit 1fi# 重启 network 服务注意这个服务名可能因系统而异例如在某些系统上可能是 networkingsystemctl restart network# 检查 systemctl restart 的退出状态if [ $? -ne 0 ]; thenecho Failed to restart network service.exit 1fiecho NetworkManager stopped and network service restarted successfully.
elseecho NetworkManager 网口IP配置 此脚本用于配置网口IP地址简化命令行操作 #!/bin/bash
interfaces$(ip a | awk /^[0-9]: / {printf %s , $2} END {print })
echo 可选择网卡如下$interfaces
read -p 请输入网口 eth
read -p 请输入IP eth_ip
read -p 请输入mask: eth_mask
echo IPADDR$eth_ip /etc/sysconfig/network-scripts/ifcfg-$eth
echo NETMASK$eth_mask /etc/sysconfig/network-scripts/ifcfg-$eth
echo 正在重启网络
systemctl restart network
echo 重启成功 聚合口配置 此脚本用于自动配置聚合口 #!/bin/bash
status$(systemctl status NetworkManager | grep Active: | awk {print $3} | tr -d ())
if [ $status ! dead ]
thenecho NetworkManager服务已开启
else# 开启 NetworkManagerecho 正在重启NetworkManagersystemctl restart NetworkManagerecho 重启成功
fi# 检查是否存在 bond0 连接
if nmcli connection show | grep -q bond0; thenecho Warning: bond0 connection already exists.exit 1 # 或者执行其他适当的操作例如删除现有连接再重新创建
fiif [ $# -ne 3 ]; thenecho Usage: $0 ip_address interface1 interface2exit 1
fiip_address$1
interface1$2
interface2$3nmcli connection add type bond con-name bond0 ifname bond0 bond.options modeactive-backup,miimon100
nmcli connection add type ethernet slave-type bond con-name bond0-port1 ifname ${interface1} master bond0
nmcli connection add type ethernet slave-type bond con-name bond0-port2 ifname ${interface2} master bond0
nmcli connection modify bond0 ipv4.addresses ${ip_address}/24 ipv4.method manual connection.autoconnect yes
nmcli connection modify bond0 connection.autoconnect-slaves 1
nmcli connection up bond0
echo Bond connection created successfully. 总结