1. 程式人生 > >Vmware復制完好的linux目錄後網卡操作

Vmware復制完好的linux目錄後網卡操作

lib single eth1 core eth0 root ipv6 記錄 print

目錄

  • Vmware復制完好的linux目錄後網卡操作
    • 修改/etc/udev/rules.d/70-persistent-net.rules
    • 修改網卡配置文件
    • 重啟查看

Vmware復制完好的linux目錄後網卡操作

為了減少工作量,目前需要對已經安裝好系統的linux,進行復制。采用直接復制目錄的方式,那麽後續會出現網卡配置沖突問題,那麽如何解決呢?

OS 版本:

[root@kyeupdb ~]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: OracleServer
Description:    Oracle Linux Server release 6.9
Release:    6.9
Codename:   n/a

修改/etc/udev/rules.d/70-persistent-net.rules

  • 查看現有的IP地址
[root@kyeupdb ~]# ifconfig 
eth1      Link encap:Ethernet  HWaddr 00:50:56:38:CC:A3  
          inet addr:192.168.1.115  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:fe38:cca3/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:205 errors:0 dropped:0 overruns:0 frame:0
          TX packets:75 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:49848 (48.6 KiB)  TX bytes:13452 (13.1 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
  • 修改文件
[root@kyeupdb ~]# vi /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 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:f0:2d:c6", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:38:cc:a3", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

把上面的eth0一行進行註釋,並把eth1的名字修改成eth0,記錄mac地址:00:50:56:38:cc:a3

修改網卡配置文件

DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=none
HWADDR=00:50:56:38:cc:a3
IPADDR=192.168.1.20
PREFIX=24
GATEWAY=192.168.1.1
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"

刪除UUID,並把mac地址修改成記錄的mac。

重啟查看

Vmware復制完好的linux目錄後網卡操作