Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
docpublic:systemes:linux:virt_kvm [2017/02/19 15:02]
procacci@tem-tsp.eu [network]
docpublic:systemes:linux:virt_kvm [2017/02/22 18:21] (current)
procacci@tem-tsp.eu [add 2nd network on specific NIC]
Line 76: Line 76:
   * https://wiki.libvirt.org/page/VirtualNetworking   * https://wiki.libvirt.org/page/VirtualNetworking
   * https://seravo.fi/2012/virtualized-bridged-networking-with-macvtap   * https://seravo.fi/2012/virtualized-bridged-networking-with-macvtap
 +  * https://www.techotopia.com/index.php/Creating_a_CentOS_6_KVM_Networked_Bridge_Interface
 +  * http://www.rendoumi.com/xu-ni-hua-wang-luo-bi-jiao-tun-tap-macvlan-macvtap/
  
 <code> <code>
Line 127: Line 129:
 addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts addn-hosts=/var/lib/libvirt/dnsmasq/default.addnhosts
 [root@localhost ~]# cat /var/lib/libvirt/dnsmasq/default.hostsfile [root@localhost ~]# cat /var/lib/libvirt/dnsmasq/default.hostsfile
 +</code>
 +
 +
 +==== add 2nd network on specific NIC ====
 +
 +  * https://doc.opensuse.org/documentation/leap/virtualization/html/book.virt/cha.libvirt.networks.html
 +  * https://kashyapc.fedorapeople.org/virt/create-a-new-libvirt-bridge.txt
 +
 +definition manuelle du nouveau reseau
 +
 +<code>
 +[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>
 +</code>
 +
 +<code>
 +[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 ~]# 
 +</code>
 +
 +==== retrait reseau ====
 +
 +<code>
 +
 +[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
 +</code>
 +
 +==== ajout 2eme interface =====
 +
 +<code>
 +[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
 +
 </code> </code>
  
docpublic/systemes/linux/virt_kvm.1487516540.txt.gz · Last modified: 2017/02/19 15:02 by procacci@tem-tsp.eu
[unknown link type]Back to top
CC Attribution-Noncommercial-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0