虚拟机克隆之后网络配置--centros为例

虚拟机克隆时,是将原来机器所有信息都克隆过去,包括相应网卡设备mac地址的漫画信息,这个需要修改的;
同时一下网络规则删除也使用于Linux中eth0和eth1之间的互相修复
【环境】VMware、centros、克隆
对虚拟机中的一台centros机器克隆完成之后,针对新建服务器网络设置包括以下几步:
修改相应的配置

1、修改主机名–需要修改文件

/etc/hosts
/etc/sysconfig/network

2、修改网卡配置

cat/etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=172.17.40.247
NETMASK=255.255.254.0
GATEWAY=172.17.40.1

—–其中DEVICE和ifcfg-ethx根据实际修改
可以通过ip addr 查看哪个网卡设备是ok的 (查看网卡状态 也可以使用ifconfig -a 或者ethtool ethx )

3、删除网络规则,里面有相应的mac信息,删除重启服务器会根据ifcfg-ethx来重新生成

/etc/udev/rules.d/70-persistent-net.rules
[root@weijin-dev0001 etc]# cat udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:93:7a:ec", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:93:31:f4", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
[root@weijin-dev0001 etc]# cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:93:7a:ec", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:93:31:f4", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

找到上面ok的网卡设备,在70-persistent-net.rules中找到对应的PCI device信息,将此网络规则删除,最后重启服务器,在验证,是否ok

网卡启动常用命令:

service network restart
ifup eth0
ifdown eth0

参考文章:

https://www.2cto.com/os/201308/236031.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值