Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Simulazione LAN con Virtualbox [Risolto]
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano
View previous topic :: View next topic  
Author Message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Tue Jul 15, 2008 2:57 pm    Post subject: Simulazione LAN con Virtualbox [Risolto] Reply with quote

Ciao a tutti, spero che qualcuno riesca ad aiutarmi...
Non riesco a far figurare la mia macchina virtuale come una macchina della stessa sottorete dell'università.

Mi spiego meglio: la mia Gentoo Box acquisisce automaticamente l'indirizzo IP tramite dhcp dalla rete dell'università...alla macchina virtuale invece viene dato un indirizzo del tipo "10.0.2.x" e dalla mia gentoo box non riesco a contattarla...vorrei ivece che anche l'indirizzo della macchina virtuale venisse dato dall'access point dell'università...

Ho provato a seguire questa guida, ma sembra funzionare solo se il server dhcp è raggiungibile via cavo...avete qualche idea o esperienza in merito?

Grazie mille
_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)


Last edited by canduc17 on Thu Jul 17, 2008 1:07 pm; edited 2 times in total
Back to top
View user's profile Send private message
mack1
Guru
Guru


Joined: 18 Mar 2006
Posts: 315

PostPosted: Tue Jul 15, 2008 4:14 pm    Post subject: Reply with quote

Purtroppo, a meno che tu non abbia una scheda con chipset prism, la cosa al momento non è fattibile :evil: :

http://www.linuxfoundation.org/en/Net:Bridge#It_doesn.27t_work_with_my_Wireless_card.21

Code:

What can be bridged?
Linux bridging is very flexible; the LAN's can be either traditional Ethernet device's, or pseudo-devices such as PPP, VPN's or VLAN's. The only restrictions are that the devices:

-All devices share the same maximum packet size (MTU). The bridge doesn't fragment packets.
-Devices must look like Ethernet. i.e have 6 byte source and destination address.
-Support promiscuous operation. The bridge needs to be able to receive all network traffic, not just traffic destined for its own address.
-Allow source address spoofing. The bridge must be able to send data over network as if it came from another host.


Code:

It doesn't work with my Wireless card!
This is a known problem, and it is not caused by the bridge code. Many wireless cards don't allow spoofing of the source address. It is a firmware restriction with some chipsets.


Non ho il portatile sotto mano (fino a domani sera!!), quindi non posso testare la cosa, però ho trovato questo:

http://home.nyc.rr.com/computertaijutsu/vboxbridge.html#Wireless

Ciao
Back to top
View user's profile Send private message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Wed Jul 16, 2008 12:55 pm    Post subject: Reply with quote

Bene, questa opzione bocciata allora...

Un'altra idea che mi viene in mente sarebbe quella di dare un indirizzo fisso alla mia macchina (interfaccia di rete eth0) e un indirizzo della stessa rete alla macchina virtuale...Magari utilizzando la mia macchina come server dhcp per la macchina virtuale, se è possibile...In questo modo dovrebbero parlarsi come se fossero due macchine distinte...

Qualcuno saprebbe come fare o ha altre idee da proporre?
_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)
Back to top
View user's profile Send private message
skypjack
l33t
l33t


Joined: 05 Aug 2006
Posts: 884
Location: Italia - Firenze

PostPosted: Thu Jul 17, 2008 7:41 am    Post subject: Reply with quote

no, aspetta, io sulla mia macchina ho virtualbox e non ho nessun problema ad andare in rete con il sistema emulato. quest'ultimo e il sistema ospite sono sulla stessa sottorete, dove la macchina ospite fa il forwarding delle richieste dell'emulata verso la rete esterna. questa soluzione non ti va bene?
Back to top
View user's profile Send private message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Thu Jul 17, 2008 7:58 am    Post subject: Reply with quote

Questo ok, basta lasciare le impostazioni di default e funziona così anche a me...

Ma io voglio simulare una LAN in tutto e per tutto: ho bisogno di riuscire a pingare da macchina host a macchina guest o a farmi rispondere da apache della macchina web se faccio una richiesta dalla host.
Cioè se inserisco
Code:
http://ip-macchina-guest:80
nel browser dell'host, voglio vedere la pagina di default di apache della macchina virtuale.
O ancora, vorrei collegarmi in ssh tra le due macchine...

Tutto ciò non è possibile con la configurazione base...
_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)
Back to top
View user's profile Send private message
Scen
Retired Dev
Retired Dev


Joined: 29 Jul 2003
Posts: 2470
Location: Padova, Italy

PostPosted: Thu Jul 17, 2008 12:43 pm    Post subject: Reply with quote

Se, come ha segnalato mack1, la scheda ethernet del tuo sistema host è una "wireless", allora, se non ho capito male, non ti sarà possibile interfaccia la macchina guest con la LAN fisica (tramite interfaccia di rete di tipo "host" nel guest, e utilizzando un bridge wlan0 + tun/tap nell'host, mannaggia che gioco di parole).

Però mi hai messo la pulce nell'orecchio, appena ho un attimo voglio provarci anch'io con uno dei notebook aziendali che ho a disposizione :P
_________________
I was born in a deep forest/I wish I could live here all my life/I am made from stones and roots/My home, these woods and roads
All my life I loved this sound/Of the woods all around/Eagles flies where the winds blows free
Journey is my destiny
Back to top
View user's profile Send private message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Thu Jul 17, 2008 1:06 pm    Post subject: Reply with quote

Ho risolto!!! :D
Grazie a questa guida.
Riassumo i passaggi da eseguire ed i file di configurazione che ho utilizzato:
  1. Utilizzare questo /etc/conf.d/net:
    Code:
    dns_domain_lo="loacaldomain"

    config_eth0=( "null" )

    tuntap_vbox0="tap"

    config_vbox0=( "null")

    tunctl_vbox0=("-u canduc")

    config_br0=( "dhcp" )

    bridge_br0="eth0 vbox0"

    depend_br0()
    {
             need net.eth0
             need net.vbox0
    }

    brctl_br0=( "setfd 0")
    Probabilmente alcune impostazioni verranno sovrascritte in seguito, però ho lasciato cmq il file così, visto che funziona...
  2. Connettersi all'access point come si fa abitualmente ed assicurarsi che la macchina host navighi regolarmente in internet.
    Per la rete tra access point e macchina host ho:
    host ip: 10.14.198.71 netmask 255.0.0.0
  3. creare il bridge br0 e le tap necessarie con questo script:
    Code:
    #!/bin/sh

    # name of the vm user
    USER="canduc"

    #numero di tap da creare (una per ogni macchina virtuale)
    NUMBER_OF_VM=1

    #############################################

    # create the taps and insert them into the bridge

    NB=1
    for NB in `seq 1 $NUMBER_OF_VM`;
    do
       tunctl -t tap$NB -u $USER
       ip link set up dev tap$NB
       brctl addif br0 tap$NB
       echo "NB è" $NB
    done

    ifconfig br0 192.168.0.5 netmask 255.255.255.0 broadcast 192.168.0.255 up
  4. Dire a Gentoo che la connessione a internet sulla scheda di rete deve essere condivisa, basta utilizzare i seguenti comandi da utente root (il primo solo se si ha installato iptables):
    Code:
    iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
    sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
    Il mio ifconfig risponde:
    Code:
    candell canduc # ifconfig
    br0       Link encap:Ethernet  HWaddr 00:1D:09:B9:DF:44 
              inet addr:192.168.0.5  Bcast:192.168.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:81 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1150 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:22280 (21.7 Kb)  TX bytes:245818 (240.0 Kb)

    eth0      Link encap:Ethernet  HWaddr 00:1D:09:B9:DF:44 
              UP BROADCAST PROMISC MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)
              Interrupt:17

    lo        Link encap:Local Loopback 
              inet addr:127.0.0.1  Mask:255.0.0.0
              UP LOOPBACK RUNNING  MTU:16436  Metric:1
              RX packets:32 errors:0 dropped:0 overruns:0 frame:0
              TX packets:32 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:0
              RX bytes:2512 (2.4 Kb)  TX bytes:2512 (2.4 Kb)

    tap1      Link encap:Ethernet  HWaddr 00:FF:24:F2:6C:6B 
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:81 errors:0 dropped:0 overruns:0 frame:0
              TX packets:501 errors:0 dropped:427 overruns:0 carrier:0
              collisions:0 txqueuelen:500
              RX bytes:23414 (22.8 Kb)  TX bytes:105460 (102.9 Kb)

    vbox0     Link encap:Ethernet  HWaddr 00:FF:26:CD:60:3A 
              UP BROADCAST RUNNING PROMISC MULTICAST  MTU:1500  Metric:1
              RX packets:0 errors:0 dropped:0 overruns:0 frame:0
              TX packets:0 errors:0 dropped:1155 overruns:0 carrier:0
              collisions:0 txqueuelen:500
              RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

    wlan0     Link encap:Ethernet  HWaddr 00:1E:4C:78:1A:12 
              inet addr:10.14.198.71  Bcast:10.14.255.255  Mask:255.255.0.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:7034 errors:0 dropped:0 overruns:0 frame:0
              TX packets:1761 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:1930590 (1.8 Mb)  TX bytes:298909 (291.9 Kb)
              Interrupt:17 Memory:f9ffc000-fa000000
  5. Avvio la macchina virtuale (nel mio caso è una Fedora 9) ed imposto manualmente i parametri di rete come segue:
    indirizzo ip: 192.168.1.100 (o qualunque indirizzo compatibile con la rete dei tap in br0)
    netmask: 255.255.255.0
    gateway: 10.14.198.71 (cioè l'indirizzo della scheda wlan0 sulla macchina host)

Fine: ora la macchina virtuale vede la rete connessa al bridge anche se, non ho capito perchè, non è in grado di navigare su internet...

Ma per i miei scopi non mi interessa...

Ora ad esempio, se sulla fedora apro il firewall sulla porta 80, dalla macchina host riesco a contattarla con il browser e a vedere la pagina di presentazione del suo server apache!

Se avete suggerimenti per migliorare le mie impostazioni fatemi sapere!

Grazie a tutti!
_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)
Back to top
View user's profile Send private message
mack1
Guru
Guru


Joined: 18 Mar 2006
Posts: 315

PostPosted: Thu Jul 17, 2008 1:14 pm    Post subject: Reply with quote

Allora è possibile fare il bridging anche con una interfaccia wireless, basta usare parprouted e un dhcp relay, visto che parprouted funge solo con pacchetti unicast.
I sorgenti di parprouted si trovano qui:

http://www.hazard.maks.net/parprouted/

Ha come dipendenze iproute2 ed è :

Code:
parprouted is a daemon for transparent IP (Layer 3) proxy ARP bridging.
Unlike standard bridging, proxy ARP bridging allows to bridge Ethernet
networks behind wireless nodes. Normal L2 bridging does not work between
wireless nodes because wireless does not know about MAC addresses used
in the wired Ethernet networks. Also this daemon is useful
for making transparent firewalls.


Code:
 
The daemon listens for incoming ARP requests, and in case the location
of the requested IP address is unknown, forwards them to other interfaces,
as well as updates kernel ARP table with the received replies. When
necessary, the daemon generates an ARP reply itself, which causes the
stations to send traffic to the host daemon is running on. By
automatically adding appropriate /32 routes to Linux kernel IP routing
table for the hosts learned via ARP, daemon ensures that the Linux kernel
will be able to route the packets to the destination host when it receives
them without any need routing/subnetting manually


Assicurati che l'interfaccia wireless sia associata all' ap e che abbia un ip, prima di seguire le istruzioni.
Wlan0 è il dispositivo wireless e vbox0 è quello virtuale, la rete è 192.168.1.0 come esempio.

1-Abilitare l'ip forwarding:

Code:
echo 1 > /proc/sys/net/ipv4/ip_forward


2-Creare dispositivo di rete virtuale con i permessi corretti:

Code:
tunctl -t vbox0 -u nome_utente && chmod 666 /dev/net/tun


3-Settare vbox0 con ip (altrimenti non funziona):

Code:

ip link set vbox0 up
ip addr add 192.168.1.108/24 dev vbox0


4-Attivare parprouter (wlan0 è il dev wireless):

Code:
parprouted wlan0 vbox0


5-Aggiungere route per vbox0:

Code:
route add -net 192.168.1.0 netmask 255.255.255.0 vbox0


6-Settare ip statico del sistema guest con gateway e dns a mano oppure usare il dhcp, solo che parproute funzia solo con pacchetti unicast, però si può usare un dhcp relay per ovviare all'inconveniente:

Code:

In /etc/conf.d/dhcrelay

# List all interfaces space separated. If this is not specified then
# we use all interfaces.
IFACE="wlan0 vbox0"

# Space separated list of IPs to forward BOOTP/DHCP packets to.
DHCRELAY_SERVERS="192.168.1.1"


Avviare dhcp relay:

Code:
/etc/init.d/dhcrelay start


Ho usato virtualbox (in rete >> interfaccia host >>vbox0) e funzia bene 8) !!!

Ciao
Back to top
View user's profile Send private message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Thu Jul 17, 2008 1:27 pm    Post subject: Reply with quote

Grazie mille, mack1!
Anche se avevo già risolto così ho una soluzione in più!
_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)
Back to top
View user's profile Send private message
mack1
Guru
Guru


Joined: 18 Mar 2006
Posts: 315

PostPosted: Thu Jul 17, 2008 1:30 pm    Post subject: Reply with quote

De nada :D !!!
Posso solo sapere che soluzione hai trovato per fare il bridging con un dev wireless?

Ciao
Back to top
View user's profile Send private message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Thu Jul 17, 2008 1:35 pm    Post subject: Reply with quote

Beh, è tutto scritto sopra...
_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)
Back to top
View user's profile Send private message
mack1
Guru
Guru


Joined: 18 Mar 2006
Posts: 315

PostPosted: Thu Jul 17, 2008 1:38 pm    Post subject: Reply with quote

Azz... mentre postavo hai scritto la soluzione....
Back to top
View user's profile Send private message
fbcyborg
Advocate
Advocate


Joined: 16 Oct 2005
Posts: 3056
Location: ROMA

PostPosted: Mon Jul 21, 2008 6:16 pm    Post subject: Reply with quote

E pensare che ho avuto casini & casini anche io.
Non vedo l'ora di far funzionare il bridge da WLAN... quasi non ci credo! :D
_________________
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Back to top
View user's profile Send private message
canduc17
l33t
l33t


Joined: 11 Oct 2005
Posts: 795
Location: Ferrara, Italy

PostPosted: Mon Jul 21, 2008 9:09 pm    Post subject: Reply with quote

Ti consiglio di usare la soluzione di mack1 perchè la mia mi ha dato un po' di problemi.
La sua funziona alla grande!
_________________
A cow enters a supermarket, does an handstand and dies. (Public toilet graffito)
Back to top
View user's profile Send private message
fbcyborg
Advocate
Advocate


Joined: 16 Oct 2005
Posts: 3056
Location: ROMA

PostPosted: Mon Jul 21, 2008 9:13 pm    Post subject: Reply with quote

OK, grazie!!!
_________________
[HOWTO] Come criptare la /home usando cryptsetup e luks
[HOWTO] Abilitare il supporto al dom0 XEN su kernel 3.X
Help answer the unanswered
Back to top
View user's profile Send private message
mack1
Guru
Guru


Joined: 18 Mar 2006
Posts: 315

PostPosted: Mon Jul 21, 2008 9:41 pm    Post subject: Reply with quote

Occhio solo che sotto forte carico parprouted a volte salta e va riavviato a mano, ma per il resto funzia :D :D (ho installato gentoo su vbox proprio ieri).

@fbcyborg se devi mappare solo una porta tipo 22 o 80 puoi vedere anche una soluzione di questo tipo:

http://mydebian.blogdns.org/?p=148

Ciao
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Forum di discussione italiano All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum