Sun, September 30, 2018 ยท 1 min read

Setting default gateway from virsh-net command line

Setting default gateway from virsh-net command line

Generally when a network is configured from virsh-define for a particular range say 192.168.4.0 it gateway will be automatically assigned to 192.168.4.1. If the gateway wants to be changed to 192.168.4.2 then it can be done by using virsh-net edit command line option from cli.

Add <route family='ipv4' address='192.168.4.0' prefix='24' gateway='192.168.4.2'/> inside the network XML.

Check the existing virsh networks:

virsh net-list

Stop the network, make configuration changes then start it:

virsh net-destroy cipher-nat2
virsh net-edit cipher-nat2
virsh net-start cipher-nat2