Linux中配置网络地址,主机名

临时设置主机名 # hostname hello

exit退出终端,再重新进入生效

永久设置主机名

echo "hello" > /etc/hostname 或

vim /etc/hostnam

cat /etc/hostname

hello
重启计算机生效

reboot

检查结果

hostname

hello
配置静态ip地址参数
1.查看当前主机的网卡设备

nmcli connection show

名称 UUID 类型 设备
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
2.修改连接 "System eth0" 的配置
nmcli connection modify "System eth0" ipv4.method manual ipv4.addresses "172.25.0.11/24" connection.autoconnect yes
3.重新激活连接 "System eth0 ",通过 up指令激活,必要时可以先down再up

nmcli connection up "System eth0"

4.确保系统服务NetworkManager开机自启:

systemctl restart NetworkManager

systemctl enable NetworkManager

5.4)检查修改结果,确认无误
检查IP地址:

ifconfig eth0

收藏 打印