This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
docpublic:systemes:linux:virt_kvm [2016/12/18 11:09] procacci@tem-tsp.eu created |
docpublic:systemes:linux:virt_kvm [2017/02/22 18:21] (current) procacci@tem-tsp.eu [add 2nd network on specific NIC] |
||
---|---|---|---|
Line 4: | Line 4: | ||
* https:// | * https:// | ||
+ | |||
+ | ==== install packages ==== | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# yum groupinstall Virtualization | ||
+ | [root@localhost ~]# yum groupinstall " | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# service libvirtd status | ||
+ | </ | ||
+ | |||
+ | ==== VM pfsense ==== | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# qemu-img create -f qcow2 / | ||
+ | |||
+ | |||
+ | [root@localhost iso]# virt-install --vcpus=1 --ram=1024 --name=pfsense --file=/ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ==== information reseau pfsense ==== | ||
+ | |||
+ | |||
+ | < | ||
+ | [root@localhost ~]# brctl show | ||
+ | bridge name bridge id STP enabled interfaces | ||
+ | virbr0 8000.5254005d4f0b yes virbr0-nic | ||
+ | vnet0 | ||
+ | [root@localhost ~]# ip addr | ||
+ | ... | ||
+ | 3: virbr0: < | ||
+ | link/ether 52: | ||
+ | inet 192.168.122.1/ | ||
+ | | ||
+ | 4: virbr0-nic: < | ||
+ | link/ether 52: | ||
+ | 6: vnet0: < | ||
+ | link/ether fe: | ||
+ | inet6 fe80:: | ||
+ | | ||
+ | |||
+ | |||
+ | |||
+ | [root@localhost ~]# nmap -sP 192.168.122.0/ | ||
+ | |||
+ | Starting Nmap 6.40 ( http:// | ||
+ | Nmap scan report for 192.168.122.148 | ||
+ | Host is up (0.00021s latency). | ||
+ | MAC Address: 52: | ||
+ | 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 scan report for 192.168.122.148 | ||
+ | Host is up (0.00030s latency). | ||
+ | Not shown: 997 filtered ports | ||
+ | PORT STATE SERVICE | ||
+ | 22/ | ||
+ | 80/ | ||
+ | 443/tcp open https | ||
+ | MAC Address: 52: | ||
+ | |||
+ | </ | ||
+ | |||
+ | ===== network ===== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | * https:// | ||
+ | * http:// | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# virsh net-dumpxml default | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <forward mode=' | ||
+ | <nat> | ||
+ | <port start=' | ||
+ | </ | ||
+ | </ | ||
+ | <bridge name=' | ||
+ | <mac address=' | ||
+ | <ip address=' | ||
+ | < | ||
+ | <range start=' | ||
+ | </ | ||
+ | </ip> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | locatio of xml file | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# ls / | ||
+ | autostart | ||
+ | </ | ||
+ | |||
+ | ==== dnsmasq ==== | ||
+ | |||
+ | lancé automatiquement par libvirt pour assurer la passralle DNS/ | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# cat / | ||
+ | ## | ||
+ | ## | ||
+ | ## virsh net-edit default | ||
+ | ## or other application using the libvirt API. | ||
+ | ## | ||
+ | ## dnsmasq conf file created by libvirt | ||
+ | strict-order | ||
+ | pid-file=/ | ||
+ | except-interface=lo | ||
+ | bind-dynamic | ||
+ | interface=virbr0 | ||
+ | dhcp-range=192.168.122.2, | ||
+ | dhcp-no-override | ||
+ | dhcp-lease-max=253 | ||
+ | dhcp-hostsfile=/ | ||
+ | addn-hosts=/ | ||
+ | [root@localhost ~]# cat / | ||
+ | </ | ||
+ | |||
+ | |||
+ | ==== add 2nd network on specific NIC ==== | ||
+ | |||
+ | * https:// | ||
+ | * https:// | ||
+ | |||
+ | definition manuelle du nouveau reseau | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# cat / | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | |||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | [root@localhost ~]# virsh net-list --all | ||
+ | | ||
+ | ---------------------------------------------------------- | ||
+ | | ||
+ | |||
+ | [root@localhost ~]# virsh net-define p4p1-net.xml | ||
+ | Réseau p4p1_routed défini depuis p4p1-net.xml | ||
+ | |||
+ | [root@localhost ~]# virsh net-list --all | ||
+ | | ||
+ | ---------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@localhost ~]# virsh net-start p4p1_routed | ||
+ | Réseau p4p1_routed démarré | ||
+ | |||
+ | [root@localhost ~]# virsh net-list --all | ||
+ | | ||
+ | ---------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@localhost ~]# virsh net-autostart p4p1_routed | ||
+ | Réseau p4p1_routed marqué en démarrage automatique | ||
+ | |||
+ | [root@localhost ~]# virsh net-list --all | ||
+ | | ||
+ | ---------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@localhost ~]# ls / | ||
+ | autostart | ||
+ | [root@localhost ~]# cat / | ||
+ | <!-- | ||
+ | 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. | ||
+ | --> | ||
+ | |||
+ | < | ||
+ | < | ||
+ | < | ||
+ | <forward dev=' | ||
+ | < | ||
+ | </ | ||
+ | <bridge name=' | ||
+ | <mac address=' | ||
+ | <ip address=' | ||
+ | < | ||
+ | <range start=' | ||
+ | </ | ||
+ | </ip> | ||
+ | </ | ||
+ | [root@localhost ~]# | ||
+ | </ | ||
+ | |||
+ | ==== retrait reseau ==== | ||
+ | |||
+ | < | ||
+ | |||
+ | [root@localhost ~]# virsh net-list --all | ||
+ | | ||
+ | ---------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@localhost ~]# virsh net-destroy p4p1_routed | ||
+ | Réseau p4p1_routed détruit | ||
+ | |||
+ | [root@localhost ~]# virsh net-list --all | ||
+ | | ||
+ | ---------------------------------------------------------- | ||
+ | | ||
+ | | ||
+ | |||
+ | [root@localhost ~]# virsh net-undefine p4p1_routed | ||
+ | Le réseau p4p1_routed n'est plus défini | ||
+ | |||
+ | [root@localhost ~]# virsh net-list --all | ||
+ | | ||
+ | ---------------------------------------------------------- | ||
+ | | ||
+ | |||
+ | [root@localhost ~]# ls / | ||
+ | autostart | ||
+ | </ | ||
+ | |||
+ | ==== ajout 2eme interface ===== | ||
+ | |||
+ | < | ||
+ | [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 | ||
+ | ------------------------------------------------------- | ||
+ | vnet0 bridge | ||
+ | eth2 | ||
+ | |||
+ | </ | ||
+ |