指定虛擬機網卡IP,除了可以在虛擬機裡設定,也可以直接在KVM 中直接設定
sudo virsh net-list
$ sudo virsh net-list
Name State Autostart Persistent
--------------------------------------------
default active yes yes
network active yes yes
virsh net-edit $NETWORK_NAME
<dhcp>
<range start='192.168.122.100' end='192.168.122.254'/>
<host mac='52:54:00:ed:3c:bc' name='winxp' ip='192.168.122.2'/>
<host mac='52:54:00:19:1b:70' name='loki' ip='192.168.122.3'/>
<host mac='52:54:00:b8:f1:68' name='gilLab' ip='192.168.122.4'/>
<host mac='' name='vm1' ip=''/>
</dhcp>
$NETWORK_NAME
是
sudo virsh net-destroy $NETWORK_NAME &&\
sudo virsh net-start $NETWORK_NAME
如果 KVM 有多張網卡,而虛擬機也會需要多張網卡需要設定 MTU,因為預設是1500 ,不設定有可能造成虛擬機網路無法出去的狀況。
virsh net-edit $NETWORK_NAME
<network>
...
<mtu size='9000' />
...
</network>
sudo reboot