当前位置: 移动技术网 > 科技>操作系统>Linux > centos中网卡的配置

centos中网卡的配置

2019年09月17日  | 移动技术网科技  | 我要评论
我们在虚拟机中安装好centos后,需要手动配置网卡,得到IP。可以先配置临时IP,然后在远程连接软件中配置永久IP。 ...

配置临时ip:

ip a a 192.168.59.100/24 dev ens32 
ifconfig ens32 192.168.59.100 up 

在linux最小安装之后,一般需要手动配置网络地址。

初始化界面:

一、简单的利用dhcp获取

1、进入网卡配置文件

 1 cd /etc/sysconfig/network-scripts/ 

2、ls列出network-scripts目录下的文件

3、找到ifcfg-ens33,进入ifcfg-ens33文件,修改onboot的no为yes

bootproto=static  #静态ip
bootproto=dhcp   #动态ip
bootproto=none   #无(不指定)

通常情况下自己配置时为none

4、重启网络地址:

systemctl restart network        #重启网络服务
ip a / ifconfig                  #查看网络地址。

5.重启或关机后再次连接

reboot
poweroff
shutdown -r now
shutdown now

二、手动配置ip。

cd /etc/sysconfig/network-scripts/          #进入网卡配置文件
vi ifcfg-ens33                              #配置网卡
################
name=ens33                                  #网卡名称
device=ens33                                #设备名称
onboot=yes                                  #开机启动
bootproto=none                              #ip获取方式
ipaddr=192.168.59.103                       #ip地址
netmask=255.255.255.0                       #网络掩码
gateway=192.168.59.2                        #网关地址
dns1=192.168.59.2                           #dns1号地址
##################

systemctl restart network
reboot

在第三步中,得到子网和掩码,所用ip可以从192.168.59.3-192.168.59.254中随便获取一个。

附加:

如何得到centos的网关和ip:

 

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网