Monday, April 30, 2018

Modify Linux virtual Network for KVM Networking



I have created host-only network for VM internal networking such as host-only and now need to modify the IP address for the virtual interface, notice that the edit function is not available using virt-manager.

Given below I want to edit net1 interface IP address from 172.16.0.1 to 172.16.0.254.

1) Get network listing

[root@virtm ~]# virsh net-list
 Name                 State      Autostart     Persistent
----------------------------------------------------------
 net0                 active     yes           yes
 net1                 active     yes           yes
 net2                 active     yes           yes

2) edit the interface

[root@virtm ~]# virsh net-edit net1

<network>
  <name>net1</name>
  <uuid>e0952f30-c192-46ef-8898-bc8904a5dcb7</uuid>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='52:54:00:d4:44:d8'/>
  <domain name='net1'/>
  <ip address='172.16.0.1' netmask='255.255.255.0'>
  </ip>
</network>

Save and Quit

3) Restart the interface

[root@virtm ~]# virsh net-destroy net1
Network net1 destroyed

[root@virtm ~]# virsh net-start net1
Network net1 started

4) Verify the output using Linux ip command

[root@virtm ~]# ip a |grep vir

13: virbr1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN qlen 1000

    inet 172.16.0.254/24 brd 172.16.0.255 scope global virbr1