vmware设置centos静态ip

之前有过设置ubuntu静态ip的经验,这次安装设置centos感觉很顺利很简单。参考https://www.linuxidc.com/Linux/2017-10/147449.htm,照做就可以了。

1.vmware的配置我之前已经修改过,还是保持不变:

2.修改centos的配置:vim /etc/sysconfig/network-scripts

#修改
BOOTPROTO=static #将dhcp改为ststic
ONBOOT=yes #将no改为yes
#新增
IPADDR=192.168.141.21 #静态IP
GATEWAY=192.168.141.1 #默认网关
NETMASK=255.255.255.0 #子网掩码

改完后重启网络服务:service network restart

然后就好了,真的就好了,上网以及ssh登录都没问题,这是尝试装linux以来最简单直接的一次了,查看ip addr:
[[email protected] ~]# 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:35:94:01 brd ff:ff:ff:ff:ff:ff
    inet 192.168.141.10/24 brd 192.168.141.255 scope global noprefixroute dynamic ens33
       valid_lft 1458sec preferred_lft 1458sec
    inet 192.168.141.21/24 brd 192.168.141.255 scope global secondary ens33
       valid_lft forever preferred_lft forever
    inet6 fe80::8a04:3629:1c8e:4e06/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

参考文章:

1.https://www.linuxidc.com/Linux/2017-10/147449.htm

猜你喜欢

转载自www.cnblogs.com/shanhm1991/p/9903932.html