虚拟机VMWare CentOs7 配置静态IP

虚拟机VMWare CentOs7 配置静态IP

  • 系统启动后没有IP
  • 设置静态IP
  • 查看虚拟机Mac
  • 查看Windows IP
  • 感谢分享

最近学习Zookeeper需要用到Linux静态IP, 特在此备忘操作.

系统启动后没有IP

虚拟机VMWare CentOs7 配置静态IP_第1张图片
感谢未干的咸鱼分享解决方案.

设置静态IP

[root@localhost ~]# clear
[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:42:52:7a brd ff:ff:ff:ff:ff:ff
    inet 192.168.101.30/24 brd 192.168.101.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe42:527a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

备份ens33

cp /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33_bak

配置静态ID

vi /etc/sysconfig/network-scripts/ifcfg-ens33
----------------------------------------------------------
DEVIE=eth1
# Machine Code
HWADDR=00:0C:29:42:52:7A
TYPE=Ethernet
# 开机时启动网络服务
ONBOOT=yes
NM_CONTROLLED=yes
# 使用静态IP
BOOTPROTO=static
# 前三位要和主机的ip地址一致,后一位为255
BROADCAST=192.168.101.255
DNS1=202.101.172.35
# 虚拟机的IP地址,前三位与主机的一致
IPADDR=192.168.101.30
NETMASK=255.255.255.0
# 主机的默认网关地址
GATEWAY=192.168.101.1
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes

重启网络服务

[root@localhost ~]# sudo service network restart
Restarting network (via systemctl):                        [  确定  ]


[root@localhost ~]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
# 可以看到IP地址已经设置为 192.168.101.30
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:0c:29:42:52:7a brd ff:ff:ff:ff:ff:ff
    inet 192.168.101.30/24 brd 192.168.101.255 scope global noprefixroute ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe42:527a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

查看虚拟机Mac

虚拟机VMWare CentOs7 配置静态IP_第2张图片

查看Windows IP

ipconfig

虚拟机VMWare CentOs7 配置静态IP_第3张图片

感谢分享

  1. hongdada - CentOS7.2 设置静态ip
  2. lurunxiu - 虚拟机下Centos7如何设置静态IP地址
  3. 一路前行1 - centOS 7下无法启动网络(service network start)错误解决办法

你可能感兴趣的:(zookeeper)