Per lo svolgimento degli esercizi e' disponibile un pool di virtual machine, dislocate fisicamente nel Dipartimento di Fisica. L'accesso e consentito tramite SSH:
ssh matricola@lpr-bastion.fis.unipr.it #stessa password della posta
Per l'accesso a lpr-bastion dall'esterno della rete di Ateneo e' necessario utilizzare la VPN di Ateneo .
Da lpr-bastion si accede alle macchine interne
ssh lpr1 #stessa password della posta
lpr-bastion svolge la funzione di router per le macchine interne.
#Enable IP routing #configure /etc/sysctl.conf ( net.ipv4.ip_forward = 1 ) echo 1 > /proc/sys/net/ipv4/ip_forward #runtime
Con i servizi di iptables possiamo aggiungere a lpr-bastion la funzione di NAT.
Per tutti i pacchetti in uscita (richieste di client interni e risposte a client esterni) viene modificato l'indirizzo di mittente (POSTROUTING).
service iptables start
iptables -t nat -A POSTROUTING -p all -o eth0 -j SNAT --to-source 172.28.34.100 service iptables save
Ogni servizio interno deve essere abilitato modificando l'indirizzo di destinazione (PREROUTING) Servizi su lprX abilitati su lpr-bastion:
#DNS iptables -t nat -A PREROUTING -p udp -i eth0 -d 172.28.34.100 --dport 53 -j DNAT --to-destination 192.168.0.1 #lpr1 #EMAIL iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 25 -j DNAT --to-destination 192.168.0.1 #lpr1 #WWW iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 81 -j DNAT --to-destination 192.168.0.1 #lpr1 iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 82 -j DNAT --to-destination 192.168.0.2 #lpr2 iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 83 -j DNAT --to-destination 192.168.0.3 #lpr3 iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 84 -j DNAT --to-destination 192.168.0.4 #lpr4 iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 85 -j DNAT --to-destination 192.168.0.5 #lpr5 iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 8001 -j DNAT --to-destination 192.168.1.1 #VH01 iptables -t nat -A PREROUTING -p tcp -i eth0 -d 172.28.34.100 --dport 8002 -j DNAT --to-destination 192.168.1.2 #VH02
service iptables save iptables -nvL -t nat
Su lpr-bastion e' installato un server web in ascolto sulla porta 80.
Listen 80
Serve per kickstart e per le pagine personali degli utenti.
Il servizio DHCP su lpr-bastion distribuisce ai nodi delle rete LPR le seguenti informazioni:
File di configurazione del servizio: /etc/dhcpd.conf
option domain-name "fis.unipr.it"; option domain-name-servers 192.135.11.20, 160.78.48.10; option subnet-mask 255.255.255.0; option ntp-servers ntp.fis.unipr.it; default-lease-time 21600; # 6 ore max-lease-time 43200; # 12 ore ignore unknown-clients; ddns-update-style none; not authoritative; subnet 192.168.0.0 netmask 255.255.255.0 { filename "linux-install/pxelinux.0"; next-server 192.168.0.254; #lpr-bastion option routers 192.168.0.254; #lpr-bastion option subnet-mask 255.255.255.0; use-host-decl-names on; host lpr1 { hardware ethernet 00:0C:29:D3:88:63; fixed-address 192.168.0.1; } # host lpr2 { hardware ethernet 00:0C:29:0E:78:44; fixed-address 192.168.0.2; } # host lpr3 { hardware ethernet 00:0C:29:FB:9E:D3; fixed-address 192.168.0.3; } # host lpr4 { hardware ethernet 00:0C:29:91:94:46; fixed-address 192.168.0.4; } # host lpr5 { hardware ethernet 00:0C:29:B4:2C:E3; fixed-address 192.168.0.5; } # # Esempio di configurazione di IP dinamici # range 192.168.0.200 192.168.0.240; # host lpr-wn01 { hardware ethernet 00:0C:29:D3:C7:D8; } # # host lpr-wn02 { hardware ethernet 00:0C:29:9C:AB:64; } # # host lpr-wn03 { hardware ethernet 00:0C:29:E6:3F:75; } # # host lpr-wn04 { hardware ethernet 00:0C:29:F3:F5:A0; } # # host lpr-wn05 { hardware ethernet 00:0C:29:6C:DD:63; } # }
Su lpr-bastion ci sono 2 interfacce (eth0 e eth1). Per abilitare solo eth1:
echo "DHCPDARGS=eth1" >> /etc/sysconfig/dhcpd
Consultare gli eventi del servizio:
grep dhcpd /var/log/messages
E' il prtocollo DHCP per IPv6.
Links: http://www.sbarjatiya.com/notes_wiki/index.php/Configuring_DHCPv6_server_and_client -
Installazione del server su lpr-bastion:
yum install dhcpv6.x86_64
Configurazione (pool dinamico). File /etc/dhcp6s.conf
interface eth1 { server-preference 255; renew-time 60; rebind-time 90; prefer-life-time 130; valid-life-time 200; allow rapid-commit; # option dns_servers 2000::2 ibm.com; link ALL { pool{ range 2001:760:2e04:1033::FF00 to 2001:760:2e04:1033::FFF0/64; prefix 2001:760:2e04:1033::/64; }; }; };
Log dei Leases il /var/lib/dhcpv6/server6.leases
To create a static DHCPv6 entry, the DUID and IAID of the client must be entered.
DUID: Each DHCP client and server has a DUID. DHCP servers use DUIDs to identify clients for the selection of configuration parameters and in the association of IAs (Identity Association) with clients. DHCP clients use DUIDs to identify a server in messages where a server needs to be identified. For more information, see RFC3315.
Create a DUID: ( http://www.rjsystems.nl/en/2100-dhcpv6-stateful-autocfg.php )
cd /home/lpr wget -q http://www.ipv6.mtu.edu/wide_mkduid.pl chmod 755 wide_mkduid.pl cd /var/lib/dhcpv6 /home/lpr/wide_mkduid.pl -m `ifconfig eth0 |grep HWaddr |awk '{print $5}' lpr3> DUID is 00:03:00:06:00:0c:29:fb:9e:d3 lpr4> DUID is 00:03:00:06:00:0c:29:91:94:46
IAID: An "identity-association" (IA) is a construct through which a server and a client can identify, group, and manage a set of related IPv6 addresses. Each IA consists of an IAID and associated configuration information.
Questi 3 servizi servono per l'installazione automatica dei nodi.
Attraverso il servizio tftp viene distribuito ai nodi il kernel PXE e le immagini del kernel linux di installazione.
Il server tftp e' stato installato nel seguente modo:
yum install tftp-server
Il kernel PXE viene caricato dai nodi al boot mediante una GET tftp del file /tftpboot/linux-install/pxelinux.0 (vedi configurazione DHCP).
Oltre al kernel PXE viene caricato il file di configurazione PXE che si trova nella dir /tftpboot/linux-install/pxelinux.cfg/.
I file di configurazione PXE sono i seguenti:
/tftpboot/linux-install/pxelinux.cfg/sl6x-x86_64.cfg /tftpboot/linux-install/pxelinux.cfg/sl6x-x86_64-ks.cfg
Script per gestire i file di configurazione PXE
/usr/local/sbin/ig-bootselect
ig-bootselect richiede che questa directory sia modificabile da httpd
chown apache.apache /tftpboot/linux-install/pxelinux.cfg/
Il kernel PXE carica via tftp le immagini del kernel linux per l'installazione:
/tftpboot/linux-install/boot/sl6x-x86_64/vmlinuz /tftpboot/linux-install/boot/sl6x-x86_64/initrd.img
L'installazione puo' essere automatizzata utilizzando il servizio Kickstart:
Nel file di configurazione di kickstart vengono specificate le opzioni di installazione:
http://lpr-bastion.fis.unipr.it/ks/sl6x-proxy.ks
Il seguente script CGI, eseguito al termine della procedura kickstart, modifica il file di configurazione PXE in modo che al successivo reboot dell'host venga avviato il nuovo sistema operativo:
/var/www/cgi-bin/install_ack.cgi
yum install -y boost-devel.x86_64 yum install -y gcc-c++.x86_64 yum install -y php-posix yum install -y php-readline yum install -y php-xmlrpc yum install -y mod_authz_ldap yum install -y mod_auth_cas yum install -y mod_ssl # per VH ssl yum install -y tftp yum install -y php-xml #per CAS # yum install -y yum-conf-epel yum install -y python-dns yum install -y openssl-devel # program BIO
Il file kickstart su lpr-bastion installa sui nodi lprX i seguenti file:
install -m 644 /lpr/etc/hosts /etc/ install -m 644 /lpr/etc/yum.conf /etc/ #attiva il proxy-http install -m 644 /lpr/etc/auto.master /etc/ #monta la partizione comune /home install -m 644 /lpr/etc/auto.home /etc/ install -m 644 /lpr/etc/nsswitch.conf /etc/ install -m 644 /lpr/etc/sudoers /etc/ install -m 644 /lpr/etc/openldap/ldap.conf /etc/openldap/ install -m 644 /lpr/etc/sysconfig/authconfig /etc/sysconfig/ install -m 644 /lpr/etc/pam.d/system-auth-ac /etc/pam.d/ install -m 644 /lpr/etc/pam.d/password-auth-ac /etc/pam.d/ install -m 644 /lpr/etc/pam.d/smartcard-auth-ac /etc/pam.d/ install -m 644 /lpr/etc/pam.d/fingerprint-auth-ac /etc/pam.d/ install -m 600 /lpr/etc/sssd/sssd.conf /etc/sssd/ install -m 644 /lpr/etc/ssh/ssh_config /etc/ssh/ #ssh viene configurato passwordless: install -m 644 /lpr/etc/ssh/sshd_config /etc/ssh/ #root usa il metodo public-key auth install -m 644 /lpr/etc/ssh/ssh_host_rsa_key.pub /etc/ssh/ #gli altri utenti usano hostbased auth install -m 600 /lpr/etc/ssh/ssh_host_rsa_key /etc/ssh/ install -m 600 /lpr/etc/ssh/shosts.equiv /etc/ssh/ install -m 600 /lpr/etc/ssh/ssh_known_hosts /etc/ssh/ install -m 755 -d /root/.ssh/ install -m 600 /lpr/etc/ssh/id_rsa /root/.ssh/ install -m 644 /lpr/etc/ssh/id_rsa.pub /root/.ssh/ install -m 644 /lpr/etc/ssh/id_rsa.pub /root/.ssh/authorized_keys
Sui nodi lpr1-lpr5:
echo "module load openmpi-x86_64" > /etc/profile.d/openmpi.sh