Virtual machine configuration IP

2021.1.22 HYP
virtual machine needs to be configured to connect to the local area network.
Configuration method 1:

ifconfig ethX 192.168.0.100 network 192.168.0.1	
#100为ip,1为网关
#本方法关机失效

Configuration method 2

vi  /etc/sysconfig/network-scripts/ifcfg-ethx	
#基本配置参数
NAME='eth0'#
DEVICE=eth0#设备名称
IPADDR=192.168.1.1#IP地址
BOOTPROTO=ON
HWADDR= #MAC地址
ONBOOT=YES	#随服务启动
TYPE=Ethernet #类型为以太网
GATEWAY=
PREFIX=24#子网掩码24位相当于NATMASK=255.255.255.0
DNS1=8.8.8.8#第一个dns服务器
BOOTPROTO=none #设置none为禁止dhcp,设置static为静态ip,设置dhcp为开启dhcp服务
IPV6INIT=no	#禁止IPV6
USERCTL=no	#是否允许非root用户控制该设备,设置为no,只能用root用户更改
IPV4_FAILURE_FATAL=yes	#如果ipv4配置失败禁用设备
IPV6_FAILURE_FATAL=yes	#如果ipv6配置失败禁用设备
#配置随服务启动此配置开机生效
service restart network #重启网卡生效

Guess you like

Origin blog.csdn.net/m0_52425873/article/details/112972247