linux :ip地址配置

(1)命令行配置ip地址(自动)

read -p "please input 网卡名:" network
nmcli connection modify $network ipv4.method auto connection.autoconnect yes
nmcli connection up $network &> /dev/null
echo "$network 已经激活了"

(2)命令行配置ip地址(手动)

read -p "please input 网卡名:" network
nmcli connection modify $network ipv4.method manual ipv4.address 192.168.4.5/24 ipv4.gateway 192.168.4.254 ipv4.dns 8.8.8.8 connection.autoconnect yes
nmcli connection up $network &> /dev/null
echo "$network 已经激活了"

posted @ 2023-10-02 16:59  卷叶小树  阅读(60)  评论(0编辑  收藏  举报