[root@localhost ~]# yum groupinstall Virtualization [root@localhost ~]# yum groupinstall "Virtualization Client"
[root@localhost ~]# service libvirtd status
[root@localhost ~]# qemu-img create -f qcow2 /vm/kvm/pfsense.qcow2 10G [root@localhost iso]# virt-install --vcpus=1 --ram=1024 --name=pfsense --file=/vm/kvm/pfsense.qcow2 --cdrom=/vm/iso/pfSense-CE-2.3.2-RELEASE-amd64.iso --hvm --vnc --network bridge:virbr0
[root@localhost ~]# brctl show
bridge name bridge id STP enabled interfaces
virbr0 8000.5254005d4f0b yes virbr0-nic
vnet0
[root@localhost ~]# ip addr
...
3: virbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
link/ether 52:54:00:5d:4e:0a brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN qlen 1000
link/ether 52:54:00:5d:4e:0a brd ff:ff:ff:ff:ff:ff
6: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master virbr0 state UNKNOWN qlen 1000
link/ether fe:54:00:ad:70:82 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc54:ff:fead:7082/64 scope link
valid_lft forever preferred_lft forever
[root@localhost ~]# nmap -sP 192.168.122.0/24
Starting Nmap 6.40 ( http://nmap.org ) at 2016-12-18 13:04 CET
Nmap scan report for 192.168.122.148
Host is up (0.00021s latency).
MAC Address: 52:54:00:AD:70:82 (QEMU Virtual NIC)
Nmap scan report for 192.168.122.1
Host is up.
Nmap done: 256 IP addresses (2 hosts up) scanned in 4.68 seconds
[root@localhost ~]# nmap 192.168.122.148
Starting Nmap 6.40 ( http://nmap.org ) at 2016-12-18 13:05 CET
Nmap scan report for 192.168.122.148
Host is up (0.00030s latency).
Not shown: 997 filtered ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
443/tcp open https
MAC Address: 52:54:00:AD:70:82 (QEMU Virtual NIC)
[root@localhost ~]# virsh net-dumpxml default
<network>
<name>default</name>
<uuid>048b8b48-18f5-4100-a708-c19df66bfabd</uuid>
<forward mode='nat'>
<nat>
<port start='1024' end='65535'/>
</nat>
</forward>
<bridge name='virbr0' stp='on' delay='0'/>
<mac address='52:54:00:5d:4f:0b'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
</network>
locatio of xml file
[root@localhost ~]# ls /etc/libvirt/qemu/networks/ autostart default.xml
lancé automatiquement par libvirt pour assurer la passralle DNS/DHCP
[root@localhost ~]# cat /var/lib/libvirt/dnsmasq/default.conf ##WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE ##OVERWRITTEN AND LOST. Changes to this configuration should be made using: ## virsh net-edit default ## or other application using the libvirt API. ## ## dnsmasq conf file created by libvirt strict-order pid-file=/var/run/libvirt/network/default.pid except-interface=lo bind-dynamic interface=virbr0 dhcp-range=192.168.122.2,192.168.122.254 dhcp-no-override dhcp-lease-max=253 dhcp-hostsfile=/var/lib/libvirt/dnsmasq/default.hostsfile addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts [root@localhost ~]# cat /var/lib/libvirt/dnsmasq/default.hostsfile
definition manuelle du nouveau reseau
[root@localhost ~]# cat /root/p4p1-net.xml <network> <name>p4p1_routed</name> <bridge name="virbr1" /> <forward mode="route" dev="p4p1"/> <ip address="192.168.22.1" netmask="255.255.255.0"> <dhcp> <range start="192.168.22.2" end="192.168.22.254" /> </dhcp> </ip> </network>
[root@localhost ~]# virsh net-list --all
Nom État Démarrage automatique Persistent
----------------------------------------------------------
default actif yes yes
[root@localhost ~]# virsh net-define p4p1-net.xml
Réseau p4p1_routed défini depuis p4p1-net.xml
[root@localhost ~]# virsh net-list --all
Nom État Démarrage automatique Persistent
----------------------------------------------------------
default actif yes yes
p4p1_routed inactif no yes
[root@localhost ~]# virsh net-start p4p1_routed
Réseau p4p1_routed démarré
[root@localhost ~]# virsh net-list --all
Nom État Démarrage automatique Persistent
----------------------------------------------------------
default actif yes yes
p4p1_routed actif no yes
[root@localhost ~]# virsh net-autostart p4p1_routed
Réseau p4p1_routed marqué en démarrage automatique
[root@localhost ~]# virsh net-list --all
Nom État Démarrage automatique Persistent
----------------------------------------------------------
default actif yes yes
p4p1_routed actif yes yes
[root@localhost ~]# ls /etc/libvirt/qemu/networks/
autostart default.xml p4p1_routed.xml
[root@localhost ~]# cat /etc/libvirt/qemu/networks/p4p1_routed.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
virsh net-edit p4p1_routed
or other application using the libvirt API.
-->
<network>
<name>p4p1_routed</name>
<uuid>1d3ddaa8-dffc-4194-a680-07680413daa2</uuid>
<forward dev='p4p1' mode='route'>
<interface dev='p4p1'/>
</forward>
<bridge name='virbr1' stp='on' delay='0'/>
<mac address='52:54:00:f6:a6:f4'/>
<ip address='192.168.22.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.22.2' end='192.168.22.254'/>
</dhcp>
</ip>
</network>
[root@localhost ~]#
[root@localhost ~]# virsh net-list --all Nom État Démarrage automatique Persistent ---------------------------------------------------------- default actif yes yes p4p1_routed actif yes yes [root@localhost ~]# virsh net-destroy p4p1_routed Réseau p4p1_routed détruit [root@localhost ~]# virsh net-list --all Nom État Démarrage automatique Persistent ---------------------------------------------------------- default actif yes yes p4p1_routed inactif yes yes [root@localhost ~]# virsh net-undefine p4p1_routed Le réseau p4p1_routed n'est plus défini [root@localhost ~]# virsh net-list --all Nom État Démarrage automatique Persistent ---------------------------------------------------------- default actif yes yes [root@localhost ~]# ls /etc/libvirt/qemu/networks/ autostart default.xml
[root@localhost ~]# brctl show bridge name bridge id STP enabled interfaces virbr0 8000.5254005d4f0b yes virbr0-nic vnet0 virbr1 8000.525400f6a6f4 yes virbr1-nic [root@localhost ~]# virsh attach-interface --domain pfsense --type bridge --source virbr1 --target eth2 --model virtioInterface attached successfully [root@localhost ~]# virsh domiflist pfsense Interface Type Source Model MAC ------------------------------------------------------- vnet0 bridge virbr0 rtl8139 52:54:00:ad:7a:83 eth2 bridge virbr1 virtio 52:54:00:c9:23:02