KVM設定轉殖虛擬機器的網路

2021-08-21 13:32:21 字數 1586 閱讀 6651

kvm轉殖虛擬機器後,需要設定虛擬機器的網路,進入虛擬機器後會發現沒有eth0網絡卡,是因為虛擬機器還使用原來的mac位址,需要修改之。

# 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 0x1af4:0x1000 (virtio-pci)

#subsystem=="net", action=="add", drivers=="?*", attr=="52:54:00:56:28:68", attr=="1", kernel=="eth*", name="eth0"

# pci device 0x1af4:0x1000 (virtio-pci)

subsystem=="net", action=="add", drivers=="?*", attr=="52:54:00:12:41:cd", attr=="1", kernel=="eth*", name="eth0"

更改網絡卡配置檔案/etc/sysconfig/network-scripts/ifcfg-eth0,將hwaddr的值修改為/etc/udev/rules.d/70-persistent-net.rules檔案中的新值,修改後如下:

# cat /etc/sysconfig/network-scripts/ifcfg-eth0 

device="eth0"

bootproto="none"

hwaddr="52:54:00:12:41:cd"

ipv6init="yes"

ipv6_autoconf="yes"

nm_controlled="yes"

onboot="yes"

type="ethernet"

uuid="49d231f8-c5c4-40cd-8ebb-2c0b2d7a7864"

ipaddr="172.16.101.12"

prefix="16"

gateway="172.16.0.254"

dns1="172.20.1.4"

dns2="180.76.76.76"

重啟系統。

注意:在轉殖虛擬機器時,好像virbr0會對虛擬機器的網路有影響(我在沒有關閉virbr0之前網路設定不成功,具體原因未知),可能需要關閉virbr0:

# virsh net-list 

# virsh net-destroy default

# virsh net-undefine default

# service libvirtd restart

KVM複製虛擬機器,KVM轉殖虛擬機器

1.關閉要轉殖的虛擬機器 2.語法 virt clone o 原虛擬機器 n 新虛擬機器 f 新虛擬機器存放的路徑 virt clone o centos7.0 n xuegod110 f var lib libvirt images xuegod110.img qcow2格式 virt clone...

kvm虛擬機器轉殖

原虛擬機器的完整拷貝,占用空間大.virt clone auto clone o web01 n web02 完整轉殖 virsh dumpxml web01 web02.xml vim web02.xml 修改虛擬機器的名字 刪除虛擬機器uuid 刪除mac位址 修改磁碟路徑 virsh defi...

kvm虛擬機器轉殖和操作

參考鏈結 virt clone o 192.168.0.242 sw web n 192.168.0.163 nginx f data kvm images 192.168.0.163 nginx.img virt clone o 192.168.0.235 sw web n 192.168.0.1...