Servizi di rete automatici al boot anche con IP dinamico senza usare Network Manager
<br />
<span style="font-weight: bold;"><font size="4">Automatizzare il boot della rete</font><br />
</span><br />
Il mio desiderio è quello di avere il desktop pronto senza usare Network Manager in quanto qust'ultimo risulta piuttosto invasivo.<span style="font-weight: bold;"><br />
</span>Ecco la modifica da fare allo script <span style="color: rgb(0, 0, 255);">/etc/rc.d/rc.local</span><br />
ATTENZIONE: fare un backup di tale script prima di modificarlo!<br />
<br />
Partiamo. Da terminale e da root digitiamo:<br />
<br />
<span style="color: rgb(255, 0, 0);">cd /etc/rc.d</span><br style="color: rgb(255, 0, 0);" />
<span style="color: rgb(255, 0, 0);">cp -a ./rc.local ./rc.local_originale</span><br />
<br />
Ora apriamo con un editor il file <span style="color: rgb(0, 0, 255);">/etc/rc.d/rc.local <span style="color: rgb(0, 0, 0);">e</span></span> copiamoci quello che troviamo qui di seguito:<br />
<br />
<span style="color: rgb(0, 0, 255);">#!/bin/sh</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">#</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># This script will be executed *after* all the other init scripts.</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># You can put your own initialization stuff in here if you don't</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># want to do the full Sys V style init stuff.</span><br style="color: rgb(0, 0, 255);" />
<br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">touch /var/lock/subsys/local</span><br style="color: rgb(0, 0, 255);" />
<br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">## PER FLUSHARE IPTABLES ##</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">iptables --flush</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">iptables --table nat --flush</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">iptables --delete-chain</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">iptables --table nat --delete-chain</span><br style="color: rgb(0, 0, 255);" />
<br style="color: rgb(0, 0, 255);" />
<br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># tirasu la rete</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">route del default</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">ifconfig eth0 up</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">ifconfig lo up</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">ifconfig eth0 192.168.1.33 netmask 255.255.255.0</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">route add default gw 192.168.1.1</span><br style="color: rgb(0, 0, 255);" />
<br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># ripristina resolv.con</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">cat /home/eugenio/.TIENI/resolv.conf > /etc/resolv.conf</span><br style="color: rgb(0, 0, 255);" />
<br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># ATTENZIONE: il file /etc/resolv.conf è una copia che ho messo in una cartella dal nome .TIENI</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># e ogni volta, al boot, viene ricopiato nel suo posto originale in caso di perdita nella sessione precedente.</span><br style="color: rgb(0, 0, 255);" />
<br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);"># FINE SCRIPT</span><br style="color: rgb(0, 0, 255);" />
<span style="color: rgb(0, 0, 255);">#=======================</span><br />
<br />
E' tutto.<br />
<br />
Eugenio