Curs administrador Linux 14,15,16,19 i 20 de juliol, potser de 2004?
TCP/IP
-10.10.1.64 / 32 es refereix a un sol equip ja que la subnetmask es
255.255.255.255.
-Eines:
ifconfig eth0 'ip_adress' netmask 'mascara'
route add -net 'ip_xarxa' netmask 'mascara' gw 'ip_gateway'
route add default gw 'ip_gateway'
netstat, interessant amb -rn , -la i -lan
nmap
tcpdump, és un snifer
Fitxers de configuració:
Servidor de fitxers; es configuren a /etc/resolv.conf
Hosts: taula estàtica de màquines
Per decidir ordre de resolució de nom: /etc/nsswitch.conf, amb una entrada
que diu:
hosts: files,dns
Fitxers de configuració de les interfícies:
a Fedora: /etc/sysconfig/network
/etc/sysconfig/network-scripts
Configuracions lògiques i perfils:
Podem associar a una interfície física vàries interfícies lògiques. Son
configuracions predefinides que podem associar a una interfície física.
Veurem com la fa la Fedora:
La configuració està a /etc/sysconfig/networkscripts, trobem el fitxer
ifcfg-eth0, que té el contingut:
# Realtek|RTL-8139/8139C/8139C+
DEVICE=eth0
BOOTPROTO=static
BROADCAST=10.10.255.255
HWADDR=00:E0:4C:C0:B9:F1
IPADDR=10.10.1.63
NETMASK=255.255.0.0
NETWORK=10.10.0.0
ONBOOT=yes
TYPE=Ethernet
bootproto=dhcp, per fer configuració per dhcp.
Podem tenir tants fitxers com interfícies ifcfg-eth0, ifcfg-eth1,
ifcfg-eth0:0, ifcfg-eth0_casa.
Per activar una d'aquestes interfícies lògiques fem ifup i per desactivar
ifdown. Per exemple podriem fer ifdown eth0_casa, ifup eth0_feina.
A Debian les interficies lògiques les fa amb uns fitxers que es dieun
ifstates ???(consultar).
Perfil: a més de ip, configuro Dns, nom de màquina (/etc/resolv.conf) i el
fitxer de hosts.
Aquest temes estàn ben tractats amb l'interfície gràfica de Fedora.
DNS:
Bind 4, 8 i 9 (les més conegudes). . Pot treballar "engabiat" amb un
chroot.La gàbia està a /var/named/chroot/.
Bind deixa obert el port 53.
Si no treballem com a gàbia, la configuració està a /var/named i el fitxer
de configuració és /etc/named.conf.
Si treballem com a gàbia, la configuració està a /var/named/chroot/var/named i el fitxer de configuració a /var/named/chroot/etc/named.conf
A Fedora hi ha un error i hem de copiar el fitxers named.conf i rndc.key
de /etc a /var/named/chroot.
Amb el fitxer de named.conf configurem: opcions generals, logging i
defició de zones. Després hi han fitxers de configuració de cada zona.
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
include "/etc/rndc.key";
Primera zona es la root (.) de tipus Hint, que redirecciona cap a fora, el
fitxer named.ca indica els servidors root.
La segona zona es localhost. El type master vol dir que pot modificar la
zona (que no és slave).
Ens diu el nom de fitxer de configuració i les màquines
La tercera és la zona inversa. A vegades no s'utilitzen ni son obligatòries.
Eines, tenim nslookup i dig.
--------------------------
Podem instal.lar un servidor de forward, que envía les peticions a un
altre "Pare". Els forwards es posen al fitxer de named.conf. A quest
fitxer:
/* */ entre això està comentat
// comentat
Afegirem :
forwarders first;
forwarders {195.77.207.125;
195.235.113.3,};
Per aplicar canvis, fa falta reiniciar el servidor o recarregar el fitxer
de configuració. (restart o reload).
Un fitxer indica si tot va bé: /var/logs/messages. El mirem amb tail -m
(mira de baix a dalt).
tail -n30 /var/log/messages (30 últimes línies)
tail -f /var/log/messages (va mostrant les últimes línies)
-----------------------
El nostre domini:
a named.conf:
zone "admin.net" IN {
type master;
file "admin.net.db";
};
El IN vol dir zona d'internet. Per si de cas nosaltres la posarem.
Zones master, slave i stub. Aquesta última stub només transfereix els
equips DNS d'aquella zona, pot ser útil per optimitzar recerca.
Finalment el fitxer ha quedat com:
// generated by named-bootconf.pl
options {
directory "/var/named";
/*
* If there is a firewall between you and nameservers you want
* to talk to, you might need to uncomment the query-source
* directive below. Previous versions of BIND always asked
* questions using port 53, but BIND 8.1 uses an unprivileged
* port by default.
*/
// query-source address * port 53;
forward first;
forwarders {195.77.207.125;
195.235.113.3;};
};
//
// a caching only nameserver config
//
controls {
inet 127.0.0.1 allow { localhost; } keys { rndckey; };
};
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "admin.net" IN {
type master;
file "admin.net.db";
};
Ara crearem propiament els fitxers de zona a /var/named/chroot/var/named/
El fitxer s'anomenarà admin.net.db:
$TTL 86400
$ORIGIN admin.net.
@ 1D IN SOA ns.admin.net. root (
42 ; serial (d. adams)
3H ; refresh
15M ; retry
1W ; expiry
1D ) ; minimum
1D IN NS ns.admin.net.
ns.admin.net. A 10.10.1.63
www.admin.net. A 10.10.1.67
mail.admin.net. A 10.10.1.68
mail2.admin.net. A 10.10.1.70
pc-003 A 10.10.1.63
IN 10 MX mail.admin.net.
IN 20 MX mail2.admin.net.
(A dominoteca.com, dominis ràpid. 2 ip públiques i 2 dns si volem el nostre
domini. Com a truquet es pot ficar un servidor nostre DNS i un altre públic -ya.com, wanadoo...-)
Ara passem al servidor de la susana. Si volem mantenir el nostre, hem de
canviar els forwarders nostres, i redirigirlos cap el servidor de la Susana.
Fer el servei permanent: Anem a /etc/rc5.d/ i fer la següent comanda:
ln -s /etc/init.d/named S60named
------------------
Per no haver d'escriure el domini cada cop en fer un ping, etc, a
resolv.conf hem d'afegir un paràmetre per a cercar les zones per defecte:
search admin.net
Podriem ficar varis dominis separats per espais.
------------
Configurar DNS esclau: al named.conf definirem una zona esclava:
zone "admin.net" IN {
type slave;
file "admin.net.slave.db";
masters {10.10.1.69;};
};
El fitxer admin.net.slave.db no l'hem d'omplir ja que s'omplirà sol en fer
una transferència de zona.
IMPORTANT: al contrari que al fitxers de zona, en la definició de la zona
a named.conf, no s'acaba amb punt.(admin.net)
Ara modificarem el named.conf del master per indicar qui pot fer
transferència de zona, quedarà així:
zone "admin.net" IN {
type master;
file "admin.net.db";
allow-trasfer {10.10.1.66;};
Tenim problemes inicialment per què l'usuari named no té permis per
escriure. Haurem de fer
chwon -R named /var/named/chroot.
Per veure com va, amb dig.
Mes informació amb man named i man named.conf
----------------------------
Configurar arranc de dimonis:
Eina: chkconfig -list
APACHE:
Fins apache 1.3 hi havia 3 fitxers de configuració.
A partir d'aquí hi ha un sol fitxer, httpd.conf, està a /etc/httpd/conf/.
Es divideix en 3 parts:
1- paràmetres generals servidor apache, més a nivell de procés
2- main, paràmetres que defineixen el servidor per defecte i que poden
utilitzar els diferents servidors virtuals
3- definicions de servidors virtuals.
Usuaris possibles que "corren" l'apache segons la distribució: www-data,
www, noboody
UseCanonicalName Off, si fem una petició des del client, farem servir com
arrel el que ha escrit el client, si està en on, fariem servir el nom que
diu a "server name".
S'adjunta fitxer httpd.conf com a exemple.
-----------------
Servidors virtuals: varis dominis virtuals. Per Ips i per noms. Podem
associar diversos dominis a diverses tarjes de xarxa (per IP), o diversos
dominis amb una sola tarja de xarxa (basats en noms).
---------------
Per instal.lar webmin hauria de ser a /usr/local/webmin
SERVIDOR DE CORREU:
Com a pop3: dovecot
Al fitxer de configuració a /etc/postfix/main.cf, modifiquem:
# INTERNET HOST AND DOMAIN NAMES
#
# The myhostname parameter specifies the internet hostname of this
# mail system. The default is to use the fully-qualified domain name
# from gethostname(). $myhostname is used as a default value for many
# other configuration parameters.
#
myhostname = mail.admin.net
#myhostname = virtual.domain.tld
# The mydomain parameter specifies the local internet domain name.
# The default is to use $myhostname minus the first component.
# $mydomain is used as a default value for many other configuration
# parameters.
#
mydomain = admin.net
Amb quin domini sortiran els e-mails:
# SENDING MAIL
#
# The myorigin parameter specifies the domain that locally-posted
# mail appears to come from. The default is to append $myhostname,
# which is fine for small sites. If you run a domain with multiple
# machines, you should (1) change this to $mydomain and (2) set up
# a domain-wide alias database that aliases each user to
# user@that.users.mailhost.
#
# For the sake of consistency between sender and recipient addresses,
# myorigin also specifies the default domain name that is appended
# to recipient addresses that have no @domain part.
#
#myorigin = $myhostname
myorigin = $mydomain
--------------
# RECEIVING MAIL
# The inet_interfaces parameter specifies the network interface
# addresses that this mail system receives mail on. By default,
# the software claims all active interfaces on the machine. The
# parameter also controls delivery of mail to user@[ip.address].
#
# See also the proxy_interfaces parameter, for network addresses that
# are forwarded to us via a proxy or network address translator.
#
# Note: you need to stop/start Postfix when this parameter changes.
#
inet_interfaces = all
#inet_interfaces = $myhostname
#inet_interfaces = $myhostname, localhost
-----
# The mydestination parameter specifies the list of domains that this
# machine considers itself the final destination for.
#
# These domains are routed to the delivery agent specified with the
# local_transport parameter setting. By default, that is the UNIX
# compatible delivery agent that lookups all recipients in /etc/passwd
# and /etc/aliases or their equivalent.
#
# The default is $myhostname + localhost.$mydomain. On a mail domain
# gateway, you should also include $mydomain.
#
# Do not specify the names of virtual domains - those domains are
# specified elsewhere (see sample-virtual.cf).
#
# Do not specify the names of domains that this machine is backup MX
# host for. Specify those names via the relay_domains settings for
# the SMTP server, or use permit_mx_backup if you are lazy (see
# sample-smtpd.cf).
#
# The local machine is always the final destination for mail addressed
# to user@[the.net.work.address] of an interface that the mail system
# receives mail on (see the inet_interfaces parameter).
#
# Specify a list of host or domain names, /file/name or type:table
# patterns, separated by commas and/or whitespace. A /file/name
# pattern is replaced by its contents; a type:table is matched when
# a name matches a lookup key (the right-hand side is ignored).
# Continue long lines by starting the next line with whitespace.
#
# DO NOT LIST RELAY DESTINATIONS IN MYDESTINATION.
# SPECIFY RELAY DESTINATIONS IN RELAY_DOMAINS.
#
# See also below, section "REJECTING MAIL FOR UNKNOWN LOCAL USERS".
#
#mydestination = $myhostname, localhost.$mydomain $mydomain
#mydestination = $myhostname, localhost.$mydomain, $mydomain,
# mail.$mydomain, www.$mydomain, ftp.$mydomain
mydestination = $myhostname, $mydomain
------------------------
# You can specify the list of "trusted" network addresses by hand
# or you can let Postfix do it for you (which is the default).
#
# By default (mynetworks_style = subnet), Postfix "trusts" SMTP
# clients in the same IP subnetworks as the local machine.
# On Linux, this does works correctly only with interfaces specified
# with the "ifconfig" command.
#
# Specify "mynetworks_style = class" when Postfix should "trust" SMTP
# clients in the same IP class A/B/C networks as the local machine.
# Don't do this with a dialup site - it would cause Postfix to "trust"
# your entire provider's network. Instead, specify an explicit
# mynetworks list by hand, as described below.
#
# Specify "mynetworks_style = host" when Postfix should "trust"
# only the local machine.
#
#mynetworks_style = class
#mynetworks_style = subnet
#mynetworks_style = host
# Alternatively, you can specify the mynetworks list by hand, in
# which case Postfix ignores the mynetworks_style setting.
#
# Specify an explicit list of network/netmask patterns, where the
# mask specifies the number of bits in the network part of a host
# address.
#
# You can also specify the absolute pathname of a pattern file instead
# of listing the patterns here. Specify type:table for table-based lookups
# (the value on the table right-hand side is not used).
#
mynetworks = 10.10.1.0/24, 127.0.0.0/8
#mynetworks = $config_directory/mynetworks
#mynetworks = hash:/etc/postfix/network_table
Els que no estiguin aquí no podràn accedir i indicarà que no pots fer relay.
----
Autenticació per smtp a linux: sasl. Suporta varis tipus d'autenticació
i d'encriptació.
---
A Red Hat s'engega sendmail, l'hem d'aturar, després:
chkconfig sendmail off
chkconfig --add postfix
-----
Comprovem que està activat smtp:
[root@pc-003 root]# netstat -lap | more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 *:32769 *:* LISTEN 1724/rpc.statd
tcp 0 0 pc-003:32770 *:* LISTEN 2072/xinetd
tcp 0 0 pc-003:783 *:* LISTEN 2137/spamd -d -c -a
tcp 0 0 *:sunrpc *:* LISTEN 1704/portmap
tcp 0 0 *:10000 *:* LISTEN 2274/perl
tcp 0 0 pc-003:ipp *:* LISTEN 1868/cupsd
tcp 0 0 *:smtp *:* LISTEN 2124/master
tcp 1 0 pc-003:32774 pc-003:ipp CLOSE_WAIT 2718/eggcups
tcp 0 0 *:ssh *:* LISTEN 2057/sshd
tcp 0 0 *:smtp *:* LISTEN 2124/master
tcp 0 0 *:https *:* LISTEN 2158/httpd
udp 0 0 *:32768 *:* 1724/rpc.statd
udp 0 0 *:10000 *:* 2274/perl
udp 0 0 *:sunrpc *:* 1704/portmap
udp 0 0 *:628 *:* 1724/rpc.statd
udp 0 0 *:ipp *:* 1868/cupsd
udp 0 0 *:xdmcp *:* 2326/gdm-binary
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags Type State I-Node PID/Program name Path
unix 2 [ ACC ] STREAM LISTENING 5168 2792/esd /tmp/.esd/socket
unix 2 [ ACC ] STREAM LISTENING 4472 2619/fam /tmp/.fam_socket
unix 2 [ ACC ] STREAM LISTENING 4012 2326/gdm-binary /tmp/.gdm_socket
----
Si volem connexions segures, hem d'instal.lar el mòdul SSL per Postfix.
Per autenticar amb nom i password a smtp, hem d'instal.lar el mòdul SASL.
Els correus físicament estàn a /var/mail/nom_usuari
-----
Pop: courier-imap... Farem servir dovecot que porta IMAP + POP.
Hem de configurar /etc/dovecot.conf
chkconfig dovecot start
chkconfig dovecot on
netstat -lan | more
nmap localhost per comprovar :
IMAP 143
POP 110
Squirrelmail:
cd /usr/share/squirrelmail/, son les fonts de squirrelmail. Configurarem
amb el conf.pl
Ara modifiquem l'Apache per accedir a aquets fitxers.
Un alias pot accedir a qualsevol carpeta encara que estigui fora del
document root.
Podem fer un enllaç simbòlic i fer que l'Apache el segueixi ficant el paràmetre "followsimlinks" al directori virtual.
La manera més ràpida és un alias.
alias /webmail/ "/usr/share/squirrelmail/"
Servidors samba, NFS