Linux学习笔记网卡配置的脚本

网卡配置的小jio本

#!/bin/bash
echo -e “1)查看\t2)修改\t3)添加\t4)删除\t5)启动\t6)停止”
YES=“y”
while [[ $YES == “y” ]]; do
read -e -p “请输入你操作编号(如:1、2、3、4、5、6):” read01
if [[ $read01 == “1” ]] || [[ $read01 == “2” ]] || [[ $read01 == “3” ]] || [[ $read01 == “4” ]] || [[ $read01 == “5” ]] || [[ $read01 == “6” ]]; then
YES=“n”
else
echo “输入错误!请重新输入”
YES=“y”
fi
done
case $read01 in
1)
nmcli connection | awk ‘{print $1"\t"$4}’
echo “---------------------------------------”
;;
2)
nmcli connection | awk ‘{print $1"\t"$4}’
echo “---------------------------------------”
read -e -p “请输入<网卡连接名>:” ifcfg01
read -e -p “请输入<网卡IP地址/掩码位>:” ifcfg02
read -e -p “请输入<网卡网关>:” ifcfg03
read -e -p “请输入<网卡DNS指向>:” ifcfg04
nmcli connection modify $ifcfg01 ipv4.method manual ipv4.addresses $ifcfg02 ipv4.gateway $ifcfg03 ipv4.dns $ifcfg04 autoconnect yes
systemctl restart NetworkManager network
echo “---------------------------------------”
nmcli connection | awk ‘{print $1"\t"$4}’
exit 0
;;
3)
nmcli connection | awk ‘{print $1"\t"$4}’
echo “---------------------------------------”
read -e -p “请输入<网卡连接名>:” ifcfg01
read -e -p “请输入<网卡设备名>:” ifcfg02
read -e -p “请输入<网卡IP地址/掩码位>:” ifcfg03
read -e -p “请输入<网卡网关>:” ifcfg04
read -e -p “请输入<网卡DNS指向>:” ifcfg05
nmcli connection add type ethernet con-name $ifcfg01 ifname $ifcfg02 ipv4.method manual ipv4.addresses $ifcfg03 ipv4.gateway $ifcfg04 ipv4.dns $ifcfg05 autoconnect yes
nmcli connection up $ifcfg01
systemctl restart NetworkManager network
echo “--------------------------------------”
nmcli connection | awk ‘{print $1"\t"$4}’
exit 0
;;
4)
nmcli connection | awk ‘{print $1"\t"$4}’
echo “--------------------------------------”
read -e -p “请输入<网卡连接名>:” ifcfg01
nmcli connection delete $ifcfg01
systemctl restart NetworkManager network
echo “--------------------------------------”
nmcli connection | awk ‘{print $1"\t"$4}’
exit 0
;;
5)
nmcli connection | awk ‘{print $1"\t"$4}’
echo “--------------------------------------”
read -e -p “请输入<网卡连接名>:” ifcfg01
nmcli connection up $ifcfg01
echo “--------------------------------------”
nmcli connection | awk ‘{print $1"\t"$4}’
exit 0
;;
6)
nmcli connection | awk ‘{print $1"\t"$4}’
echo “--------------------------------------”
read -e -p “请输入<网卡连接名>:” ifcfg01
nmcli connection down $ifcfg01
echo “--------------------------------------”
nmcli connection | awk ‘{print $1"\t" $4}’
exit 0
;;
esac

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值