kvm虚拟化小结(十四)virbr0网段修改

KVM默认安装好后,会有一个virbr0,该网卡一般只做为物理机和虚拟机之间nat使用。其默认使用的网段是192.168.122.0/24网段,这就造成对应的内部虚拟机有一个在192.168.122.0/24段的IP。而有时这并不符合我们的要求,我们可以修改该网段的地址,当然也可以删除或禁用该网卡,改用其他网卡。

1、查看IP信息

[root@localhost ~]# ifconfig virbr0
virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:2f:c8:44  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2、查看网络情况

[root@localhost ~]# virsh net-list
 名称               状态     自动开始  持久
----------------------------------------------------------
 default              活动     是           是

3、查看当前的网段配置

virbr0

4、修改并启用

通过上面的net-edit命令打开后,我们修改对应的网段为172.25.0.0/24,并将对应的DHCP段的地址也修改掉。可以重启服务器生效,也可以通过下面的命令生效

[root@localhost ~]# virsh net-destroy  default
网络 default 被删除
[root@localhost ~]# virsh net-start default
网络 default 已启用
[root@localhost ~]# ifconfig virbr0
virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 172.25.0.1  netmask 255.255.255.0  broadcast 172.25.0.255
        ether 52:54:00:2f:c8:44  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

destroy之前,建议先通过net-dumpxml将配置导出。

5、其他

新增网卡也是一样的道理,与网段相关的命令如下:

virsh # help network
 Networking (help keyword 'network'):
    net-autostart                  autostart a network
    net-create                     create a network from an XML file
    net-define                     define an inactive persistent virtual network or modify an existing persistent one from an XML file
    net-destroy                    destroy (stop) a network
    net-dhcp-leases                print lease info for a given network
    net-dumpxml                    network information in XML
    net-edit                       edit XML configuration for a network
    net-event                      Network Events
    net-info                       network information
    net-list                       list networks
    net-name                       convert a network UUID to network name
    net-start                      start a (previously defined) inactive network
    net-undefine                   undefine a persistent network
    net-update                     update parts of an existing network's configuration
    net-uuid                       convert a network name to network UUID




本站的发展离不开您的资助,金额随意,欢迎来赏!

You can donate through PayPal.
My paypal id: itybku@139.com
Paypal page: https://www.paypal.me/361way

分类: 虚拟化云和自动化 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.