Corrigé du TP 3
Services FTP et DHCP
IUT Aix-Marseille - INFO Aix C. Pain-Barre
1 FTP
1.6 Exercices
Corrigé de l’exercice 1 (Session FTP graphique à allegro)
[Consulter l’énoncé]
Cet exercice ne devrait pas poser de problèmes particuliers. La fenêtre degftpdevrait ressembler à celle de la figure1.
FIGURE1–Transfert de fichier par FTP réalisé avecgftp
Corrigé de l’exercice 2 (Session FTP en mode texte à allegro)
[Consulter l’énoncé]
toto@pc$ ftp allegro
Connected to allegro.aix.univ-amu.fr.
220 allegro.aix.univ-amu.fr FTP server (Version 6.4/OpenBSD/Linux-ftpd-0.17) ready.
Name (allegro:toto): etxxxx
331 Password required for etxxxx.
Password: mon password
230- Linux allegro 2.6.32-5-686 #1 SMP Sat May 5 01:33:08 UTC 2012 i686 230-
230- The programs included with the Debian GNU/Linux system are free software;
230- the exact distribution terms for each program are described in the 230- individual files in /usr/share/doc/*/copyright.
230-
230- Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent 230- permitted by applicable law.
230 User etxxxx logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
1. ftp> passive Passive mode on.
2. ftp> cd /home/cpb/public/unix 250 CWD command successful.
ftp> dir
227 Entering Passive Mode (139,124,181,131,195,191) 150 Opening ASCII mode data connection for '/bin/ls'.
total 4788
-rw-r--r-- 1 cpb prof 19254 Aug 30 2012 BonnePartieDeTP6UnixIUT.pdf.bz2 -rw-r--r-- 1 cpb prof 476014 Aug 30 2012 Cours8&9Unix.pdf.bz2
-rw-r--r-- 1 cpb prof 96059 Aug 30 2012 TP6UnixIUT.pdf.bz2 -rw-r--r-- 1 cpb prof 50500 Aug 30 2012 Test08-10-04.pdf.bz2 -rw-r--r-- 1 cpb prof 4840 Aug 30 2012 a_decouper.txt
...
226 Transfer complete.
ftp> bin
200 Type set to I.
ê
le fichier à transférer est de type binaire ftp> get bart.giflocal: bart.gif remote: bart.gif
227 Entering Passive Mode (139,124,181,131,148,182)
150 Opening BINARY mode data connection for 'bart.gif' (3807 bytes).
226 Transfer complete.
3807 bytes received in 0.04 secs (83.5 kB/s) 3. . . . pas de corrigé pour cette question. . .
4. ftp> cd /home/etxxxx
250 CWD command successful.
ftp> ascii
200 Type set to A.
ê
cette fois, le fichier à déposer est un fichier texteftp> put un-fichier.txt
local: un-fichier.txt remote: un-fichier.txt
227 Entering Passive Mode (139,124,181,131,191,139)
150 Opening ASCII mode data connection for 'un-fichier.txt'.
226 Transfer complete.
128 bytes sent in 0.00 secs (2500.0 kB/s) 5. ftp> bye
221 Goodbye.
toto@pc$
Corrigé de l’exercice 3 (Session FTP avec ftp.rfc-editor.org depuis Linux)
[Consulter l’énoncé]
toto@pc$ ftp ftp.rfc-editor.org Connected to ftp.rfc-editor.org.
220 "FTP Server Ready"
Name (ftp.rfc-editor.org:toto): anonymous 331 Please specify the password.
Password: toto@etu.univ-amu.fr 230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
1. ftp> passive Passive mode on.
2. ftp> cd in-notes
250 Directory successfully changed.
3. ftp> hash
Hash mark printing on (1024 bytes/hash mark).
ftp> ascii
200 Switching to ASCII mode.
ftp> get rfc1939.txt
local: rfc1939.txt remote: rfc1939.txt
227 Entering Passive Mode (4,31,198,49,117,146).
150 Opening ASCII mode data connection for rfc1939.txt (47018 bytes).
################################################
226 Transfer complete.
48309 bytes received in 0.52 secs (90.1 kB/s) 4. ftp> bye
221 Goodbye.
1.8 Exercices
Corrigé de l’exercice 4 (Transfert manuel en mode passif)
[Consulter l’énoncé]
toto@pc$ telnet ftp.rfc-editor.org 21 Trying 4.31.198.49...
Connected to ftp.rfc-editor.org.
Escape character is '^]'.
220 "FTP Server Ready"
USER anonymous
331 Please specify the password.
PASS toto@etu.univ-amu.fr 230 Login successful.
CWD in-notes
250 Directory successfully changed.
TYPE A
200 Switching to ASCII mode.
PASV
227 Entering Passive Mode (4,31,198,49,117,68).
ê
à ce stade, il faut se connecter à l’adresse (4.31.198.49) et au port (117×256 + 68), indiqués entre parenthèses dans la ligne ci-dessus. Pour cela, on utilisenc(et un peu de shell) dans un autre terminal :$ nc 4.31.198.49 $((117*256+68)) > rfc821.txt
ê
où$((117*256+68))demande àbashde calculer le port (30020), et où on redirige la sortie dencdans le fichier de notre choix (rfc821.txt)RETR rfc821.txt
150 Opening ASCII mode data connection for rfc821.txt (120432 bytes).
226 Transfer complete.
ê
à ce stade, le transfert est terminé,ncs’arrête, et le fichierrfc821.txta été rempli QUIT221 Goodbye.
Connection closed by foreign host.
toto@pc$
1.9 Installation du serveur ProFTP
Corrigé de l’exercice 5 (Installation de proftpd)
[Consulter l’énoncé]
1. . . . pas de corrigé pour cette question. . . 2. . . . pas de corrigé pour cette question. . . 3. . . . pas de corrigé pour cette question. . .
4. m2:~# apt-get update
Ign http://ftp.fr.debian.org lenny Release.gpg
Ign http://ftp.fr.debian.org lenny/main Translation-en_US ...
Get:5 http://archive.debian.org lenny/main Packages [5191kB]
Get:6 http://archive.debian.org lenny/contrib Packages [76.2kB]
...
W: Failed to fetch http://security.debian.org/dists/lenny/updates/contrib/source/Sources.gz 404 Not Found [IP: 212.211.132.32 80]
E: Some index files failed to download, they have been ignored, or old ones used instead.
5. m2:~# apt-cache search ftp-server
ftpd-ssl - FTP server with SSL encryption support ftpd - File Transfer Protocol (FTP) server
...
wu-ftpd - powerful and widely used FTP server ...
proftpd-basic - versatile, virtual-hosting FTP daemon - binaries vsftpd - The Very Secure FTP Daemon
6. m2:~# apt-get install proftpd-basic Reading package lists... Done
Building dependency tree
Reading state information... Done ...
Suggested packages:
proftpd-doc proftpd-mod-mysql proftpd-mod-pgsql proftpd-mod-ldap The following NEW packages will be installed:
proftpd-basic
0 upgraded, 1 newly installed, 0 to remove and 543 not upgraded.
Need to get 691kB of archives.
After this operation, 1603kB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
proftpd-basic
Install these packages without verification [y/N]? y
Get:1 http://archive.debian.org lenny/main proftpd-basic 1.3.1-17lenny9 [691kB]
Fetched 691kB in 0s (1441kB/s) Preconfiguring packages ...
Selecting previously deselected package proftpd-basic.
(Reading database ... 78259 files and directories currently installed.) Unpacking proftpd-basic (from .../proftpd-basic_1.3.1-17lenny9_i386.deb) ...
Setting up proftpd-basic (1.3.1-17lenny9) ...
Adding system user `proftpd' (UID 108) ...
Adding new user `proftpd' (UID 108) with group `nogroup' ...
Not creating home directory `/var/run/proftpd'.
Adding system user `ftp' (UID 109) ...
Adding new user `ftp' (UID 109) with group `nogroup' ...
Creating home directory `/home/ftp' ...
`/usr/share/proftpd/templates/welcome.msg' -> `/home/ftp/welcome.msg.proftpd-new' Starting ftp server: proftpd.
7. m2:~# /etc/init.d/proftpd start Starting ftp server: proftpd.
8. m2:~# netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:58917 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:4459 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:113 0.0.0.0:* LISTEN
tcp6 0 0 :::21 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
ê
Les options utilisées sont -tpour TCP, -lpour les serveurs en écoute (listen), et-n pour garder les adresses et les ports sous forme numérique. Ca n’a pas d’importance mais on peut aussi remarquer que le serveur utilise une adresse d’écoute IPv6 (mais qui comprend IPv4).9. Une recherche de la chaîneftpdans le fichier suffit : m2:~# grep -i ftp /etc/services
ftp-data 20/tcp
ftp 21/tcp
tftp 69/udp
sftp 115/tcp
ftps-data 989/tcp # FTP over SSL (data)
ftps 990/tcp
venus-se 2431/udp # udp sftp side effect
codasrv-se 2433/udp # udp sftp side effect
frox 2121/tcp # frox: caching ftp proxy
zope-ftp 8021/tcp # zope management by ftp
ê
les ports concernés sont mis en évidence en grasCorrigé de l’exercice 6 (Autoriser l’accès à root)
[Consulter l’énoncé]
1.
-
D’abord, il faut configurerm1:m1:~# ifconfig eth0 10.0.2.15/24 m1:~# route add default gw 10.0.2.2
m1:~# ftp 10.0.2.10 Connected to 10.0.2.10.
220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]
Name (10.0.2.10:root):
331 Password required for root Password:
530 Login incorrect.
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit 221 Goodbye.
ê
En effet, le loginroota échoué2. (a) le fichier modifié devrait commencer par les lignes suivantes, où les modifications sont en gras :
# /etc/ftpusers: list of users disallowed FTP access. See ftpusers(5).
# root daemon ...
(b) La portion du fichier modifié devrait contenir les lignes : ...
# DefaultRoot ~
# Autoriser le login root
RootLogin on
...
(c) m2:~# /etc/init.d/proftpd stop Stopping ftp server: proftpd.
m2:~# /etc/init.d/proftpd start Starting ftp server: proftpd.
-
on aurait pu aussi taper la seule commande : m2:~# /etc/init.d/proftpd restart Stopping ftp server: proftpd.Starting ftp server: proftpd.
3. m1:~# ftp 10.0.2.10 Connected to 10.0.2.10.
220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]
Name (10.0.2.10:root):
331 Password required for root Password:
230 User root logged in Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwx--- 2 root root 4096 Sep 15 2007 Desktop drwxr-xr-x 2 root root 4096 Sep 5 2007 tmp 226 Transfer complete
ftp> quit 221 Goodbye.
4. . . . pas de corrigé pour cette question. . .
Corrigé de l’exercice 7 (Autoriser l’accès aux utilisateurs)
[Consulter l’énoncé]
1. m2:~# adduser toto Adding user `toto' ...
Adding new group `toto' (1000) ...
Adding new user `toto' (1000) with group `toto' ...
Creating home directory `/home/toto' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: toto Retype new UNIX password: toto
passwd: password updated successfully Changing the user information for toto
Enter the new value, or press ENTER for the default Full Name []:
Room Number []:
Work Phone []:
Home Phone []:
Other []:
Is the information correct? [y/N] y m2:~# adduser titi
Adding user `titi' ...
...
m2:~#
2. m1:~# pwd /root m1:~# ls Desktop tmp
ê
pour le moment, il n’y a que deux répertoires dans le répertoire personnel derootsurm1 m1:~# ftp 10.0.2.10Connected to 10.0.2.10.
220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]
Name (10.0.2.10:root): toto 331 Password required for toto Password:
230 User toto logged in Remote system type is UNIX.
Using binary mode to transfer files.
ê
le login detotoa bien été accepté ftp> pwd257 "/home/toto" is the current directory ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list 226 Transfer complete
ê
son répertoire personnel est vide surm2ftp> put /etc/passwd passwd
local: /etc/passwd remote: passwd 200 PORT command successful
150 Opening BINARY mode data connection for passwd 226 Transfer complete
1091 bytes sent in 0.00 secs (5667.2 kB/s) ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 toto toto 1091 Dec 29 12:25 passwd 226 Transfer complete
ê
totopeut y déposer un fichier ftp> get passwd mypassswdlocal: mypassswd remote: passwd 200 PORT command successful
150 Opening BINARY mode data connection for passwd (1091 bytes) 226 Transfer complete
1091 bytes received in 0.00 secs (716.5 kB/s) ftp> ! ls -l
total 12
drwx--- 2 root root 4096 2007-09-15 13:22 Desktop -rw-r--r-- 1 root root 1091 2014-12-29 13:26 mypassswd drwxr-xr-x 2 root root 4096 2007-09-05 18:00 tmp
ftp>
ê
et peut aussi en télécharger ; les transferts fonctionnent bien dans les deux sens.3. ftp> cd ..
250 CWD command successful ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxr-xr-x 2 ftp nogroup 4096 Dec 29 11:09 ftp drwxr-xr-x 2 titi titi 4096 Dec 29 12:23 titi drwxr-xr-x 2 toto toto 4096 Dec 29 12:25 toto 226 Transfer complete
ftp> cd ftp
250 CWD command successful ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 root root 170 Nov 16 2011 welcome.msg 226 Transfer complete
ftp> get welcome.msg
local: welcome.msg remote: welcome.msg 200 PORT command successful
150 Opening BINARY mode data connection for welcome.msg (170 bytes) 226 Transfer complete
170 bytes received in 0.00 secs (532.1 kB/s) ftp> ! ls
Desktop mypassswd tmp welcome.msg
ê
effectivement,totopeut se balader dans l’arborescence et télécharger des fichiers4. La portion du fichier concernée devient donc : ...
# Use this to jail all users in their homes
DefaultRoot ~
...
5. ftp> open 10.0.2.10 Connected to 10.0.2.10.
220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]
Name (10.0.2.10:root): toto 331 Password required for toto Password: toto
230 User toto logged in Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 toto toto 1091 Dec 29 12:25 passwd 226 Transfer complete
ftp> cd ..
250 CWD command successful ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 toto toto 1091 Dec 29 12:25 passwd 226 Transfer complete
ê
tiens ? en redescendant, on a le même contenu ? ftp> pwd257 "/" is the current directory
ê
en effet, cartotose situe à la "racine", c’est à dire son répertoire personnel. . .Corrigé de l’exercice 8 (Autoriser le login anonyme)
[Consulter l’énoncé]
1. La portion du fichier modifiée devient :
<Anonymous ~ftp>
User ftp
Group nogroup
# We want clients to be able to login with "anonymous" as well as "ftp"
UserAlias anonymous ftp
# Cosmetic changes, all files belongs to ftp user DirFakeUser on ftp
DirFakeGroup on ftp
RequireValidShell off
# Limit the maximum number of anonymous logins
MaxClients 10
# We want 'welcome.msg' displayed at login, and '.message' displayed
# in each newly chdired directory.
DisplayLogin welcome.msg
DisplayChdir .message
# Limit WRITE everywhere in the anonymous chroot
<Directory *>
<Limit WRITE>
DenyAll
</Limit>
</Directory>
# Uncomment this if you're brave.
<Directory incoming>
# Umask 022 is a good standard umask to prevent new files and dirs
# (second parm) from being group and world writable.
Umask 022 022
<Limit READ WRITE>
DenyAll
</Limit>
<Limit STOR>
AllowAll
</Limit>
</Directory>
</Anonymous>
2. m1:~# cp /etc/passwd . 3. m1:~# ftp 10.0.2.10
Connected to 10.0.2.10.
220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]
Name (10.0.2.10:root): anonymous
331 Anonymous login ok, send your complete email address as your password Password:
230-Welcome, archive user anonymous@::ffff:10.0.2.15 !
230-
230-The local time is: Tue Dec 23 17:54:06 2014 230-
230-This is an experimental FTP server. If you have any unusual problems, 230-please report them via e-mail to <root@localhost>.
230-
230 Anonymous access granted, restrictions apply Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
4. ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 ftp ftp 170 Nov 16 2011 welcome.msg 226 Transfer complete
ftp> ascii
200 Type set to A ftp> get welcome.msg
local: welcome.msg remote: welcome.msg 200 PORT command successful
150 Opening ASCII mode data connection for welcome.msg (170 bytes) 226 Transfer complete
177 bytes received in 0.00 secs (442.1 kB/s) ftp> ! cat welcome.msg
Welcome, archive user %U@%R ! The local time is: %T
This is an experimental FTP server. If you have any unusual problems, please report them via e-mail to <root@%L>.
5. ftp> put passwd
local: passwd remote: passwd 200 PORT command successful
550 passwd: No such file or directory
ê
en effet, le transfert est refusé 6. m2:~# cp /etc/services /home/ftpm2:~# ls -l /home/ftp total 24
-rw-r--r-- 1 root root 18274 2014-12-29 14:56 services -rw-r--r-- 1 root root 170 2011-11-16 10:55 welcome.msg 7. Sur la session FTP dem1:
ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 ftp ftp 18274 Dec 23 17:02 services -rw-r--r-- 1 ftp ftp 170 Nov 16 2011 welcome.msg 226 Transfer complete
8. Surm2:
m2:~# mkdir /home/ftp/incoming m2:~# ls -ld /home/ftp/incoming
drwxr-xr-x 2 root root 4096 2014-12-29 15:06 /home/ftp/incoming
et sur la session FTP dem1: ftp> dir
200 PORT command successful
150 Opening ASCII mode data connection for file list
drwxr-xr-x 2 ftp ftp 4096 Dec 29 13:58 incoming -rw-r--r-- 1 ftp ftp 18274 Dec 29 13:56 services -rw-r--r-- 1 ftp ftp 170 Nov 16 2011 welcome.msg 226 Transfer complete
ê
le répertoireincomingest bien présent ftp> put /etc/protocols incoming/protocolslocal: /etc/protocols remote: incoming/protocols 200 PORT command successful
550 incoming/protocols: Permission denied
ê
mais on ne peut y déposer un fichier9. On peut observer que ce sont les identités indiquées dans la partie <Anonymous ~ftp> du fichier de configuration. . .
10. ftp> put /etc/protocols incoming/protocols
local: /etc/protocols remote: incoming/protocols 200 PORT command successful
150 Opening BINARY mode data connection for incoming/protocols 226 Transfer complete
2510 bytes sent in 0.00 secs (6846.8 kB/s) ftp> dir incoming
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 ftp ftp 2510 Dec 29 14:11 protocols 226 Transfer complete
ê
le fichier a bien été déposé sur le serveur 11. ftp> get incoming/protocols zefilelocal: zefile remote: incoming/protocols 200 PORT command successful
550 incoming/protocols: No such file or directory
ê
précisons que c’est le téléchargement qui pose problème et non pas le nom qu’on veut donner à notre copie du fichier12. Dans la partie<Directory incoming>, il faut ajouter la directive :
AllowOverwrite off
et remplacer la directive :
<Limit READ WRITE>
DenyAll
</Limit>
par les deux directives :
<Limit WRITE>
DenyAll
</Limit>
<Limit READ>
AllowAll
</Limit>
Et enfin redémarrer le serveur :
m2:/home/ftp# /etc/init.d/proftpd restart Stopping ftp server: proftpd.
Starting ftp server: proftpd.
13. On rouvre une session FTP : ftp> open 10.0.2.10 Connected to 10.0.2.10.
220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]
Name (10.0.2.10:root): anonymous
331 Anonymous login ok, send your complete email address as your password Password:
230-Welcome, archive user anonymous@::ffff:10.0.2.15 ! 230-
230-The local time is: Mon Dec 29 15:18:20 2014 230-
230-This is an experimental FTP server. If you have any unusual problems, 230-please report them via e-mail to <root@localhost>.
230-
230 Anonymous access granted, restrictions apply Remote system type is UNIX.
Using binary mode to transfer files.
ftp> dir incoming
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 ftp ftp 2510 Dec 29 14:11 protocols 226 Transfer complete
ftp> get incoming/protocols ze-file
local: ze-file remote: incoming/protocols 200 PORT command successful
150 Opening BINARY mode data connection for incoming/protocols (2510 bytes) 226 Transfer complete
2510 bytes received in 0.00 secs (1518.7 kB/s)
ê
le téléchargement du fichier fonctionne bien ftp> put /etc/passwd incoming/protocolslocal: /etc/passwd remote: incoming/protocols 200 PORT command successful
550 incoming/protocols: Overwrite permission denied
ê
et on ne peut pas écraser le fichier ftp> delete incoming/protocols550 incoming/protocols: No such file or directory
ê
ni le supprimerftp> append /etc/passwd incoming/protocols local: /etc/passwd remote: incoming/protocols 200 PORT command successful
550 incoming/protocols: No such file or directory
ê
on ne peut pas non plus lui ajouter du contenuftp> put /etc/passwd incoming/truc
local: /etc/passwd remote: incoming/truc 200 PORT command successful
150 Opening BINARY mode data connection for incoming/truc 226 Transfer complete
1091 bytes sent in 0.00 secs (7102.9 kB/s) ftp> dir incoming
200 PORT command successful
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 ftp ftp 2510 Dec 29 14:11 protocols -rw-r--r-- 1 ftp ftp 1091 Dec 29 14:36 truc 226 Transfer complete
ê
on peut toujours déposer un fichierftp> rename incoming/truc incoming/passwd
350 File or directory exists, ready for destination name 550 Rename incoming/passwd: No such file or directory
ê
mais qu’on ne peut même pas renommer. . .Corrigé de l’exercice 9 (Transfert manuel en mode actif)
[Consulter l’énoncé]
1. Le serveur écoute sur le port21donc : m1:~# telnet 10.0.2.10 21 Trying 10.0.2.10...
Connected to 10.0.2.10.
Escape character is '^]'.
220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]
2. USER toto
331 Password required for toto PASS toto
230 User toto logged in 3.
4. $ nc -l -p 12345 5. PORT 10,0,2,15,48,57
200 PORT command successful 6. LIST
150 Opening ASCII mode data connection for file list 226 Transfer complete
ê
le serveur de m2envoie le contenu du répertoire sur la connexion de données, établie avecnc (mode actif)7. QUIT
221 Goodbye.
Connection closed by foreign host.
m1:~#
2 DHCP
2.1 Configuration d’un serveur DHCP
Corrigé de l’exercice 11 (configuration du serveur DHCP de m2)
[Consulter l’énoncé]
1. Le fichier après la modification :
m2:~# cat /etc/default/dhcp3-server
# Defaults for dhcp initscript
# sourced by /etc/init.d/dhcp
# installed at /etc/default/dhcp3-server by the maintainer scripts
#
# This is a POSIX shell fragment
#
# On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
# Separate multiple interfaces with spaces, e.g. "eth0 eth1".
INTERFACES="eth0"
2. Le fichier (extrait) après les modifications : m2:~# cat /etc/dhcp3/dhcpd.conf ...
ddns-update-style none;
# option definitions common to all supported networks...
option domain-name "iut.univ-aix.fr";
option domain-name-servers 139.124.1.2;
default-lease-time 600;
max-lease-time 7200;
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;
# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
# log-facility local7;
# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.
subnet 10.0.2.0 netmask 255.255.255.0 { range 10.0.2.120 10.0.2.150;
option routers 10.0.2.2;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.2.255;
host vmxp {
hardware ethernet 08:00:26:66:20:13;
fixed-address 10.0.2.20;
} } ...
ê
Si la VM Windows XP a effectivement pour adresses MAC08:00:26:66:20:13 3. m2:~# /etc/init.d/dhcp3-server startStarting DHCP server: dhcpd3.
2.2 Configuration des clients DHCP
Corrigé de l’exercice 12 (configuration temporaire du client DHCP de m1)
[Consulter l’énoncé]
1. m1:~# dhclient eth0
Internet Systems Consortium DHCP Client V3.1.1 Copyright 2004-2008 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/
Listening on LPF/eth0/02:04:06:22:ab:24 Sending on LPF/eth0/02:04:06:22:ab:24 Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 DHCPOFFER from 10.0.2.10
DHCPREQUEST on eth0 to 255.255.255.255 port 67 DHCPACK from 10.0.2.10
bound to 10.0.2.120 -- renewal in 273 seconds.
2. m1:~# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 02:04:06:22:ab:24
inet addr:10.0.2.120 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::4:6ff:fe22:ab24/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:263 errors:0 dropped:0 overruns:0 frame:0 TX packets:275 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000
RX bytes:9742 (9.5 KiB) TX bytes:12971 (12.6 KiB) Interrupt:5
m1:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
m1:~# cat /etc/resolv.conf domain iut.univ-aix.fr search iut.univ-aix.fr nameserver 139.124.1.2 m1:~#
ê
Tout ce qu’on a fait jusqu’à présent surm1devrait continuer de fonctionner.Corrigé de l’exercice 13 (configuration du client DHCP de la VM Windows)
[Consulter l’énoncé]
1. il faut configurer l’interface via DHCP :
C:>netsh int ip set address "Connexion au réseau local" dhcp Ok.
2. C:>ipconfig
Configuration IP de Windows
Carte Ethernet Connexion au réseau local:
Suffixe DNS propre à la connexion : iut.univ-aix.fr Adresse IP. . . : 10.0.2.20
Masque de sous-réseau . . . : 255.255.255.0 Passerelle par défaut . . . : 10.0.2.2
i
On peut aussi utiliseripconfig/allpour avoir plus de détails sur la configuration.C:>route print
===========================================================================
Liste d'Interfaces
0x1 ... MS TCP Loopback interface
0x2 ...08 00 27 71 76 54 ... Carte AMD PCNET Family Ethernet PCI - Mini...
===========================================================================
===========================================================================
Itinéraires actifs :
Destination réseau Masque réseau Adr. passerelle Adr. interface Métrique
0.0.0.0 0.0.0.0 10.0.2.2 10.0.2.20 20
10.0.2.0 255.255.255.0 10.0.2.20 10.0.2.20 20 10.0.2.20 255.255.255.255 127.0.0.1 127.0.0.1 20 10.0.2.255 255.255.255.255 10.0.2.20 10.0.2.20 20
127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1
224.0.0.0 240.0.0.0 10.0.2.20 10.0.2.20 20
255.255.255.255 255.255.255.255 10.0.2.20 10.0.2.20 1 Passerelle par défaut : 10.0.2.2
===========================================================================
Itinéraires persistants : Aucun
Corrigé de l’exercice 14 (configuration permanente du client DHCP de m1)
[Consulter l’énoncé]
1. Au même titre que la VM XP précédemment, il faut ajouter une entréehostpourm1: host m1 {
hardware ethernet 02:04:06:22:ab:24;
fixed-address 10.0.2.15;
}
2. Après redémarrage : m1:~# ifconfig
eth0 Link encap:Ethernet HWaddr 02:04:06:22:ab:24 inet6 addr: fe80::4:6ff:fe22:ab24/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1 errors:0 dropped:0 overruns:0 frame:0 ...
ê
la configuration n’a pas été obtenue 3. . . . pas de corrigé pour cette question. . .4. . . . pas de corrigé pour cette question. . . 5. Après redémarrage :
m1:~# ifconfig
eth0 Link encap:Ethernet HWaddr 02:04:06:22:ab:24
inet addr:10.0.2.120 Bcast:10.0.2.255 Mask:255.255.255.0 inet6 addr: fe80::4:6ff:fe22:ab24/64 Scope:Link
...
m1:~# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0
3 Le courrier électronique
3.1 Clients de messagerie
Il ne devrait pas y avoir besoin de corrigé. . .
3.2 Format d’un message électronique 3.3 SMTP
3.3.1 Messages du protocole SMTP 3.3.2 Exercice
Corrigé de l’exercice 16 (Envoi du message anonyme)
[Consulter l’énoncé]
$ telnet allegro 25
Trying 139.124.181.131...
Connected to allegro.aix.univ-amu.fr.
Escape character is '^]'.
220 allegro.iut.univ-aix.fr ESMTP Postfix (Debian/GNU) HELO mamachine.com
250 allegro.iut.univ-aix.fr MAIL FROM:<tarzan@jungle.org>
250 2.1.0 Ok RCPT TO:<cpb>
250 2.1.5 Ok DATA
354 End data with <CR><LF>.<CR><LF>
From: Tarzan of the Jungle <tarzan@jungle.org>
To: Cyril Pain-Barre <cpb@allegro>
Subject: Un message super interessant blablabla le message anonyme
et patati et patata .
250 2.0.0 Ok: queued as CDCCBF975 QUIT
221 2.0.0 Bye
Connection closed by foreign host.
$
Si on consulte ce message par mail, voici ça donne :
mailx version nail 11.25 7/29/05. Type ? for help.
"/var/spool/mail/cpb": 1 message 1 new
>N 1 Tarzan of the Jung Tue May 13 10:51 16/619 Un message super interessant
? 1
Message 1:
From tarzan@jungle.org Tue May 13 10:51:50 2008 Return-Path: <tarzan@jungle.org>
X-Original-To: cpb
Delivered-To: cpb@allegro.iut.univ-aix.fr From: Tarzan of the Jungle <tarzan@jungle.org>
To: Cyril Pain-Barre <cpb@allegro.iut.univ-aix.fr>
Subject: Un message super interessant
Date: Tue, 13 May 2008 10:48:53 +0200 (CEST) Status: R
blablabla le message anonyme et patati et patata
? x
Si on le récupère par Thunderbird et qu’on double-clique dessus, voici ce que l’on obtient :
3.4 Étude de la RFC de POP3
Corrigé de l’exercice 17 (récupération de messages avec POP3)
[Consulter l’énoncé]
Voici la trace de la discussion avec le serveur POP3 d’allegro, en supposant qu’il y a 4 messages dans la boîte aux lettres et que le message anonyme est le dernier :
$ telnet allegro 110 Trying 139.124.181.131...
Connected to allegro.aix.univ-amu.fr.
Escape character is '^]'.
+OK USER cpb +OK
PASS mon-mot-de-passe +OK
LIST +OK 1 470 2 390 3 281 4 455 . RETR 4 +OK
Return-Path: <tarzan@jungle.org>
X-Original-To: cpb
Delivered-To: cpb@allegro.iut.univ-aix.fr
Received: from mamachine.com (a73.iut.univ-aix.fr [139.124.187.73]) by allegro.iut.univ-aix.fr (Postfix) with SMTP id CDCCBF975
for <cpb>; Mon, 29 Dec 2014 16:45:54 +0100 (CET) From: Tarzan of the Jungle <tarzan@jungle.org>
To: Cyril Pain-Barre <cpb@allegro>
Subject: Un message super interessant blablabla le message anonyme
et patati et patata .
DELE 4 +OK QUIT +OK
Connection closed by foreign host.