Installazione di un servizio DHCP ridondante: Difference between revisions
Jump to navigation
Jump to search
m New page: {{Stub}} *[http://www.randombugs.com/linux/linux-isc-dhcp-server-failover-debian-ubuntu.html Linux ISC DHCP Server failover under Debian and Ubuntu | Random Bugs] *[http://canonical.wordp... |
mNo edit summary |
||
| Line 1: | Line 1: | ||
=Configurazione Master= | |||
* Occorre che la configurazione di partenza conetnga un pool, e che la configurazione base sia contenuta in un file a parte. Eventuali dichiarazioni di host statici vanno incluse in un file a parte. | |||
* Configurazione base: | |||
sudoedit /etc/dhcp/dhcpd.conf | |||
<pre> | |||
# /etc/dhcp/dhcp.conf MASTER | |||
# vim: set syntax=dhcpd.conf : | |||
ddns-update-style none; | |||
deny unknown-clients; | |||
authoritative; | |||
# FAILOVER SETTINGS | |||
failover peer "dhcp-failover" { | |||
primary; # declare this to be the primary server | |||
address 192.168.6.100; | |||
port 647; | |||
peer address 192.168.6.101; | |||
peer port 647; | |||
max-response-delay 30; | |||
max-unacked-updates 10; | |||
load balance max seconds 3; | |||
mclt 1800; | |||
split 128; | |||
} | |||
subnet 192.168.6.0 netmask 255.255.255.0 { | |||
option domain-name "example.com"; | |||
option domain-name-servers 192.168.6.100, 192.168.6.101; | |||
option routers 192.168.6.254; | |||
pool { | |||
range 192.168.6.51 192.168.6.61; | |||
next-server 192.168.6.100; | |||
default-lease-time 600; | |||
max-lease-time 7200; | |||
log-facility local7; | |||
server-name pubserver; | |||
filename = "pxelinux.0"; | |||
# FAILOVER SETTINGS | |||
failover peer "dhcp-failover"; | |||
} | |||
} | |||
include "/etc/dhcp/dhcpd.conf.hosts"; | |||
</pre> | |||
* Questo è il file con gli ip assegnati ai mac: | |||
sudoedit /etc/dhcp/dhcpd.conf.hosts | |||
<pre> | |||
# /etc/dhcp/dhcpd.conf.hosts | |||
# vim: set syntax=dhcpd.conf : | |||
host client011 { | |||
# Client011 | |||
hardware ethernet 00:0F:FE:20:59:4F; | |||
fixed-address 192.168.6.11; | |||
} | |||
host client012 { | |||
# Client012 | |||
hardware ethernet 00:21:5a:20:81:76; | |||
fixed-address 192.168.6.12; | |||
} | |||
#..... | |||
</pre> | |||
* Riavviare il server dhcp master, e verificare che nonc i siano errori: | |||
sudo invoke-rc.d isc-dhcp-server restart | |||
=Configurazione server Slave= | |||
* Copiare la stessa configurazione del master, ma cambiare: | |||
sudoedit /etc/dhcp/dhcpd.conf | |||
<pre> | |||
# /etc/dhcp/dhcp.conf SLAVE | |||
#... | |||
secondary; # declare this to be the secondary server | |||
address 192.168.6.101; | |||
#... | |||
peer address 192.168.6.100; | |||
#... | |||
#mclt 1800; | |||
#split 128; | |||
#... | |||
option domain-name-servers 192.168.6.101, 192.168.6.100; | |||
#... | |||
</pre> | |||
* notare, che se si hanno i server dns master e slave, si possono invertire sul dhcp server secondario. | |||
* Copiare anche il file con gli ip assegnati ai mac | |||
/etc/dhcp/dhcpd.conf.hosts | |||
* Avviare e verificare che non ci siano errori | |||
sudo invoke-rc.d isc-dhcp-server restart | |||
* Provare ora a stoppare il master ed a rinnovare un ip. | |||
=Sincronizzazione modifiche assegnazioni IP= | |||
* Se si effettuano modifiche sui mac, è possibile aggiornare il file anche sullo slave. Allo scopo si usa lsyncd | |||
* Installarlo | |||
sudo apt-get install lsyncd | |||
* Creare il file di init.d | |||
sudo wget http://lsyncd.googlecode.com/svn-history/r73/package/debian/init.d -O /etc/init.d/lsyncd | |||
sudo chmod +x /etc/init.d/lsyncd | |||
sudo update-rc.d lsyncd defaults | |||
* Modificare la riga 59: | |||
log_failure_msg "lsyncd daemon failed to start" | |||
* Creare il file di configurazione: | |||
sudo cp /usr/share/doc/lsyncd/examples/lsyncd.conf.xml /etc/lsyncd.conf.xml | |||
* abilitare debug | |||
<debug/> | |||
* Disabilitare la cancellazione dei files se non serve, eliminado la riga: | |||
<option text="--delete"/> | |||
* Dichiarare la diretcory da monitorare e da mirrorare: | |||
<pre> | |||
<directory> | |||
<source path="/etc/dhcp"/> | |||
<target path="root@pubstor01.pubblistil.priv:/etc/dhcp"/> | |||
<exclude-from filename="/etc/lsyncd.exclude" / | |||
</directory> | |||
</pre> | |||
* Come tutti i programmi basati su inotify, lsyncd monitora le directory, non i singoli file, quindi occorre dire a rsync cosa escludere dalla copia. Creare il file con le esclusioni che deve avere il formato dell'opzione --exclude-from di rsync: | |||
sudoedit /etc/lsyncd.exclude | |||
<pre> | |||
dhcpd.conf | |||
dhclient.conf | |||
/etc/dhcp/dhclient-exit-hooks.d/ | |||
/etc/dhcp/dhclient-enter-hooks.d/ | |||
</pre> | |||
* Collegarsi come via ssh root la prima volta dal server master al server slave, per verificare il funzionamento del collegamento rsync. | |||
* Avviare lsyncd e verificare i log: | |||
sudo invoke-rc.d lsyncd start | |||
sudo tail -f /var/log/lsyncd | |||
* Verificare che le modifiche si propaghino, e che i files esclusi nons iano propagati | |||
* '''ATTENZIONE DEBIAN SQUEEZE UTILIZZA LA VERSIONE 1.X DI LSYNCD, CHE HA LA CONFIGURAZIOEN TOTALMENTE DIVERSA DAL 2.X''' | |||
* '''TODO: riavviare slave quando vengono applicate modifiche ai mac con INCRON''' | |||
=Riferimenti= | |||
*[http://www.madboa.com/geek/dhcp-failover/ Failover with ISC DHCP] | |||
*[http://blog.whatgeek.com.pt/2012/03/22/dhcp-failover-load-balancing-and-synchronization-centos-6/ DHCP failover / load balancing (and synchronization) with CentOS 6 | Feiticeir0's Blog] | |||
*[http://www.development-cycle.com/2011/07/near-realtime-file-replication-with-lsyncd/ Near Realtime File Replication With Lsyncd | Development Cycle] | |||
*[http://backdrift.org/recursive-inotify-scripting-with-lsyncd Recursive Inotify Scripting With Lsyncd | Backdrift] | |||
*[http://blackonsole.org/live-syncing-using-lsyncd/ Live syncing using lsyncd | :: b l a c k o n s o l e ::]* | |||
*[http://www.randombugs.com/linux/linux-isc-dhcp-server-failover-debian-ubuntu.html Linux ISC DHCP Server failover under Debian and Ubuntu | Random Bugs] | *[http://www.randombugs.com/linux/linux-isc-dhcp-server-failover-debian-ubuntu.html Linux ISC DHCP Server failover under Debian and Ubuntu | Random Bugs] | ||
*[http://canonical.wordpress.com/2009/11/22/dhcp-failover-with-isc-dhcp/ DHCP failover with ISC DHCP « Real-Time Web Log] | *[http://canonical.wordpress.com/2009/11/22/dhcp-failover-with-isc-dhcp/ DHCP failover with ISC DHCP « Real-Time Web Log] | ||
*[http://www.howtoforge.com/how-to-set-up-dhcp-failover-on-centos5.1 How To Set Up DHCP Failover On Centos 5.1 | HowtoForge - Linux Howtos and Tutorials] | *[http://www.howtoforge.com/how-to-set-up-dhcp-failover-on-centos5.1 How To Set Up DHCP Failover On Centos 5.1 | HowtoForge - Linux Howtos and Tutorials] | ||
Revision as of 18:37, 12 February 2013
Configurazione Master
- Occorre che la configurazione di partenza conetnga un pool, e che la configurazione base sia contenuta in un file a parte. Eventuali dichiarazioni di host statici vanno incluse in un file a parte.
- Configurazione base:
sudoedit /etc/dhcp/dhcpd.conf
# /etc/dhcp/dhcp.conf MASTER
# vim: set syntax=dhcpd.conf :
ddns-update-style none;
deny unknown-clients;
authoritative;
# FAILOVER SETTINGS
failover peer "dhcp-failover" {
primary; # declare this to be the primary server
address 192.168.6.100;
port 647;
peer address 192.168.6.101;
peer port 647;
max-response-delay 30;
max-unacked-updates 10;
load balance max seconds 3;
mclt 1800;
split 128;
}
subnet 192.168.6.0 netmask 255.255.255.0 {
option domain-name "example.com";
option domain-name-servers 192.168.6.100, 192.168.6.101;
option routers 192.168.6.254;
pool {
range 192.168.6.51 192.168.6.61;
next-server 192.168.6.100;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
server-name pubserver;
filename = "pxelinux.0";
# FAILOVER SETTINGS
failover peer "dhcp-failover";
}
}
include "/etc/dhcp/dhcpd.conf.hosts";
- Questo è il file con gli ip assegnati ai mac:
sudoedit /etc/dhcp/dhcpd.conf.hosts
# /etc/dhcp/dhcpd.conf.hosts
# vim: set syntax=dhcpd.conf :
host client011 {
# Client011
hardware ethernet 00:0F:FE:20:59:4F;
fixed-address 192.168.6.11;
}
host client012 {
# Client012
hardware ethernet 00:21:5a:20:81:76;
fixed-address 192.168.6.12;
}
#.....
- Riavviare il server dhcp master, e verificare che nonc i siano errori:
sudo invoke-rc.d isc-dhcp-server restart
Configurazione server Slave
- Copiare la stessa configurazione del master, ma cambiare:
sudoedit /etc/dhcp/dhcpd.conf
# /etc/dhcp/dhcp.conf SLAVE
#...
secondary; # declare this to be the secondary server
address 192.168.6.101;
#...
peer address 192.168.6.100;
#...
#mclt 1800;
#split 128;
#...
option domain-name-servers 192.168.6.101, 192.168.6.100;
#...
- notare, che se si hanno i server dns master e slave, si possono invertire sul dhcp server secondario.
- Copiare anche il file con gli ip assegnati ai mac
/etc/dhcp/dhcpd.conf.hosts
- Avviare e verificare che non ci siano errori
sudo invoke-rc.d isc-dhcp-server restart
- Provare ora a stoppare il master ed a rinnovare un ip.
Sincronizzazione modifiche assegnazioni IP
- Se si effettuano modifiche sui mac, è possibile aggiornare il file anche sullo slave. Allo scopo si usa lsyncd
- Installarlo
sudo apt-get install lsyncd
- Creare il file di init.d
sudo wget http://lsyncd.googlecode.com/svn-history/r73/package/debian/init.d -O /etc/init.d/lsyncd sudo chmod +x /etc/init.d/lsyncd sudo update-rc.d lsyncd defaults
- Modificare la riga 59:
log_failure_msg "lsyncd daemon failed to start"
- Creare il file di configurazione:
sudo cp /usr/share/doc/lsyncd/examples/lsyncd.conf.xml /etc/lsyncd.conf.xml
- abilitare debug
<debug/>
- Disabilitare la cancellazione dei files se non serve, eliminado la riga:
<option text="--delete"/>
- Dichiarare la diretcory da monitorare e da mirrorare:
<directory>
<source path="/etc/dhcp"/>
<target path="root@pubstor01.pubblistil.priv:/etc/dhcp"/>
<exclude-from filename="/etc/lsyncd.exclude" /
</directory>
- Come tutti i programmi basati su inotify, lsyncd monitora le directory, non i singoli file, quindi occorre dire a rsync cosa escludere dalla copia. Creare il file con le esclusioni che deve avere il formato dell'opzione --exclude-from di rsync:
sudoedit /etc/lsyncd.exclude
dhcpd.conf dhclient.conf /etc/dhcp/dhclient-exit-hooks.d/ /etc/dhcp/dhclient-enter-hooks.d/
- Collegarsi come via ssh root la prima volta dal server master al server slave, per verificare il funzionamento del collegamento rsync.
- Avviare lsyncd e verificare i log:
sudo invoke-rc.d lsyncd start sudo tail -f /var/log/lsyncd
- Verificare che le modifiche si propaghino, e che i files esclusi nons iano propagati
- ATTENZIONE DEBIAN SQUEEZE UTILIZZA LA VERSIONE 1.X DI LSYNCD, CHE HA LA CONFIGURAZIOEN TOTALMENTE DIVERSA DAL 2.X
- TODO: riavviare slave quando vengono applicate modifiche ai mac con INCRON
Riferimenti
- Failover with ISC DHCP
- DHCP failover / load balancing (and synchronization) with CentOS 6 | Feiticeir0's Blog
- Near Realtime File Replication With Lsyncd | Development Cycle
- Recursive Inotify Scripting With Lsyncd | Backdrift
- Live syncing using lsyncd | :: b l a c k o n s o l e ::*
- Linux ISC DHCP Server failover under Debian and Ubuntu | Random Bugs
- DHCP failover with ISC DHCP « Real-Time Web Log
- How To Set Up DHCP Failover On Centos 5.1 | HowtoForge - Linux Howtos and Tutorials