Linux静态ip地址配置

如何在一台虚拟机配置两个永久ip地址并且让其相互ping通?

配置要求

  1. 一台虚拟主机,运行版本linux6.5
  2. 配置IP:192.168.2.1,网口VMnet2,网卡eth0
  3. 配置IP:192.168.2.88,网口VMnet2,网卡eth1

IP:192.168.2.1配置

1.关闭防火墙和沙盒

iptables -F
setenforce 0

2.编辑网卡eth0

vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:11:11:AA
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.2.1
NETMASK=255.255.255.0
GATEWAY=192.168.2.1

IP:192.168.2.88配置

1.添加虚拟网卡

添加网卡:虚拟机 -> 设置 -> 网络适配器 -> 添加,并将模式都设置成VMnet2,如图:

在这里插入图片描述
ifcomfig查看eth1网卡信息,并复制eth1HWADDR。

2.复制eth0,编辑网卡eth1

cd /etc/sysconfig/network-scripts/
mv ifcfg-eth0 ifcfg-eth1
vim ifcfg-eth1
DEVICE=eth1
HWADDR=00:0C:29:11:11:B4
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.2.88
NETMASK=255.255.255.0
GATEWAY=192.168.2.88

3.重启网络服务,查看网卡配置信息

service network resatrt

ping测试

ping 192.168.1.88

大功告成!

猜你喜欢

转载自blog.csdn.net/qq_24263755/article/details/83065316