Corrige tp3 m3102_dut2

22
UE31 - M3102 : Services Réseaux 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 de gftp devrait ressembler à celle de la figure 1. FIGURE 1 Transfert de fichier par FTP réalisé avec gftp IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

Transcript of Corrige tp3 m3102_dut2

UE31 - M3102 : Services RéseauxCorrigé 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 de gftp devrait ressembler à celle dela figure 1.

FIGURE 1 – Transfert de fichier par FTP réalisé avec gftp

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 2/22

Corrigé de l’exercice 2 (Session FTP en mode texte à allegro)[Consulter l’énoncé]

toto@pc$ ftp allegroConnected 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): etxxxx331 Password required for etxxxx.Password: mon password230- Linux allegro 2.6.32-5-686 #1 SMP Sat May 5 01:33:08 UTC 2012 i686230-230- The programs included with the Debian GNU/Linux system are free software;230- the exact distribution terms for each program are described in the230- individual files in /usr/share/doc/*/copyright.230-230- Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent230- permitted by applicable law.230 User etxxxx logged in.Remote system type is UNIX.Using binary mode to transfer files.ftp>

1. ftp> passivePassive mode on.

2. ftp> cd /home/cpb/public/unix250 CWD command successful.ftp> dir227 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> bin200 Type set to I.

ê le fichier à transférer est de type binaire

ftp> get bart.giflocal: bart.gif remote: bart.gif227 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> ascii200 Type set to A.

ê cette fois, le fichier à déposer est un fichier texte

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

3/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

ftp> put un-fichier.txtlocal: un-fichier.txt remote: un-fichier.txt227 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> bye221 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.orgConnected to ftp.rfc-editor.org.220 "FTP Server Ready"Name (ftp.rfc-editor.org:toto): anonymous331 Please specify the password.Password: [email protected] Login successful.Remote system type is UNIX.Using binary mode to transfer files.ftp>

1. ftp> passivePassive mode on.

2. ftp> cd in-notes250 Directory successfully changed.

3. ftp> hashHash mark printing on (1024 bytes/hash mark).ftp> ascii200 Switching to ASCII mode.ftp> get rfc1939.txtlocal: rfc1939.txt remote: rfc1939.txt227 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> bye221 Goodbye.

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 4/22

1.8 Exercices

Corrigé de l’exercice 4 (Transfert manuel en mode passif)[Consulter l’énoncé]

toto@pc$ telnet ftp.rfc-editor.org 21Trying 4.31.198.49...Connected to ftp.rfc-editor.org.Escape character is '^]'.220 "FTP Server Ready"USER anonymous331 Please specify the password.PASS [email protected] Login successful.CWD in-notes250 Directory successfully changed.TYPE A200 Switching to ASCII mode.PASV227 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ésentre parenthèses dans la ligne ci-dessus. Pour cela, on utilise nc (et un peu de shell) dans un autreterminal :

$ nc 4.31.198.49 $((117*256+68)) > rfc821.txt

ê où $((117*256+68)) demande à bash de calculer le port (30020), et où on redirigela sortie de nc dans le fichier de notre choix (rfc821.txt)

RETR rfc821.txt150 Opening ASCII mode data connection for rfc821.txt (120432 bytes).226 Transfer complete.

ê à ce stade, le transfert est terminé, nc s’arrête, et le fichier rfc821.txt a é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. . .

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

5/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

4. m2:~# apt-get updateIgn http://ftp.fr.debian.org lenny Release.gpgIgn 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-serverftpd-ssl - FTP server with SSL encryption supportftpd - File Transfer Protocol (FTP) server...wu-ftpd - powerful and widely used FTP server...proftpd-basic - versatile, virtual-hosting FTP daemon - binariesvsftpd - The Very Secure FTP Daemon

6. m2:~# apt-get install proftpd-basicReading package lists... DoneBuilding dependency treeReading 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]? yGet: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 startStarting ftp server: proftpd.

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 6/22

8. m2:~# netstat -tlnActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp 0 0 0.0.0.0:58917 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:4459 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:111 0.0.0.0:* LISTENtcp 0 0 0.0.0.0:113 0.0.0.0:* LISTENtcp6 0 0 :::21 :::* LISTENtcp6 0 0 :::22 :::* LISTEN

ê Les options utilisées sont -t pour TCP, -l pour les serveurs en écoute (listen), et -n pour garderles adresses et les ports sous forme numérique. Ca n’a pas d’importance mais on peut aussiremarquer que le serveur utilise une adresse d’écoute IPv6 (mais qui comprend IPv4).

9. Une recherche de la chaîne ftp dans le fichier suffit :m2:~# grep -i ftp /etc/servicesftp-data 20/tcpftp 21/tcptftp 69/udpsftp 115/tcpftps-data 989/tcp # FTP over SSL (data)ftps 990/tcpvenus-se 2431/udp # udp sftp side effectcodasrv-se 2433/udp # udp sftp side effectfrox 2121/tcp # frox: caching ftp proxyzope-ftp 8021/tcp # zope management by ftp

ê les ports concernés sont mis en évidence en gras

Corrigé de l’exercice 6 (Autoriser l’accès à root)[Consulter l’énoncé]

1.

- D’abord, il faut configurer m1 :m1:~# ifconfig eth0 10.0.2.15/24m1:~# route add default gw 10.0.2.2

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):331 Password required for rootPassword:530 Login incorrect.Login failed.Remote system type is UNIX.Using binary mode to transfer files.ftp> quit221 Goodbye.

ê En effet, le login root a échoué

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

7/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

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).

# rootdaemon...

(b) La portion du fichier modifié devrait contenir les lignes :

...# DefaultRoot ~

# Autoriser le login rootRootLogin on

...

(c) m2:~# /etc/init.d/proftpd stopStopping ftp server: proftpd.m2:~# /etc/init.d/proftpd startStarting ftp server: proftpd.

- on aurait pu aussi taper la seule commande :m2:~# /etc/init.d/proftpd restartStopping ftp server: proftpd.Starting ftp server: proftpd.

3. 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):331 Password required for rootPassword:230 User root logged inRemote system type is UNIX.Using binary mode to transfer files.ftp> dir200 PORT command successful150 Opening ASCII mode data connection for file listdrwx------ 2 root root 4096 Sep 15 2007 Desktopdrwxr-xr-x 2 root root 4096 Sep 5 2007 tmp226 Transfer completeftp> quit221 Goodbye.

4. . . . pas de corrigé pour cette question. . .

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 8/22

Corrigé de l’exercice 7 (Autoriser l’accès aux utilisateurs)[Consulter l’énoncé]

1. m2:~# adduser totoAdding 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: totoRetype new UNIX password: totopasswd: password updated successfullyChanging the user information for totoEnter the new value, or press ENTER for the default

Full Name []:Room Number []:Work Phone []:Home Phone []:Other []:

Is the information correct? [y/N] ym2:~# adduser titiAdding user `titi' ......m2:~#

2. m1:~# pwd/rootm1:~# lsDesktop tmp

ê pour le moment, il n’y a que deux répertoires dans le répertoire personnel de root sur m1

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): toto331 Password required for totoPassword:230 User toto logged inRemote system type is UNIX.Using binary mode to transfer files.

ê le login de toto a bien été accepté

ftp> pwd257 "/home/toto" is the current directoryftp> dir200 PORT command successful150 Opening ASCII mode data connection for file list226 Transfer complete

ê son répertoire personnel est vide sur m2

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

9/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

ftp> put /etc/passwd passwdlocal: /etc/passwd remote: passwd200 PORT command successful150 Opening BINARY mode data connection for passwd226 Transfer complete1091 bytes sent in 0.00 secs (5667.2 kB/s)ftp> dir200 PORT command successful150 Opening ASCII mode data connection for file list-rw-r--r-- 1 toto toto 1091 Dec 29 12:25 passwd226 Transfer complete

ê toto peut y déposer un fichier

ftp> get passwd mypassswdlocal: mypassswd remote: passwd200 PORT command successful150 Opening BINARY mode data connection for passwd (1091 bytes)226 Transfer complete1091 bytes received in 0.00 secs (716.5 kB/s)ftp> ! ls -ltotal 12drwx------ 2 root root 4096 2007-09-15 13:22 Desktop-rw-r--r-- 1 root root 1091 2014-12-29 13:26 mypassswddrwxr-xr-x 2 root root 4096 2007-09-05 18:00 tmpftp>

ê et peut aussi en télécharger ; les transferts fonctionnent bien dans les deux sens.

3. ftp> cd ..250 CWD command successfulftp> dir200 PORT command successful150 Opening ASCII mode data connection for file listdrwxr-xr-x 2 ftp nogroup 4096 Dec 29 11:09 ftpdrwxr-xr-x 2 titi titi 4096 Dec 29 12:23 titidrwxr-xr-x 2 toto toto 4096 Dec 29 12:25 toto226 Transfer completeftp> cd ftp250 CWD command successfulftp> dir200 PORT command successful150 Opening ASCII mode data connection for file list-rw-r--r-- 1 root root 170 Nov 16 2011 welcome.msg226 Transfer completeftp> get welcome.msglocal: welcome.msg remote: welcome.msg200 PORT command successful150 Opening BINARY mode data connection for welcome.msg (170 bytes)226 Transfer complete170 bytes received in 0.00 secs (532.1 kB/s)ftp> ! lsDesktop mypassswd tmp welcome.msg

ê effectivement, toto peut se balader dans l’arborescence et télécharger des fichiers

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 10/22

4. La portion du fichier concernée devient donc :...# Use this to jail all users in their homesDefaultRoot ~...

5. ftp> open 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): toto331 Password required for totoPassword: toto230 User toto logged inRemote system type is UNIX.Using binary mode to transfer files.ftp> dir200 PORT command successful150 Opening ASCII mode data connection for file list-rw-r--r-- 1 toto toto 1091 Dec 29 12:25 passwd226 Transfer completeftp> cd ..250 CWD command successfulftp> dir200 PORT command successful150 Opening ASCII mode data connection for file list-rw-r--r-- 1 toto toto 1091 Dec 29 12:25 passwd226 Transfer complete

ê tiens ? en redescendant, on a le même contenu ?

ftp> pwd257 "/" is the current directory

ê en effet, car toto se situe à la "racine", c’est à dire son répertoire personnel. . .

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

11/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

Corrigé de l’exercice 8 (Autoriser le login anonyme)[Consulter l’énoncé]

1. La portion du fichier modifiée devient :

<Anonymous ~ftp>User ftpGroup 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 userDirFakeUser on ftpDirFakeGroup on ftp

RequireValidShell off

# Limit the maximum number of anonymous loginsMaxClients 10

# We want 'welcome.msg' displayed at login, and '.message' displayed# in each newly chdired directory.DisplayLogin welcome.msgDisplayChdir .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.10Connected to 10.0.2.10.220 ProFTPD 1.3.1 Server (Debian) [::ffff:10.0.2.10]Name (10.0.2.10:root): anonymous331 Anonymous login ok, send your complete email address as your passwordPassword:230-Welcome, archive user anonymous@::ffff:10.0.2.15 !

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 12/22

230-230-The local time is: Tue Dec 23 17:54:06 2014230-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 applyRemote system type is UNIX.Using binary mode to transfer files.ftp>

4. ftp> dir200 PORT command successful150 Opening ASCII mode data connection for file list-rw-r--r-- 1 ftp ftp 170 Nov 16 2011 welcome.msg226 Transfer completeftp> ascii200 Type set to Aftp> get welcome.msglocal: welcome.msg remote: welcome.msg200 PORT command successful150 Opening ASCII mode data connection for welcome.msg (170 bytes)226 Transfer complete177 bytes received in 0.00 secs (442.1 kB/s)ftp> ! cat welcome.msgWelcome, 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 passwdlocal: passwd remote: passwd200 PORT command successful550 passwd: No such file or directory

ê en effet, le transfert est refusé

6. m2:~# cp /etc/services /home/ftpm2:~# ls -l /home/ftptotal 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 de m1 :ftp> dir200 PORT command successful150 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.msg226 Transfer complete

8. Sur m2 :m2:~# mkdir /home/ftp/incomingm2:~# ls -ld /home/ftp/incomingdrwxr-xr-x 2 root root 4096 2014-12-29 15:06 /home/ftp/incoming

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

13/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

et sur la session FTP de m1 :ftp> dir200 PORT command successful150 Opening ASCII mode data connection for file listdrwxr-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.msg226 Transfer complete

ê le répertoire incoming est bien présent

ftp> put /etc/protocols incoming/protocolslocal: /etc/protocols remote: incoming/protocols200 PORT command successful550 incoming/protocols: Permission denied

ê mais on ne peut y déposer un fichier

9. On peut observer que ce sont les identités indiquées dans la partie <Anonymous ~ftp> du fichier deconfiguration. . .

10. ftp> put /etc/protocols incoming/protocolslocal: /etc/protocols remote: incoming/protocols200 PORT command successful150 Opening BINARY mode data connection for incoming/protocols226 Transfer complete2510 bytes sent in 0.00 secs (6846.8 kB/s)ftp> dir incoming200 PORT command successful150 Opening ASCII mode data connection for file list-rw-r--r-- 1 ftp ftp 2510 Dec 29 14:11 protocols226 Transfer complete

ê le fichier a bien été déposé sur le serveur

11. ftp> get incoming/protocols zefilelocal: zefile remote: incoming/protocols200 PORT command successful550 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 fichier

12. 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>

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 14/22

Et enfin redémarrer le serveur :m2:/home/ftp# /etc/init.d/proftpd restartStopping ftp server: proftpd.Starting ftp server: proftpd.

13. On rouvre une session FTP :ftp> open 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): anonymous331 Anonymous login ok, send your complete email address as your passwordPassword:230-Welcome, archive user anonymous@::ffff:10.0.2.15 !230-230-The local time is: Mon Dec 29 15:18:20 2014230-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 applyRemote system type is UNIX.Using binary mode to transfer files.ftp> dir incoming200 PORT command successful150 Opening ASCII mode data connection for file list-rw-r--r-- 1 ftp ftp 2510 Dec 29 14:11 protocols226 Transfer completeftp> get incoming/protocols ze-filelocal: ze-file remote: incoming/protocols200 PORT command successful150 Opening BINARY mode data connection for incoming/protocols (2510 bytes)226 Transfer complete2510 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/protocols200 PORT command successful550 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 supprimer

ftp> append /etc/passwd incoming/protocolslocal: /etc/passwd remote: incoming/protocols200 PORT command successful550 incoming/protocols: No such file or directory

ê on ne peut pas non plus lui ajouter du contenu

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

15/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

ftp> put /etc/passwd incoming/truclocal: /etc/passwd remote: incoming/truc200 PORT command successful150 Opening BINARY mode data connection for incoming/truc226 Transfer complete1091 bytes sent in 0.00 secs (7102.9 kB/s)ftp> dir incoming200 PORT command successful150 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 truc226 Transfer complete

ê on peut toujours déposer un fichier

ftp> rename incoming/truc incoming/passwd350 File or directory exists, ready for destination name550 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 port 21 donc :

m1:~# telnet 10.0.2.10 21Trying 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 toto331 Password required for totoPASS toto230 User toto logged in

3.

4. $ nc -l -p 12345

5. PORT 10,0,2,15,48,57200 PORT command successful

6. LIST150 Opening ASCII mode data connection for file list226 Transfer complete

ê le serveur de m2 envoie le contenu du répertoire sur la connexion de données, établie avec nc(mode actif)

7. QUIT221 Goodbye.Connection closed by foreign host.m1:~#

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 16/22

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.

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

17/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

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 MAC 08: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 eth0Internet Systems Consortium DHCP Client V3.1.1Copyright 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:24Sending on LPF/eth0/02:04:06:22:ab:24Sending on Socket/fallbackDHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3DHCPOFFER from 10.0.2.10DHCPREQUEST on eth0 to 255.255.255.255 port 67DHCPACK from 10.0.2.10bound to 10.0.2.120 -- renewal in 273 seconds.

2. m1:~# ifconfig eth0eth0 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.0inet6 addr: fe80::4:6ff:fe22:ab24/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX packets:263 errors:0 dropped:0 overruns:0 frame:0TX packets:275 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:1000RX bytes:9742 (9.5 KiB) TX bytes:12971 (12.6 KiB)Interrupt:5

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 18/22

m1:~# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth00.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0m1:~# cat /etc/resolv.confdomain iut.univ-aix.frsearch iut.univ-aix.frnameserver 139.124.1.2m1:~#

ê Tout ce qu’on a fait jusqu’à présent sur m1 devrait 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" dhcpOk.

2. C:>ipconfig

Configuration IP de Windows

Carte Ethernet Connexion au réseau local:

Suffixe DNS propre à la connexion : iut.univ-aix.frAdresse IP. . . . . . . . . . . . : 10.0.2.20Masque de sous-réseau . . . . . . : 255.255.255.0Passerelle par défaut . . . . . . : 10.0.2.2

i On peut aussi utiliser ipconfig/all pour avoir plus de détails sur la configuration.

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

19/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

C:>route print===========================================================================Liste d'Interfaces0x1 ........................... MS TCP Loopback interface0x2 ...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 2010.0.2.0 255.255.255.0 10.0.2.20 10.0.2.20 2010.0.2.20 255.255.255.255 127.0.0.1 127.0.0.1 2010.0.2.255 255.255.255.255 10.0.2.20 10.0.2.20 20127.0.0.0 255.0.0.0 127.0.0.1 127.0.0.1 1224.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 1Passerelle 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ée host pour m1 :host m1 {

hardware ethernet 02:04:06:22:ab:24;fixed-address 10.0.2.15;

}

2. Après redémarrage :m1:~# ifconfigeth0 Link encap:Ethernet HWaddr 02:04:06:22:ab:24

inet6 addr: fe80::4:6ff:fe22:ab24/64 Scope:LinkUP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1RX 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:~# ifconfigeth0 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.0inet6 addr: fe80::4:6ff:fe22:ab24/64 Scope:Link

...

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 20/22

m1:~# route -nKernel IP routing tableDestination Gateway Genmask Flags Metric Ref Use Iface10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth00.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 eth0

3 Le courrier électronique

3.1 Clients de messagerieIl ne devrait pas y avoir besoin de corrigé. . .

3.2 Format d’un message électronique

3.3 SMTP3.3.1 Messages du protocole SMTP

3.3.2 Exercice

Corrigé de l’exercice 16 (Envoi du message anonyme)[Consulter l’énoncé]

$ telnet allegro 25Trying 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.com250 allegro.iut.univ-aix.frMAIL FROM:<[email protected]>250 2.1.0 OkRCPT TO:<cpb>250 2.1.5 OkDATA354 End data with <CR><LF>.<CR><LF>From: Tarzan of the Jungle <[email protected]>To: Cyril Pain-Barre <cpb@allegro>Subject: Un message super interessant

blablabla le message anonymeet patati et patata.250 2.0.0 Ok: queued as CDCCBF975QUIT221 2.0.0 ByeConnection closed by foreign host.$

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix

21/22 Corrige du TP 3 UE31 - M3102 : Services Reseaux

Si on consulte ce message par mail, voici ça donne :$ mailmailx 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? 1Message 1:From [email protected] Tue May 13 10:51:50 2008Return-Path: <[email protected]>X-Original-To: cpbDelivered-To: [email protected]: Tarzan of the Jungle <[email protected]>To: Cyril Pain-Barre <[email protected]>Subject: Un message super interessantDate: Tue, 13 May 2008 10:48:53 +0200 (CEST)Status: R

blablabla le message anonymeet patati et patata

? x

Si on le récupère par Thunderbird et qu’on double-clique dessus, voici ce que l’on obtient :

IUT Aix-Marseille - INFO Aix 29/12/2014 - C. Pain-Barre

UE31 - M3102 : Services Reseaux Corrige du TP 3 22/22

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 auxlettres et que le message anonyme est le dernier :$ telnet allegro 110Trying 139.124.181.131...Connected to allegro.aix.univ-amu.fr.Escape character is '^]'.+OKUSER cpb+OKPASS mon-mot-de-passe+OKLIST+OK1 4702 3903 2814 455.RETR 4+OKReturn-Path: <[email protected]>X-Original-To: cpbDelivered-To: [email protected]: from mamachine.com (a73.iut.univ-aix.fr [139.124.187.73])by allegro.iut.univ-aix.fr (Postfix) with SMTP id CDCCBF975for <cpb>; Mon, 29 Dec 2014 16:45:54 +0100 (CET)From: Tarzan of the Jungle <[email protected]>To: Cyril Pain-Barre <cpb@allegro>Subject: Un message super interessant

blablabla le message anonymeet patati et patata.DELE 4+OKQUIT+OKConnection closed by foreign host.

C. Pain-Barre - 29/12/2014 IUT Aix-Marseille - INFO Aix