CentOS7 手动设置IP地址

启用网卡

https://cloud.tencent.com/developer/article/1445430

VirtualBox下安装好CentOS默认是没有启用网络连接的,我们需要手动启用,方法如下:

  1. 首先进到目录
cd /etc/sysconfig/network-scripts

  2.编辑ifcfg-enp0s3

vi ifcfg-enp0s3

Paste_Image.png

  3.具体修改如下:

ONBOOT=no

改为

ONBOOT=yes  # 自动开启网络连接

  4.重启服务

service network restart

虚拟机网络设置为桥接,此时ip是自动获取,ping一下百度应该可以通,但是自动获取会经常变化,固定一下方便链接。

查看网卡信息

nmcli connection show [enp0s3网卡名称]

安装ifconfig

https://www.cnblogs.com/zuikeol/p/9647662.html

  yum install net-tools.x86_64

安装vim

https://www.cnblogs.com/citta/p/9735448.html

sudo yum install -y vim

ifconfig -a 查询网卡名称

设置ip、网关和dns。ipv4.method manual表示配置方式为手动

[root@localhost ~]# nmcli connection modify [enp0s3网卡名称] \
> ipv4.method manual \
> ipv4.addresses 192.168.100.26 \
> ipv4.gateway 192.168.100.1 \
> ipv4.dns 192.168.100.1

使配置生效

nmcli connection up [enp0s3网卡名称]

 

posted @ 2020-04-05 16:07  荒野猛兽  阅读(2493)  评论(0编辑  收藏  举报