router con ubuntu
-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
router con ubuntu
è la prima volta che scrivo sul forum ma ho un problema sul routing con ubuntu a cui non riesco a trovare soluzione.
Mi spiego meglio, in seguito ad un distacco di corrente il mio computer, che faceva anche da router tra l'ADSL e la rete interna, si è incasinato le configurazioni, dopo molto smanettare ho deciso per un format della macchina, e qui sono nati tutti i miei problemi.
Dopo avere seguito molte guide ed aver reinstallato il sistema almeno tre volte non sono ancora riuscito a far rifunzionare il routing tra le due schede eth0 eth1 di conseguenza a condividere internet con la rete interna.
Vi descrivo adesso la procedura da me eseguita per ricreare il sistema:
- installato il sistema ubuntu desktop 14.04
- configurazione delle interfacce eth0 in dhcp ip 10.0.2.2 gateway 10.0.2.1 subnet 10.0.2.0/24 interfaccia eth1 statico ip192.168.80.100 gateway 192.168.80.100 subbnet 192.168.0./24
- installato dhcp sull'interfaccia eth1
- abilitato ip-forwarding, abilitato anche il loop back
- creato le regole di iptables
se da la macchina ubuntu faccio il ping del router ADSL mi pinga dall'interfaccia eth0 se faccio il ping di google 8.8.8.8 fa il ping da eth1 e risponde come host non raggiungibile.
se faccio il tracert da una macchina della rete arriva ad eth1 e si ferma.
non riesco a trovare una soluzione vi ringrazio se qualcuno può aiutarmi
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
posta l'output dei comandi
Codice: Seleziona tutto
ifconfigCodice: Seleziona tutto
route -n-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Hai usato il Network Manager?Raffaele974 [url=http://forum.ubuntu-it.org/viewtopic.php?p=4826925#p4826925][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:le interfaccie non sono state editate da file
-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
eth0 viene configurata automatica con ip 10.0.2.2netmask 255.255.255.0 gateway 10.0.2.1 dns 10.0.2.1
ho provato anche editando /etc/interfaces ma il risultato non cambia ho provato a dare ad eth1 come gateway 10.0.2.1 stesso risultato
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Il gateway per l'interfaccia di rete eth1 dovrebbe essere lo stesso di quello dell'interfaccia eth0, ottenuto in automatico dal server DHCP. Ma se posti l'output dei comandi è meglio
-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
ping 10.0.2.1
mi da ping from 10.0.2.1
ping 8.8.8.8
mi dà ping from 192.168.80.100
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Codice: Seleziona tutto
auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0
auto eth0
iface eth0 inet static
address 10.0.2.2
netmask 255.255.255.0
network 10.0.2.0
broadcast 10.0.2.255
gateway 10.0.2.1
dns-nameservers 10.0.2.1
auto eth1
iface eth1 inet static
address 192.168.80.100
netmask 255.255.255.0
network 192.168.80.0
broadcast 192.168.80.255
Codice: Seleziona tutto
cat /proc/sys/net/ipv4/ip_forwardCodice: Seleziona tutto
sudo iptables-saveCodice: Seleziona tutto
sudo iptables -t nat -A POSTROUTING -s 192.168.80.0/24 ! -d 192.168.80.0/24 -j MASQUERADE-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
Codice: Seleziona tutto
ifconfig
eth0 Link encap:Ethernet IndirizzoHW 00:01:02:9d:de:0f
UP BROADCAST 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
collisioni:0 txqueuelen:1000
Byte RX:0 (0.0 B) Byte TX:0 (0.0 B)
Interrupt:17
eth1 Link encap:Ethernet IndirizzoHW 00:1f:c6:e3:83:2f
indirizzo inet:192.168.80.100 Bcast:192.168.80.255 Maschera:255.255.255.0
indirizzo inet6: fe80::21f:c6ff:fee3:832f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16887 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:203 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:1164984 (1.1 MB) Byte TX:0 (0.0 B)
eth2 Link encap:Ethernet IndirizzoHW 00:1f:c6:e7:ff:71
indirizzo inet:10.0.0.2 Bcast:10.0.0.255 Maschera:255.255.255.0
indirizzo inet6: fe80::21f:c6ff:fee7:ff71/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4636 errors:0 dropped:0 overruns:0 frame:0
TX packets:4285 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:4624580 (4.6 MB) Byte TX:519639 (519.6 KB)
lo Link encap:Loopback locale
indirizzo inet:127.0.0.1 Maschera:255.0.0.0
indirizzo inet6: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1001 errors:0 dropped:0 overruns:0 frame:0
TX packets:1001 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:0
Byte RX:103954 (103.9 KB) Byte TX:103954 (103.9 KB)Codice: Seleziona tutto
route -n
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.80.100 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth2
192.168.80.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
Codice: Seleziona tutto
ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.80.100 icmp_seq=1 Destination Host Unreachable
From 192.168.80.100 icmp_seq=2 Destination Host Unreachable
From 192.168.80.100 icmp_seq=3 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
6 packets transmitted, 0 received, +3 errors, 100% packet loss, time 5018ms
pipe 3Codice: Seleziona tutto
ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.435 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.404 ms
64 bytes from 10.0.0.1: icmp_seq=3 ttl=64 time=0.361 ms
^C
--- 10.0.0.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.361/0.400/0.435/0.030 ms/-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
Codice: Seleziona tutto
route -n
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth2
10.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth1
192.168.80.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1Codice: Seleziona tutto
ping 10.0.0.1
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data.
From 192.168.80.100 icmp_seq=1 Destination Host Unreachable
From 192.168.80.100 icmp_seq=2 Destination Host Unreachable
^C
--- 10.0.0.1 ping statistics ---
5 packets transmitted, 0 received, +2 errors, 100% packet loss, time 3999ms
pipe 2Codice: Seleziona tutto
ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 192.168.80.100 icmp_seq=1 Destination Host Unreachable
From 192.168.80.100 icmp_seq=2 Destination Host Unreachable
From 192.168.80.100 icmp_seq=3 Destination Host Unreachable
From 192.168.80.100 icmp_seq=4 Destination Host Unreachable
^C
--- 8.8.8.8 ping statistics ---
5 packets transmitted, 0 received, +4 errors, 100% packet loss, time 3999ms
pipe 4
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Codice: Seleziona tutto
OUTPUT Le interfacce di rete sono diventate tre? eth0 (non configurata), eth1, eth2 (configurate)
Qual'è l'interfaccia di rete collegata al router ADSL, ossia a Internet?
Nel mio esempio di configurazione ho supposto che fosse l'interfaccia eth0 di indirizzo IP 10.0.2.2, visto che tu hai indicato come gateway l'indirizzo IP 10.0.2.1
-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
Codice: Seleziona tutto
ifconfig
eth0 Link encap:Ethernet IndirizzoHW 00:01:02:9d:de:0f
UP BROADCAST 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
collisioni:0 txqueuelen:1000
Byte RX:0 (0.0 B) Byte TX:0 (0.0 B)
Interrupt:17
eth1 Link encap:Ethernet IndirizzoHW 00:1f:c6:e3:83:2f
indirizzo inet:192.168.80.100 Bcast:192.168.80.255 Maschera:255.255.255.0
indirizzo inet6: fe80::21f:c6ff:fee3:832f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16887 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:203 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:1164984 (1.1 MB) Byte TX:0 (0.0 B)
eth2 Link encap:Ethernet IndirizzoHW 00:1f:c6:e7:ff:71
indirizzo inet:10.0.0.2 Bcast:10.0.0.255 Maschera:255.255.255.0
indirizzo inet6: fe80::21f:c6ff:fee7:ff71/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4636 errors:0 dropped:0 overruns:0 frame:0
TX packets:4285 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:4624580 (4.6 MB) Byte TX:519639 (519.6 KB)
lo Link encap:Loopback locale
indirizzo inet:127.0.0.1 Maschera:255.0.0.0
indirizzo inet6: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1001 errors:0 dropped:0 overruns:0 frame:0
TX packets:1001 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:0
Byte RX:103954 (103.9 KB) Byte TX:103954 (103.9 KB)
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Per essere corretta, in accordo con l'output del comando ifconfig e lo schema della tua LAN, dovrebbe essere qualcosa del genere
Codice: Seleziona tutto
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth2
10.0.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth2
192.168.80.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1
-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
Codice: Seleziona tutto
sudo route add 0.0.0.0 dev eth2
sudo route del 0.0.0.0 dev eth1
sudo route del 255.255.255.255 dev eth1- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Questo dipende da qual'è la tabella di routing di partenza (che non mi hai postato)Raffaele974 [url=http://forum.ubuntu-it.org/viewtopic.php?p=4827090#p4827090][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto: quindi in teoria lanciando i comandi route risolvoCodice: Seleziona tutto
sudo route add 0.0.0.0 dev eth2 sudo route del 0.0.0.0 dev eth1 sudo route del 255.255.255.255 dev eth1
oppure la configurazione delle due schede di rete nel Network Manager. E' uguale, basta fare le cose per beneRaffaele974 [url=http://forum.ubuntu-it.org/viewtopic.php?p=4827090#p4827090][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto: poi però per renderli stabili devo editare il file /etc/interfaces
Non serve fare 100 cose insieme, procedi un passo alla volta:
1) inizialmente configura solo una scheda di rete. La scheda di rete eth2, quella che ti mette a disposizione il collegamento verso Internet, e verifica che tutto sia corretto
2) aggiungi la configurazione della seconda scheda di rete, eth1, e verifica che tutto sia corretto
3) ... e via così
-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
La cosa strana che non capisco è eth1 con il bridge funziona mentre con il routing non fuziona!!!
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Visto che non hai postato i passi che hai seguito, solo tu sai che cosa hai fatto e che risultati hai ottenuto ... sfere di cristallo nel Forum non pervenute!Raffaele974 [url=http://forum.ubuntu-it.org/viewtopic.php?p=4827210#p4827210][img]http://forum.ubuntu-it.org/images/icons/icona-cita.gif[/img][/url] ha scritto:problema risolto connettendo le schede eth0 ed eth2.
La cosa strana che non capisco è eth1 con il bridge funziona mentre con il routing non fuziona!!!
Comunque, bene che hai risolto
- thece
- Tenace Tecnocrate

- Messaggi: 13174
- Iscrizione: lunedì 23 aprile 2007, 14:16
- Distribuzione: Debian 12 (Bookworm) - KDE
Re: router con ubuntu
Il "routing" e il "bridge" tra due interfacce di rete realizzanno due funzioni diverse.
Nel "routing" le due interfacce di rete, supponiamo eth0 e eth1, sono due entità logiche distinte. Entrambe hanno un proprio indirizzo IP su due diverse subnet, supponiamo 192.168.1.100 e 192.168.2.200. La funzionalità di "routing" unisce le due diverse subnet 192.168.1.0/24 e 192.168.2.0/24
Codice: Seleziona tutto
"Routing"
192.168.1.0/24 192.168.2.0/24
<----------------> eth0 eth1 <---------------->
.100 .200
Codice: Seleziona tutto
"Bridge"
192.168.1.0/24 192.168.1.0/24
<----------------> eth0 br0 eth1 <---------------->
.100
-
Raffaele974
- Prode Principiante
- Messaggi: 12
- Iscrizione: giovedì 26 novembre 2015, 9:57
- Distribuzione: ubuntu 14.04
- Sesso: Maschile
Re: router con ubuntu
hai perfettamente ragione quindi posto tutto ciò che ho fatto:thece ha scritto:Visto che non hai postato i passi che hai seguito, solo tu sai che cosa hai fatto e che risultati hai ottenuto ... sfere di cristallo nel Forum non pervenute!
Comunque, bene che hai risolto
- installato ubuntu 14.04 LTS con una sola interfaccia di rete colegata alla ADSL
- al riavvio collego lo switch di rete (LAN) ad un'altra interfaccia ed imposto tramite network manager eth1 con ip 192.168.80.100 netmask 255.255.255.0 gateway 10.0.0.2 dns 8.8.8.8
- abilitato ip-forwarding
- lancio il comando ifconfig per verificare le configurazioni
Codice: Seleziona tutto
ifconfig
eth0 Link encap:Ethernet IndirizzoHW 00:01:02:9d:de:0f
UP BROADCAST 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
collisioni:0 txqueuelen:1000
Byte RX:0 (0.0 B) Byte TX:0 (0.0 B)
Interrupt:17
eth1 Link encap:Ethernet IndirizzoHW 00:1f:c6:e3:83:2f
indirizzo inet:192.168.80.100 Bcast:192.168.80.255 Maschera:255.255.255.0
indirizzo inet6: fe80::21f:c6ff:fee3:832f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:16887 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:203 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:1164984 (1.1 MB) Byte TX:0 (0.0 B)
eth2 Link encap:Ethernet IndirizzoHW 00:1f:c6:e7:ff:71
indirizzo inet:10.0.0.2 Bcast:10.0.0.255 Maschera:255.255.255.0
indirizzo inet6: fe80::21f:c6ff:fee7:ff71/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4636 errors:0 dropped:0 overruns:0 frame:0
TX packets:4285 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:1000
Byte RX:4624580 (4.6 MB) Byte TX:519639 (519.6 KB)
lo Link encap:Loopback locale
indirizzo inet:127.0.0.1 Maschera:255.0.0.0
indirizzo inet6: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:1001 errors:0 dropped:0 overruns:0 frame:0
TX packets:1001 errors:0 dropped:0 overruns:0 carrier:0
collisioni:0 txqueuelen:0
Byte RX:103954 (103.9 KB) Byte TX:103954 (103.9 KB)Codice: Seleziona tutto
route -n
Tabella di routing IP del kernel
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth1
10.0.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth2
10.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 0 eth1
192.168.80.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1dopo che mi hai postato la tabella di routing come avrebbe dovuto essere ho modificato il gateway di eth1 a 10.0.0.1 ed ho iniziato a provare a modificare le route tramite i comandi route add e route del.
Non riuscendo ad ottenere risultati ho disconnesso i cavi di rete spento il computer collegato il cavo proveniente dalla ADSL ad eth0 e riacceso il computer.
tramite network manager ho impostato eth0 con ip statico 10.0.0.2 netmask 255.255.255.0 gateway 10.0.0.1 e riavviato il computer.
ho collegato il cavo proveniente dallo switch ad eth2 ho aperto il network manager impostando staticamente eth2 con ip 192.168.1.100 netmask 255.255.255.0 ed il gateway 10.0.0.1 ad entrambi gli eth ho imostato i dns 8.8.8.8
lanciato il comando route -n veniva fuori la seguente tabella
Codice: Seleziona tutto
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 10.0.0.1 0.0.0.0 UG 0 0 0 eth2
10.0.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth2
192.168.80.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0a questo punto ho lanciato il comando
sudo apt-get install isc-dhcp-server
ho editato il file /etc/dhcp/dhcpd.conf con il comando sudo gedit /etc/dhcp/dhcpd.conf
ho eidtato il file /etc/default/isc-dhcp-server con il comando sudo gedit /etc/default/isc-dhcp-server nella sezione interfaces ho inserito eth2
ed adesso sudo service isc-dhcp-server stop e service isc-dhcp-server start
da qualsiasi dispositivo connesso allo switch in dhcp automaticamente si connetteva ad ubuntu e poteva navigare su internet
perciò ho dedotto che il problema sta sulla eth1 o sulle impostazioni dhcp dell'ADSL in questi giorni farò delle prove e posto i risultati
Chi c’è in linea
Visualizzano questa sezione: 0 utenti iscritti e 5 ospiti