[Risolto]configurazione client-server su virtualbox
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
Ubuntu server 17.04 installato senza DE.
Ho già provato a rifare quanto detto su "clone collegato" ma nada....
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
OK, do per scontato che hai impostato la VM con le due schede di rete così come ti ho spiegato in precedenza.
Iniziamo a configurarle. Sei capace di scrivere da solo il file /etc/network/interfaces ?
Se SI, fammi vedere cosa hai fatto
Codice: Seleziona tutto
cat /etc/network/interfaces
ifconfig
route -n
cat /etc/resolv.conf
- i nomi logici delle due schede di rete
- quale delle due è collegata al bridge e quale è collegata alla rete interna di VirtualBox
- gli indirizzi IP che vuoi utilizzare
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
Scusa il ritardo ma ho fatto un po' di ricerche in rete perché non sono riuscito ad installare correttamente le "guest additions" per copia/incolla da versione minimale di ubuntu (nel caso qualcuno con il mo stesso problema leggesse).
Per ovviare alle "guest additions" mi collego via ssh al VM-server. Banale ma se non lo sai.......
Allora, ho per ora editato in questo modo:
Codice: Seleziona tutto
root@server:~# nano /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.108
auto enp0s8
iface enp0s8 inet static
address 10.0.0.1
netmask 255.255.255.0
enp0s3 scheda in bridge che si collega all'esterno
enp0s8 scheda rivolta a lan interna
192.168.1.108 indirizzo scheda reale hypervisor
e con i comandi suggeritimi restituisce:
Codice: Seleziona tutto
root@server:~# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:fe25:4ac1 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:25:4a:c1 txqueuelen 1000 (Ethernet)
RX packets 857 bytes 78111 (78.1 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 401 bytes 56023 (56.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::a00:27ff:fe18:1a68 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:18:1a:68 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 24 bytes 1832 (1.8 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Loopback locale)
RX packets 22 bytes 1486 (1.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 22 bytes 1486 (1.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Codice: Seleziona tutto
root@server:~# route -n
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.108 0.0.0.0 UG 0 0 0 enp0s3
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s8
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3
Codice: Seleziona tutto
root@server:~# nano /etc/resolv.conf
nameserver 127.0.0.53
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
Io ti ho indicato quelli di OpenDNS
Codice: Seleziona tutto
dns-nameservers 208.67.222.222 208.67.220.220
Codice: Seleziona tutto
dns-nameservers 192.168.1.108 208.67.222.222 208.67.220.220
Codice: Seleziona tutto
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.108
dns-nameservers 208.67.222.222 208.67.220.220
auto enp0s8
iface enp0s8 inet static
address 10.0.0.1
netmask 255.255.255.0
Codice: Seleziona tutto
ping -c 4 192.168.1.108
ping -c 4 8.8.8.8
host google.it
ping -c 4 google.it
Nota importante: da un tuo vecchio post ho notato che hai indicato come router "reale" l'indirizzo IP 192.168.1.1. Quindi 192.168.1.8 che cos'è? L'indirizzo IP del tuo PC "fisico" ? Se è così, allora dove hai indicato 192.168.1.8 sostituisci con 192.168.1.1
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
192.168.1.108 è l'indirizzo della scheda del pc sul quale sto lavorando (dove ho installato tutto l'Ambaradan), attraverso la quale sono connesso ad un router tplink.
192.168.1.1 è l'indirizzo del router che mi connette ad internet.
Se non ho capito male...
Codice: Seleziona tutto
root@server:~# nano /etc/network/interfaces
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.108
dns-nameservers 192.168.1.108 208.67.222.222 208.67.220.220
auto enp0s8
iface enp0s8 inet static
address 10.0.0.1
netmask 255.255.255.0
Ma poi i miei sensi di toporagno mi hanno spinto a dare sul terminale del pc su cui lavoro (quello con scheda 192.168.1.108)
Codice: Seleziona tutto
~# echo 1 > /proc/sys/net/ipv4/ip_forward
E riprovando i ping
Codice: Seleziona tutto
~# ping -c 4 192.168.1.108
PING 192.168.1.108 (192.168.1.108) 56(84) bytes of data.
64 bytes from 192.168.1.108: icmp_seq=1 ttl=64 time=0.274 ms
64 bytes from 192.168.1.108: icmp_seq=2 ttl=64 time=0.492 ms
64 bytes from 192.168.1.108: icmp_seq=3 ttl=64 time=0.369 ms
64 bytes from 192.168.1.108: icmp_seq=4 ttl=64 time=0.444 ms
--- 192.168.1.108 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 0.274/0.394/0.492/0.085 ms
Codice: Seleziona tutto
~# ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=17.6 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=17.3 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=17.3 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=17.8 ms
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 17.343/17.541/17.817/0.226 ms
Codice: Seleziona tutto
~# host google.it
google.it has address 216.58.205.67
google.it has IPv6 address 2a00:1450:4002:807::2003
google.it mail is handled by 20 alt1.aspmx.l.google.com.
google.it mail is handled by 10 aspmx.l.google.com.
google.it mail is handled by 50 alt4.aspmx.l.google.com.
google.it mail is handled by 30 alt2.aspmx.l.google.com.
google.it mail is handled by 40 alt3.aspmx.l.google.com.
Codice: Seleziona tutto
~# ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=56 time=17.2 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=56 time=17.2 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=56 time=17.7 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=56 time=17.1 ms
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 17.100/17.315/17.704/0.265 ms
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
1) il tuo PC "fisico" sul quale è installato VirtualBox (192.168.1.108) non lo devi toccare. Per quello che stiamo facendo la sua configurazione di rete non va minimamente alterata.
2) sulla VM Server, nel file /etc(network/interfaces devi sostituire l'indirizzo IP 192.168.1.108 con l'indirizzo IP 192.168.1.1. Il gateway della tua LAN "fisica" è il tuo modem / router TP-Link (192.168.1.1). Il tuo PC "fisico" e la tua VM Server affacciandosi sulla stessa LAN (192.168.1.0/24) devono avere lo stesso gateway (192.168.1.1). Quindi
Codice: Seleziona tutto
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 208.67.222.222 208.67.220.220
auto enp0s8
iface enp0s8 inet static
address 10.0.0.1
netmask 255.255.255.0
Codice: Seleziona tutto
ifconfig
route -n
cat /etc/resolv.conf
Con questo controlliamo la raggiungibilità del gateway di LAN
Codice: Seleziona tutto
ping -c 4 192.168.1.1
Codice: Seleziona tutto
ping -c 4 8.8.8.8
Codice: Seleziona tutto
host google.it
Codice: Seleziona tutto
ping -c 4 google.it
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
Ho rimesso a posto sostituendo il gateway e il dns come da te spiegato. (senza maneggi sul PC"fisico")
Ecco i risultati
Codice: Seleziona tutto
~$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.100 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::a00:27ff:fe25:4ac1 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:25:4a:c1 txqueuelen 1000 (Ethernet)
RX packets 79 bytes 14699 (14.6 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 92 bytes 11298 (11.2 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.1 netmask 255.255.255.0 broadcast 10.0.0.255
inet6 fe80::a00:27ff:fe18:1a68 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:18:1a:68 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 19 bytes 1482 (1.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Loopback locale)
RX packets 22 bytes 1486 (1.4 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 22 bytes 1486 (1.4 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Codice: Seleziona tutto
pao@server:~$ route -n
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 enp0s3
10.0.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s8
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3
Codice: Seleziona tutto
~$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 192.168.1.1
nameserver 208.67.222.222
nameserver 208.67.220.220
Codice: Seleziona tutto
~$ ping -c 4 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=254 time=0.617 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=254 time=0.364 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=254 time=0.667 ms
64 bytes from 192.168.1.1: icmp_seq=4 ttl=254 time=0.682 ms
--- 192.168.1.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 0.364/0.582/0.682/0.130 ms
Codice: Seleziona tutto
~$ ping -c 4 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=57 time=8.93 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=57 time=8.94 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=57 time=9.16 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=57 time=43.7 ms
--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 8.935/17.702/43.765/15.047 ms
Codice: Seleziona tutto
~$ host google.it
google.it has address 216.58.205.67
google.it has IPv6 address 2a00:1450:4002:806::2003
google.it mail is handled by 50 alt4.aspmx.l.google.com.
google.it mail is handled by 40 alt3.aspmx.l.google.com.
google.it mail is handled by 10 aspmx.l.google.com.
google.it mail is handled by 30 alt2.aspmx.l.google.com.
google.it mail is handled by 20 alt1.aspmx.l.google.com.
Codice: Seleziona tutto
~$ ping -c 4 google.it
PING google.it (216.58.205.67) 56(84) bytes of data.
64 bytes from mil04s25-in-f67.1e100.net (216.58.205.67): icmp_seq=1 ttl=53 time=18.1 ms
64 bytes from mil04s25-in-f67.1e100.net (216.58.205.67): icmp_seq=2 ttl=53 time=21.3 ms
64 bytes from mil04s25-in-f67.1e100.net (216.58.205.67): icmp_seq=3 ttl=53 time=45.4 ms
64 bytes from mil04s25-in-f67.1e100.net (216.58.205.67): icmp_seq=4 ttl=53 time=17.9 ms
--- google.it ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 17.934/25.731/45.465/11.475 ms
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
Ma de che? E' giusto provarci. Nessuno nasce "imparato".
Perfetto.
Passo successivo: abilitare sulla VM Server l'inoltro dei pacchetti IP e il masquerading dei pacchetti IP.
Ti senti confidente? Ci provi da solo e mi fai vedere poi cosa hai fatto?
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
ho modificato (tolto #) in /etc/sysctl.conf
Codice: Seleziona tutto
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
Codice: Seleziona tutto
~# iptables -F
~# iptables -t nat -A POSTROUTING -s 10.0.0.0/24 ! -d 10.0.0.0/24 -j SNAT --to-source 192.168.1.100
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
Bravo! Mi fai vedere che effettivamente questa modifica è stata recepita dalla tua VM Server?james bong [url=https://forum.ubuntu-it.org/viewtopic.php?p=4993811#p4993811][img]https://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto: Ok, allora
ho modificato (tolto #) in /etc/sysctl.confCodice: Seleziona tutto
# Uncomment the next line to enable packet forwarding for IPv4 net.ipv4.ip_forward=1
Codice: Seleziona tutto
cat /proc/sys/net/ipv4/ip_forward
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
Codice: Seleziona tutto
~# cat /proc/sys/net/ipv4/ip_forward
1
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
Mettiamo a posto l'ultimo punto: la configurazione di IPTables.
Dunque, quello che hai fatto è sostanzialmente corretto, ma ha carattere "temporaneo", nel senso che se provi a riavviare la VM Server (prova ... ) la configurazione attuale di IPTables la perdi e torna alle condizioni di default. Dobbiamo quindi rendere la configurazione attuale di IPTables "persistente".
In realtà non c'è un modo "più" corrretto per farlo, io utilizzo il seguente:
- creo una directory /scripts , nella quale in realtà raccolgo tutti i miei scripts che utilizzo / richiamo sul PC
- all'interno della directory /scripts creo uno script per l'impostazione di IPTables
- richiamo lo script dal file /etc/rc.local, che in realtà è uno script anch'esso che viene richiamato automaticamente ad ogni riavvio del PC
Dalle chiacchere ai fatti
Codice: Seleziona tutto
sudo mkdir /scripts
sudo touch /scripts/iptablesSetRules.sh
sudo chmod 744 /scripts/iptablesSetRules.sh
Codice: Seleziona tutto
#!/bin/bash
IPTABLES="/sbin/iptables"
$IPTABLES -t nat -A POSTROUTING -s 10.0.0.0/24 ! -d 10.0.0.0/24 -j SNAT --to-source 192.168.1.100
exit 0
Codice: Seleziona tutto
...
/scripts/iptablesSetRules.sh
exit 0
NOTA:
lo script per IPTables lo puoi scrivere anche in questo modo
Codice: Seleziona tutto
#!/bin/bash
IPTABLES="/sbin/iptables"
$IPTABLES -t nat -A POSTROUTING -s 10.0.0.0/24 ! -d 10.0.0.0/24 -j MASQUERADE
exit 0
Questa versione è meno "performate" ma può essere utilizzata nel caso in cui l'indirizzo IP assegnato alla scheda di rete (192.168.1.100) è dinamico.
La precedente versione invece può essere usata solamente nel caso in l'indirizzo IP assegnato alla scheda di rete (192.168.1.100) è statico.
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
troppo generoso......
ho fatto ciò che dici, ma purtroppo non funzia.
Ho trovato vuoto /etc/rc.local e l'ho compilato in questo modo
Codice: Seleziona tutto
nano /etc/rc.local
#!/bin/bash
/scripts/iptablesSetRules.sh
exit 0
Un problema analogo mi era capito per far partire un script al boot.
Mi ricordo che avevo risolto creando un servizio apposito per rc.local, ma non mi ricordo bene...
Intanto spulcio un po'
Ho dato
Codice: Seleziona tutto
chmod +x /etc/rc.local
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
Codice: Seleziona tutto
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
Codice: Seleziona tutto
-rwxr-xr-x 1 root root 345 Jun 1 01:14 /etc/rc.local
PS:
Le cose che ti ho indicato / suggerito le ho usate n-mila volte. E' piuttosto difficile che non funzioninojames bong [url=https://forum.ubuntu-it.org/viewtopic.php?p=4994013#p4994013][img]https://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:Ciao thece,
... ho fatto ciò che dici, ma purtroppo non funzia ...
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
Mi fido ciecamente di te, basta guardare l'avatar .
Dici che è il caso di riordinare tutti i passaggi in un unico post?
- thece
- Tenace Tecnocrate
- Messaggi: 12943
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: configurazione client-server su virtualbox
A te la scelta e l'onere.james bong [url=https://forum.ubuntu-it.org/viewtopic.php?p=4994027#p4994027][img]https://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto: Dici che è il caso di riordinare tutti i passaggi in un unico post?
Direi che puoi modificare il titolo del tuo primo post e mettere un bel [Risolto]
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: configurazione client-server su virtualbox
alla prox.
-
- Prode Principiante
- Messaggi: 97
- Iscrizione: martedì 10 marzo 2009, 19:57
- Distribuzione: "fluttuante"
Re: [Risolto]configurazione client-server su virtualbox
configurare le VM dalla GUI di Virtualbox
VM-server: 1° scheda rete in bridge, 2°schede rete interna
VM-client: scheda rete interna
-su VM-server:
imposto le schede di rete
Codice: Seleziona tutto
nano /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1 208.67.222.222 208.67.220.220
auto enp0s8
iface enp0s8 inet static
address 10.0.0.1
netmask 255.255.255.0
enp0s3 scheda in bridge che si collega all'esterno
enp0s8 scheda rivolta a lan interna
192.168.1.1 indirizzo modem/router "fisico"
riavvio e verifico se funziona con
Codice: Seleziona tutto
ping -c 4 192.168.1.101
ping -c 4 8.8.8.8
host google.it
ping -c 4 google.it
abilitare permanentemente sulla VM Server l'inoltro dei pacchetti IP
togliere # in /etc/sysctl.conf alla seconda riga mostrata sotto
Codice: Seleziona tutto
# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
Codice: Seleziona tutto
sudo mkdir /scripts
sudo touch /scripts/iptablesSetRules.sh
sudo chmod 744 /scripts/iptablesSetRules.sh
Codice: Seleziona tutto
#!/bin/bash
IPTABLES="/sbin/iptables"
$IPTABLES -t nat -A POSTROUTING -s 10.0.0.0/24 ! -d 10.0.0.0/24 -j SNAT --to-source 192.168.1.100
#nel caso l'indirizzo IP assegnato alla scheda di rete (192.168.1.100) sia dinamico commentare la riga precedente e
#togliere il commento da quella sottostante
#$IPTABLES -t nat -A POSTROUTING -s 10.0.0.0/24 ! -d 10.0.0.0/24 -j MASQUERADE
exit 0
Codice: Seleziona tutto
#!/bin/sh -e
/scripts/iptablesSetRules.sh
exit 0
Codice: Seleziona tutto
-rwxr-xr-x 1 root root 345 Jun 1 01:14 /etc/rc.local
Codice: Seleziona tutto
chmod +x /etc/rc.local
imposto le schede di rete
Codice: Seleziona tutto
nano /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet static
address 10.0.0.2
netmask 255.255.255.0
gateway 10.0.0.1
dns-nameservers 192.168.1.1 208.67.222.222 208.67.220.220
Codice: Seleziona tutto
sudo /etc/init.d/networking restart
Chi c’è in linea
Visualizzano questa sezione: 0 utenti iscritti e 3 ospiti