linux 修改IP地址(设置为静态ip)和主机名
主机名: server0.example.com
ip地址: 172.25.0.11
网络掩码: 255.255.255.0
默认网关: 172.25.0.254
域名服务器:172.25.254.254
一、更改主机名:临时更改
hostname server0.example.com
永久更改
vim /etc/hostname(7.0版本)
server0.example.com
vim /etc/sysconfig/network (6.0)
server0.example.com
二、更改静态IP地址:(ifcfg-eth0是网卡名)
vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO static/none
IPADDR 192.168.1.1
PREFIX / NETMASK 24/255.255.255.0
GATEWAY 192.168.1.254
DNS1 202.106.0.20
nmcli connection reload
nmcli connection down "System eth0"
nmcli connection up "System eth0"