Centos7修改主机名称及IP

satuo20 1年前 ⋅ 328 阅读
  • 查看当前主机名称

hostname

  • 使用命令修改主机名称(youservername)

hostnamectl set-hostname youservername

  • 修改IP

vi /etc/sysconfig/network-scripts/ifcfg-eth0

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
#静态
BOOTPROTO=static
IPADDR=10.0.10.106
GATEWAY=10.0.10.1
NETMASK=255.255.255.0
DNS1=202.96.134.133

DEVICE=eth0
ONBOOT=yes
  • 重启网络

systemctl restart network.service 或者 service network restart

  • CentOS7 Failed to start LSB: Bring up/down networking.解决方法

解决方式:禁用NetworkManager,然后重启网络服务,能正常联网了!

systemctl stop NetworkManager
systemctl disable NetworkManager
service network restart

解决ping不通外网问题

场景1:
打开网络配置,ONBOOT="yes"然后重启
cat /etc/sysconfig/network-scripts/ifcfg-ens192
场景2:
打开网络配置,修改MACADDR然后重启
cat /etc/sysconfig/network-scripts/ifcfg-ens192
MACADDR=00:0c:29:2e:2c:20



全部评论: 0

    我有话说: