Gestione configurazioni di rete notebook

From RVM Wiki
Revision as of 16:15, 1 October 2005 by Gabriele.vivinetto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

E' possibile far configurare le schede di rete di un notebook automaticamente tramite il pacchetto guessnet

Prima di eseguire le operazioni seguenti, staccare il cavo lan ed estrarre la scheda pcmcia dal socket

Installazione ifplugd

Il pacchetto ifplugd permette di "sentire" quando una scheda lan o wifi viene collegata ad una rete, e di conseguena può far eseguire delle azioni

sudo apt-get install ifplugd

Configurazione ifplugd

Supponendo di avere una scheda lan eth0 ed una wifi pcmcia ath0, le si assegna entrambi in gestione ad ifplugd.

etho è una scheda onboard, quindi gestita come interfaccia "normale", mentre ath0 è una scheda pcmcia, quindi gestita via demone hotplug:

sudoedit /etc/default/ifplugd
...
INTERFACES="eth0"
HOTPLUG_INTERFACES="ath0"
...

Riavviare ifplugd

/etc/init.d/ifplugd stop; /etc/init.d/ifplugd start


Configurazione della scheda lan

Supponiamo di partire con una configurazione singola della scheda lan in dhcp.

Il vantaggio di avere ifplugd è che ogni volta che si inserirà il cavo lan automaticamente si richiamerà dhclient.

Definiamo il profilo per la scheda lan:

sudoedit /etc/network/interface

#loopback interface, always present

auto lo
iface lo inet loopback

#definiamo l'interfaccia lan come dhcp
iface eth0 inet dhcp

Riavviamo il networking

sudo /etc/init.d/networking stop; sudo /etc/init.d/networking start


Verifica di ifplugd per la scheda Lan

Monitoriamo il syslog:

 sudo tail -f /var/log/syslog | cut --delim=" " -f 6-

Inseriamo il cavo di rete:

ifplugd(eth0)[9734]: Link beat detected.
kernel: e100: eth0: e100_watchdog: link up, 100Mbps, full-duplex
ifplugd(eth0)[9734]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
dhclient: Internet Systems Consortium DHCP Client V3.0.1
ifplugd(eth0)[9734]: client: Internet Systems Consortium DHCP Client V3.0.1
dhclient: Copyright 2004 Internet Systems Consortium.
ifplugd(eth0)[9734]: client: Copyright 2004 Internet Systems Consortium.
dhclient: All rights reserved.
ifplugd(eth0)[9734]: client: All rights reserved.
dhclient: For info, please visit http://www.isc.org/products/DHCP
ifplugd(eth0)[9734]: client: For info, please visit http://www.isc.org/products/DHCP
dhclient:
dhclient: Listening on LPF/eth0/00:08:02:68:3a:7c
ifplugd(eth0)[9734]: client: Listening on LPF/eth0/00:08:02:68:3a:7c
dhclient: Sending on   LPF/eth0/00:08:02:68:3a:7c
ifplugd(eth0)[9734]: client: Sending on   LPF/eth0/00:08:02:68:3a:7c
dhclient: Sending on   Socket/fallback
ifplugd(eth0)[9734]: client: Sending on   Socket/fallback
dhclient: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
ifplugd(eth0)[9734]: client: DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
dhclient: DHCPOFFER from 192.168.6.100
dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
ifplugd(eth0)[9734]: client: DHCPOFFER from 192.168.6.100
ifplugd(eth0)[9734]: client: DHCPREQUEST on eth0 to 255.255.255.255 port 67
dhclient: DHCPACK from 192.168.6.100
ifplugd(eth0)[9734]: client: DHCPACK from 192.168.6.100
dhclient: bound to 192.168.6.88 -- renewal in 37766 seconds.
ifplugd(eth0)[9734]: client: bound to 192.168.6.88 -- renewal in 37766 seconds.

Stacchiamo il cavo di rete, dopo alcuni secondi verrà rilasciato l'ip:

ifplugd(eth0)[9734]: Link beat lost.
kernel: e100: eth0: e100_watchdog: link down
ifplugd(eth0)[9734]: Executing '/etc/ifplugd/ifplugd.action eth0 down'.
dhclient: Internet Systems Consortium DHCP Client V3.0.1
ifplugd(eth0)[9734]: client: Internet Systems Consortium DHCP Client V3.0.1
dhclient: Copyright 2004 Internet Systems Consortium.
ifplugd(eth0)[9734]: client: Copyright 2004 Internet Systems Consortium.
dhclient: All rights reserved.
ifplugd(eth0)[9734]: client: All rights reserved.
dhclient: For info, please visit http://www.isc.org/products/DHCP
ifplugd(eth0)[9734]: client: For info, please visit http://www.isc.org/products/DHCP
dhclient:
dhclient: Listening on LPF/eth0/00:08:02:68:3a:7c
ifplugd(eth0)[9734]: client: Listening on LPF/eth0/00:08:02:68:3a:7c
dhclient: Sending on   LPF/eth0/00:08:02:68:3a:7c
ifplugd(eth0)[9734]: client: Sending on   LPF/eth0/00:08:02:68:3a:7c
dhclient: Sending on   Socket/fallback
ifplugd(eth0)[9734]: client: Sending on   Socket/fallback
dhclient: DHCPRELEASE on eth0 to 192.168.6.100 port 67
ifplugd(eth0)[9734]: client: DHCPRELEASE on eth0 to 192.168.6.100 port 67


Installazione di guessnet

Installiamo ora guessnet

sudo apt-get install guessnet

Configurazione dei profili di rete

Guessnet è utiliabile direttamente da ifupdown, cioè con delle semplici dichiarazioni in /etc/network/interfaces

In pratica si associa l'interfaccia fisica a delle interfacce virtuali a cui si assegnano delle configurazioni particolari.

Guessnet esegue dei test specifici ad esempio per vedere se riesce a pingare un host ed al primo successo sceglie la configurazione virtuale e la applica all'interfaccia fisica.

Se tutti i test falliscono è possibile scegliere un profilo di default, che noi decideremo essere dhcp.

Vediamo una configurazione di esempio.

Il profilo "lan-pub" viene selezionato se si riesce a pingare il gateway 192.168.6.254 con mac 00:50:04:74:15:AE, altrimenti si sceglie il profilo lan-dhcp

mapping eth0
        script guessnet-ifupdown
        map lan-pub
        map default: lan-dhcp
        map timeout: 5
        map verbose: true
        map debug:true

iface lan-pub inet static
        address 192.168.6.200
        netmask 255.255.255.0
        gateway 192.168.6.254
        dns-nameservers 194.20.8.1
        test peer address 192.168.6.254 mac 00:50:04:74:15:AE

iface lan-dhcp inet dhcp

Disinseriamo il cavo e restartiamo il networking ed ifplugd:

sudo /etc/init.d/networking stop; sudo /etc/init.d/networking start
sudo /etc/init.d/ifplugd stop; sudo /etc/init.d/ifplugd start

Monitoriamo il log ed inseriamo il cavo:

  sudo tail -f /var/log/syslog | cut --delim=" " -f 6-

Copntinua ....