numero61:tuto_vbox_p._15-20
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
numero61:tuto_vbox_p._15-20 [2012/08/01 18:35] – frangi | numero61:tuto_vbox_p._15-20 [2012/08/11 18:53] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | |||
+ | |||
+ | |||
** | ** | ||
This all started when I needed to run a sandboxed instance of Wordpress. The simple part was creating a virtual Ubuntu 11.10 server as a guest inside my VirtualBox host. Then I discovered I knew much less about networking than I thought, a topic full of packets and switches and routing. I know even less about networking in VirtualBox, where all that stuff is virtualized in software. Several attempts and a networking crash-course later, mission accomplished, | This all started when I needed to run a sandboxed instance of Wordpress. The simple part was creating a virtual Ubuntu 11.10 server as a guest inside my VirtualBox host. Then I discovered I knew much less about networking than I thought, a topic full of packets and switches and routing. I know even less about networking in VirtualBox, where all that stuff is virtualized in software. Several attempts and a networking crash-course later, mission accomplished, | ||
** | ** | ||
- | Tout a commencé quand j'ai eu besoin d' | + | Tout a commencé quand j'ai eu besoin d' |
** | ** | ||
Ligne 17: | Ligne 20: | ||
Options de réseau dans VirtualBox | Options de réseau dans VirtualBox | ||
- | Installez | + | Installez |
- | Pour l'une de vos machines virtuelles installées, | + | Sur n'importe laquelle |
Il se peut que vous ayez besoin de plusieurs adaptateurs de différents types, ou du même type avec des paramètres différents, | Il se peut que vous ayez besoin de plusieurs adaptateurs de différents types, ou du même type avec des paramètres différents, | ||
- | ===== to do ===== | + | |
** | ** | ||
For my virtual web-server running Wordpress, things get a bit more complex, so here we go... The Adapter Type defines the virtual hardware available to your virtual machine (VM). VirtualBox will do its best to mediate the virtual network card with whatever physical adapters you have on your host machine. Open the Advanced pane and you get additional options for setting up your network adapter. I'm going to run through the settings deliberately out of sequence, starting with the Adapter type. | For my virtual web-server running Wordpress, things get a bit more complex, so here we go... The Adapter Type defines the virtual hardware available to your virtual machine (VM). VirtualBox will do its best to mediate the virtual network card with whatever physical adapters you have on your host machine. Open the Advanced pane and you get additional options for setting up your network adapter. I'm going to run through the settings deliberately out of sequence, starting with the Adapter type. | ||
Ligne 29: | Ligne 32: | ||
Adapter Type : VirtualBox will attempt to emulate some common types of network cards for which it has the drivers and protocols. PCnet-FAST III is the default selection, although I often select the Intel PRO/1000MT adapters if I'm looking for better compatibility with Intel hardware. There are two server versions for higher throughput if you intend your VM to run hot in a production environment. Desktop users needn' | Adapter Type : VirtualBox will attempt to emulate some common types of network cards for which it has the drivers and protocols. PCnet-FAST III is the default selection, although I often select the Intel PRO/1000MT adapters if I'm looking for better compatibility with Intel hardware. There are two server versions for higher throughput if you intend your VM to run hot in a production environment. Desktop users needn' | ||
** | ** | ||
+ | |||
+ | Quant à mon serveur web virtuel exécutant Wordpress, les choses deviennent un peu plus complexes, donc voilà... Le type d' | ||
+ | |||
+ | Adapter Type : VirtualBox va tenter d' | ||
** | ** | ||
Ligne 37: | Ligne 44: | ||
There is a little button on the right to regenerate the MAC address; should you clone a virtual machine, it will need its own unique MAC to run on your virtual network alongside the original. | There is a little button on the right to regenerate the MAC address; should you clone a virtual machine, it will need its own unique MAC to run on your virtual network alongside the original. | ||
** | ** | ||
+ | Mode : le « mode Promiscuous », au nom qui sonne plutôt osé, correspond au comportement du commutateur virtuel utilisé par le réseau interne ; Bridged (en pont) et Host Only (seulement l' | ||
+ | |||
+ | Adresse MAC : nom court pour Media Access Control, l' | ||
+ | |||
+ | Il y a un petit bouton sur la droite pour régénérer l' | ||
+ | |||
** | ** | ||
Ligne 43: | Ligne 56: | ||
Finally, the Port Forwarding button opens another dialog allowing you to define the traffic rules for the adapter; how traffic of certain types is routed between host and guest. This applies only to certain network attachments which we will look at next. This is determined by the Attached to option (with its little pal, the Name option), which is the sharp end of networking in VirtualBox, and the thing that gave me most trouble at the start of my experiment. | Finally, the Port Forwarding button opens another dialog allowing you to define the traffic rules for the adapter; how traffic of certain types is routed between host and guest. This applies only to certain network attachments which we will look at next. This is determined by the Attached to option (with its little pal, the Name option), which is the sharp end of networking in VirtualBox, and the thing that gave me most trouble at the start of my experiment. | ||
** | ** | ||
+ | |||
+ | La case à cocher Cable Connected fait la même chose que de brancher ou débrancher un câble physique. Il s'agit du paramètre qui relie votre carte réseau virtuelle à votre réseau virtuel. Elle est différente de la case tout en haut, Enable Network Adapter, qui vous permet d' | ||
+ | |||
+ | Enfin, le bouton Port Forwarding ouvre une autre boîte de dialogue vous permettant de définir les règles de trafic sur la carte, comment le trafic de certains types est acheminé entre l' | ||
** | ** | ||
Ligne 56: | Ligne 73: | ||
• Host Only, and | • Host Only, and | ||
• Internal Network. | • Internal Network. | ||
- | ** | ||
- | ** | ||
'Not attached' | 'Not attached' | ||
+ | ** | ||
+ | « Ici résident les dragons » | ||
+ | |||
+ | Il y a quatre types de rattachement au réseau disponibles et de nombreuses combinaisons possibles de paramètres parmi les autres contrôles. C'est là que la mise en réseau de VirtualBox peut ressembler à de la sorcellerie médiévale. La démarche pour faire le bon choix selon votre besoin donné peut être simple. Il peut même y avoir plusieurs bonnes solutions pour atteindre votre objectif. Mais tout le reste semble voué à l' | ||
+ | |||
+ | Types de rattachement au réseau | ||
+ | |||
+ | Nous avons quatre options possibles ici : | ||
+ | • Network Address Translation, | ||
+ | • Bridged ; | ||
+ | • Host Only ; | ||
+ | • Internal Network. | ||
+ | |||
+ | « Not attached » est aussi un type, mais utilisé dans le but de garder un adaptateur en place pour le débogage. Dans ce mode, VirtualBox avertit la VM qu'une carte réseau est présente, mais il n'y a pas de connexion. | ||
+ | |||
+ | |||
+ | |||
+ | ** | ||
Network Address Translation (NAT) | Network Address Translation (NAT) | ||
Ligne 67: | Ligne 100: | ||
When a guest machine sends an IP packet to some remote machine, the VirtualBox NAT service will intercept the packet, extract the TCP/IP segments, change the IP address to the IP address of the host machine, then send it. The outside world only sees the IP address of the host machine. Replies are received by the host machine and sent on to the Guest Machine. | When a guest machine sends an IP packet to some remote machine, the VirtualBox NAT service will intercept the packet, extract the TCP/IP segments, change the IP address to the IP address of the host machine, then send it. The outside world only sees the IP address of the host machine. Replies are received by the host machine and sent on to the Guest Machine. | ||
** | ** | ||
+ | |||
+ | Network Address Translation (NAT) | ||
+ | |||
+ | Le NAT permet à la machine invitée d' | ||
+ | |||
+ | Quand un ordinateur invité envoie un paquet IP à une machine distante, le service NAT de VirtualBox va intercepter le paquet, extraire les segments TCP/IP, changer l' | ||
** | ** | ||
Ligne 76: | Ligne 115: | ||
NAT is useful when you don't really care what IP addresses your guest machines use, so long as they are unique. You will need to do more configuration when you need to forward traffic or expose services like a web-server to the outside world. Additionally, | NAT is useful when you don't really care what IP addresses your guest machines use, so long as they are unique. You will need to do more configuration when you need to forward traffic or expose services like a web-server to the outside world. Additionally, | ||
** | ** | ||
+ | |||
+ | Par exemple, sur votre réseau domestique, votre hôte et d' | ||
+ | |||
+ | Le manuel de VirtualBox est un peu plus explicite : | ||
+ | |||
+ | « En mode NAT, l' | ||
+ | Le NAT est utile lorsque vous n'avez pas vraiment besoin de savoir quelles adresses IP vos machines virtuelles utilisent, tant qu' | ||
** | ** | ||
Ligne 84: | Ligne 130: | ||
The Bridged Adapter connects through the host to your default network device that allocates IP addresses for your physical network. VirtualBox connects to one of your installed network cards and exchanges network packets directly; it bridges the virtual and physical networks. In normal use, it will try to get a standard 192.168.x.x IP address from your router, so that your virtual machine can look like a perfectly respectable physical device alongside all the other ironmongery on your network. | The Bridged Adapter connects through the host to your default network device that allocates IP addresses for your physical network. VirtualBox connects to one of your installed network cards and exchanges network packets directly; it bridges the virtual and physical networks. In normal use, it will try to get a standard 192.168.x.x IP address from your router, so that your virtual machine can look like a perfectly respectable physical device alongside all the other ironmongery on your network. | ||
** | ** | ||
+ | |||
+ | Adaptateur Bridged (ponté) | ||
+ | |||
+ | Avec l' | ||
+ | |||
+ | L' | ||
** | ** | ||
Ligne 92: | Ligne 144: | ||
So my host connects as 192.168.0.2, | So my host connects as 192.168.0.2, | ||
** | ** | ||
+ | |||
+ | Vous pouvez avoir plus d'un périphérique réseau actif disponible sur votre hôte ; par exemple, mon ordinateur portable dispose d'un port Ethernet filaire (appelé eth0) et une carte sans fil (appelé wlan0). | ||
+ | |||
+ | Dans mon cas, j' | ||
+ | Ainsi, mon hôte se connecte en tant que 192.168.0.2, | ||
+ | |||
** | ** | ||
Ligne 103: | Ligne 161: | ||
Under the Host-only adapter, virtual machines can communicate between each other and with the hosting system but not outside. The Host-only adapter uses its own dedicated network device, called vboxnet0, to set up a sub-net and allocates IP addresses to guest machines. The guest machines cannot communicate with the outside world, since they are not connected via a physical interface. Host-only provides restricted services, useful for creating private networks under a VirtualBox host for its guests. | Under the Host-only adapter, virtual machines can communicate between each other and with the hosting system but not outside. The Host-only adapter uses its own dedicated network device, called vboxnet0, to set up a sub-net and allocates IP addresses to guest machines. The guest machines cannot communicate with the outside world, since they are not connected via a physical interface. Host-only provides restricted services, useful for creating private networks under a VirtualBox host for its guests. | ||
** | ** | ||
+ | |||
+ | Venez voir par ici, il y a plus... | ||
+ | |||
+ | Le NAT est utile parce qu'il protège nos systèmes invités de l' | ||
+ | Si votre périphérique d' | ||
+ | |||
+ | L' | ||
+ | |||
+ | Avec l' | ||
+ | |||
** | ** | ||
Ligne 108: | Ligne 176: | ||
Typically your host has its own network address, the one it uses to access the Internet - commonly 192.168.0.101. Under Host-only, the host machine also becomes the VirtualBox router, with the default IP address of 192.168.56.1. The Host creates an internal local area network serving all the guest machines set-up for Host-only, visible to the rest of your network. The vboxnet0 adapter starts issuing IP addresses from 192.168.56.101 onward, but you can change the default IP address allocation, if you want. | Typically your host has its own network address, the one it uses to access the Internet - commonly 192.168.0.101. Under Host-only, the host machine also becomes the VirtualBox router, with the default IP address of 192.168.56.1. The Host creates an internal local area network serving all the guest machines set-up for Host-only, visible to the rest of your network. The vboxnet0 adapter starts issuing IP addresses from 192.168.56.101 onward, but you can change the default IP address allocation, if you want. | ||
+ | ** | ||
+ | Contrairement à d' | ||
+ | |||
+ | Généralement, | ||
+ | |||
+ | ** | ||
Similar to the Bridged adapter, Host-only uses different address ranges. You can easily allow guest machines to obtain addresses using the DCHP (dynamic allocation, which will likely be a different address per session) that VirtualBox provides. | Similar to the Bridged adapter, Host-only uses different address ranges. You can easily allow guest machines to obtain addresses using the DCHP (dynamic allocation, which will likely be a different address per session) that VirtualBox provides. | ||
+ | |||
+ | Additionally, | ||
** | ** | ||
+ | |||
+ | Comme l' | ||
+ | |||
+ | De plus, le réseau Host-only pour l' | ||
+ | |||
** | ** | ||
- | Additionally, | ||
Internal network | Internal network | ||
Ligne 120: | Ligne 200: | ||
The Internal network option creates, according to the VirtualBox manual, "a software-based network which is visible to selected virtual machines, but not to applications running on the host or to the outside world." | The Internal network option creates, according to the VirtualBox manual, "a software-based network which is visible to selected virtual machines, but not to applications running on the host or to the outside world." | ||
- | ** | ||
- | ** | ||
This is where you begin to see the different types of network setups come into their own, being fit for different purposes. Which brings me back to my start-point; | This is where you begin to see the different types of network setups come into their own, being fit for different purposes. Which brings me back to my start-point; | ||
+ | ** | ||
+ | Réseau interne | ||
+ | |||
+ | Si vous voulez faire communiquer plusieurs machines virtuelles les unes avec les autres sur un seul hôte, mais avec rien d' | ||
+ | |||
+ | L' | ||
+ | |||
+ | C'est ici que vous commencez à voir que les différents types de configurations réseau s' | ||
+ | |||
+ | ** | ||
Guest Access to the Internet | Guest Access to the Internet | ||
Ligne 133: | Ligne 221: | ||
I begin by keeping the default networking NAT adapter. This allows the guest machine to access the Internet through my host’s connection. The guest isn't visible to anyone else on my network; I cannot access any guest resources from my host machine either, nor can any guest machines access each other. | I begin by keeping the default networking NAT adapter. This allows the guest machine to access the Internet through my host’s connection. The guest isn't visible to anyone else on my network; I cannot access any guest resources from my host machine either, nor can any guest machines access each other. | ||
** | ** | ||
+ | |||
+ | Accès des machines virtuelles à l' | ||
+ | |||
+ | Tout d' | ||
+ | |||
+ | En choisissant ma machine virtuelle dans la fenêtre VirtualBox Manager, je clique ensuite sur Settings > Network. | ||
+ | |||
+ | Je commence par garder la valeur par défaut de l' | ||
** | ** | ||
Ligne 142: | Ligne 238: | ||
By default, vboxnet0 has a DHCP server set up to dynamically allocate IP addresses on a per session basis. I want my Wordpress virtual server to keep static IP addresses, so on the DHCP tab, I uncheck the “Enable Server” box for DHCP. | By default, vboxnet0 has a DHCP server set up to dynamically allocate IP addresses on a per session basis. I want my Wordpress virtual server to keep static IP addresses, so on the DHCP tab, I uncheck the “Enable Server” box for DHCP. | ||
- | Add Host-only Adapter to Guest | ||
** | ** | ||
+ | |||
+ | Configurer l' | ||
+ | |||
+ | La méthode simple est d' | ||
+ | |||
+ | Cliquez sur le bouton « Éditer » de votre réseau Host-only, c'est l' | ||
+ | |||
+ | Par défaut, vboxnet0 dispose d'un serveur DHCP configuré pour allouer dynamiquement les adresses IP pour chaque session. Je veux que mon serveur virtuel Wordpress conserve des adresses IP statiques, donc sur l' | ||
+ | |||
+ | |||
** | ** | ||
+ | Add Host-only Adapter to Guest | ||
+ | |||
I'll add another network adapter to my guest machine, a Host-Only Adapter, that enables a self-contained, | I'll add another network adapter to my guest machine, a Host-Only Adapter, that enables a self-contained, | ||
So on my Adapter 2 tab for my guest, I set the Attached to option to Host-only, and the name is the default vboxnet0. Promiscuous mode doesn' | So on my Adapter 2 tab for my guest, I set the Attached to option to Host-only, and the name is the default vboxnet0. Promiscuous mode doesn' | ||
+ | ** | ||
+ | |||
+ | Ajouter l' | ||
+ | |||
+ | Je vais ajouter une autre carte réseau à ma machine virtuelle, un adaptateur Host-Only, qui active un réseau privé virtuel, autonome, composé uniquement de mon hôte et des machines hébergées qui utilisent Host-Only. Toute les machines membres peuvent s' | ||
+ | |||
+ | Donc sur l' | ||
+ | ** | ||
Configure the Guest | Configure the Guest | ||
Ligne 155: | Ligne 270: | ||
ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up | ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up | ||
- | ** | ||
- | ** | ||
This sets the IP address on my host-only adapter for this guest, and brings up the network interface. It uses the 192 network prefix for domestic networks, followed by .168 for the start of the host ID, .56 as the host-only sub-net range, and I could use use any final identifier above .1 (my host) on my host-only network. The NAT adapter is sitting on eth0, so logically the Host-only adapter is bound to eth1. I can now secure shell (SSH) or browse to the guest from the host using this IP address as a test. | This sets the IP address on my host-only adapter for this guest, and brings up the network interface. It uses the 192 network prefix for domestic networks, followed by .168 for the start of the host ID, .56 as the host-only sub-net range, and I could use use any final identifier above .1 (my host) on my host-only network. The NAT adapter is sitting on eth0, so logically the Host-only adapter is bound to eth1. I can now secure shell (SSH) or browse to the guest from the host using this IP address as a test. | ||
However, this is just temporary; if I reboot, this configuration will disappear. To make it permanent, I need to add it to the / | However, this is just temporary; if I reboot, this configuration will disappear. To make it permanent, I need to add it to the / | ||
+ | ** | ||
+ | Configurer le serveur virtuel | ||
+ | |||
+ | J'ai besoin que mon serveur virtuel ait une adresse IP statique sur le réseau Host-only, sinon l' | ||
+ | |||
+ | ifconfig eth1 192.168.56.101 netmask 255.255.255.0 up | ||
+ | |||
+ | Ceci définit l' | ||
+ | Toutefois, ce n'est que temporaire ; si je redémarre, cette configuration disparaîtra. Pour la rendre permanente, je dois l' | ||
+ | |||
+ | |||
+ | ** | ||
# The host-only network interface | # The host-only network interface | ||
auto eth1 | auto eth1 | ||
Ligne 171: | Ligne 296: | ||
Once I reboot, this interface will be raised automatically. I can check that it's present using the ifconfig command in a terminal on the guest. | Once I reboot, this interface will be raised automatically. I can check that it's present using the ifconfig command in a terminal on the guest. | ||
** | ** | ||
+ | |||
+ | # L' | ||
+ | auto eth1 | ||
+ | iface eth1 inet static | ||
+ | address 192.168.56.101 | ||
+ | netmask 255.255.255.0 | ||
+ | network 192.168.56.0 | ||
+ | broadcast 192.168.56.255 | ||
+ | |||
+ | Une fois que j' | ||
** | ** | ||
Ligne 183: | Ligne 318: | ||
If I add more guests to the host-only network, I can do the same so that I can address any of them, from any of them, by name. | If I add more guests to the host-only network, I can do the same so that I can address any of them, from any of them, by name. | ||
** | ** | ||
+ | |||
+ | Désignation des partenaires | ||
+ | |||
+ | Comme je ne suis pas bon avec les chiffres et les adresses IP, je préfère utiliser le nom de la machine virtuelle plutôt que l' | ||
+ | |||
+ | Je modifie le fichier (en tant que root) en ajoutant la ligne : | ||
+ | |||
+ | 192.168.56.101 ocelotsvr | ||
+ | |||
+ | Si j' | ||
+ | |||
** | ** | ||
Ligne 195: | Ligne 341: | ||
I need two rules; one to access the Apache web-server on my guest, the other to handle all the other TCP traffic (http requests, mostly). | I need two rules; one to access the Apache web-server on my guest, the other to handle all the other TCP traffic (http requests, mostly). | ||
** | ** | ||
+ | |||
+ | Un Port dans la tempête ? | ||
+ | |||
+ | Les experts en réseaux auront repéré une autre route pour accéder à mon serveur virtuel. | ||
+ | |||
+ | Grâce à mon adaptateur NAT par défaut, je pourrais y faire une configuration supplémentaire pour me permettre d' | ||
+ | |||
+ | Je peux mettre en place la redirection de port dans VirtualBox, dans le panneau de paramétrage de l' | ||
+ | |||
+ | J'ai besoin de deux règles : l'une pour accéder au serveur web Apache de ma machine virtuelle, l' | ||
** | ** | ||
Ligne 201: | Ligne 357: | ||
This also means any other guests I wish to run can't access this virtual server, as no network route exists under NAT. | This also means any other guests I wish to run can't access this virtual server, as no network route exists under NAT. | ||
** | ** | ||
+ | |||
+ | Pour garder les choses simples, je vais les nommer Apache et TCP et les deux utilisent le protocole TCP. Si je respecte les numéros de port habituels, 8888 sur l' | ||
+ | |||
+ | Cela signifie également que quelque autre machine virtuelle que je lancerai ne pourra accéder à ce serveur virtuel, car aucune route réseau n' | ||
+ |
numero61/tuto_vbox_p._15-20.1343838904.txt.gz · Dernière modification : 2012/08/01 18:35 de frangi