linux虚拟机设置固定IP并实现联网,主机与虚拟机实现互ping

ifconfig eth0 up 启用第一块网卡

onboot=yes 自动启动

service network restart 重启网络服务

使用虚拟机添加一块桥接网卡

cp eth0 eth1 复制一份网卡配置文件

uuidgen eth1  查看 eth1 网卡UUID

MAC:0800276BE64D 记录虚拟机桥接网卡的MAC地址

修改 eth1 配置文件

device=eth1

bootproto=static (固定IP)

hwaddr=08:00:27:6B:E6:4D(mac地址)

uuid=(网卡UUID)
onboot=yes 
ipaddr=192.168.1.104 (设置的IP)
netmask=255.255.255.0 (子网掩码)
gateway=192.168.1.1 (网关)

ifconfig eth1 up 启用第二块网卡

service network restart

再次 查看ifconfig 

 OK

猜你喜欢

转载自www.cnblogs.com/chenjiale/p/10631356.html