---
# System prepended metadata

title: TP 1

---

# TP 1


## 1. Affichage d'informations sur la pile TCP/IP locale

### A. Affichage des infos des cartes réseau du PC


    
-    commande utilisé : 

    ip -a
    
-    résultat obtenue : 

    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: enp6s0f1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
        link/ether 98:28:a6:3a:7f:a8 brd ff:ff:ff:ff:ff:ff
    3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether d8:f2:ca:db:cf:77 brd ff:ff:ff:ff:ff:ff
        inet 10.33.1.22/22 brd 10.33.3.255 scope global dynamic noprefixroute wlp0s20f3
           valid_lft 3501sec preferred_lft 3501sec
        inet6 fe80::5994:e96e:da0:3a96/64 scope link noprefixroute 
           valid_lft forever preferred_lft forever

#### Nom, adresse MAC, adresse IP de l'interface WIFI : 

* **nom** : wlp0s20f3
* **adresse MAC** : d8:f2:ca:db:cf:77
* **adresse IP** : 10.33.1.22

#### Nom, adresse MAC, adresse IP de l'interface Ethernet : 

* **nom** : enp6s0f1
* **adresse MAC** : 98:28:a6:3a:7f:a8
* **adresse IP** : pas connecté 

### B. Affichage du gateway : 

-    commande utilisée : 

    netstat -nr
    
-    résultat obtenue : 

    Table de routage IP du noyau
    Destination     Passerelle      Genmask         Indic   MSS Fenêtre irtt Iface
        0.0.0.0         10.33.3.253     0.0.0.0         UG        0 0          0 wlp0s20f3
        10.33.0.0       0.0.0.0         255.255.252.0   U         0 0          0 wlp0s20f3
        169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 wlp0s20f3
        

#### affichage gateway 

- gateway : 10.33.3.253




### C.  affichage des informations sur une carte IP en GUI

- en bleue l'adresse IP
- en vert l'adresse MAC
- en rouge la gateway

![](https://i.imgur.com/0ECu1pk.png)

### D. explication de l'utilisté du gateway sur le réseau Ynov : 

sur le réseau Ynov le gateway permet de mettre en relation ma machine (réseau local) et le réseau d'Ynov (réseau internet)

## 2. Modifications des informations

### A. Modification d'adresse IP : 


- avant changement : 
```
3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d8:f2:ca:db:cf:77 brd ff:ff:ff:ff:ff:ff
    inet 10.33.1.22/22 brd 10.33.3.255 scope global dynamic noprefixroute wlp0s20f3
```

- après changement : 
```
3: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether d8:f2:ca:db:cf:77 brd ff:ff:ff:ff:ff:ff
    inet 10.33.1.21/22 brd 10.33.3.255 scope global noprefixroute wlp0s20f3
```
impossible d'accéder a internet après changement : 
![](https://i.imgur.com/WHjycD8.png)



### C. Modification d'adresse IP (part 2)

- commande utilisée : 
```
nmap -sn -PE 10.33.0.0/22
``` 
- résultat obtenue : 
```
Starting Nmap 7.60 ( https://nmap.org ) at 2020-01-23 14:17 CET
Stats: 0:00:16 elapsed; 0 hosts completed (0 up), 1024 undergoing Ping Scan
Ping Scan Timing: About 81.30% done; ETC: 14:18 (0:00:04 remaining)
Stats: 0:00:21 elapsed; 0 hosts completed (0 up), 1024 undergoing Ping Scan
Ping Scan Timing: About 91.60% done; ETC: 14:18 (0:00:02 remaining)
Stats: 0:00:26 elapsed; 0 hosts completed (0 up), 1024 undergoing Ping Scan
Ping Scan Timing: About 97.85% done; ETC: 14:18 (0:00:01 remaining)
Nmap scan report for 10.33.0.18
Host is up (0.0082s latency).
Nmap scan report for 10.33.0.25
Host is up (0.048s latency).
Nmap scan report for 10.33.0.29
Host is up (0.086s latency).
Nmap scan report for 10.33.0.36
Host is up (0.021s latency).
Nmap scan report for 10.33.0.37
Host is up (0.32s latency).
Nmap scan report for 10.33.0.45
Host is up (0.095s latency).
Nmap scan report for 10.33.0.55
Host is up (0.12s latency).
Nmap scan report for 10.33.0.66
Host is up (0.033s latency).
[...]
Nmap scan report for 10.33.3.197
Host is up (0.11s latency).
Nmap scan report for 10.33.3.201
Host is up (0.0064s latency).
Nmap scan report for 10.33.3.212
Host is up (0.12s latency).
Nmap scan report for 10.33.3.215
Host is up (0.010s latency).
Nmap scan report for 10.33.3.220
Host is up (0.049s latency).
Nmap scan report for 10.33.3.239
Host is up (0.075s latency).
Nmap scan report for 10.33.3.246
Host is up (0.012s latency).
Nmap scan report for _gateway (10.33.3.253)
Host is up (0.011s latency).
Nmap done: 1024 IP addresses (146 hosts up) scanned in 28.82 seconds

```
 comme on peut le voir grace a la commande nmap l'adresse 10.33.3.198 est libre car elle n'apparaît pas je peux donc la choisir
 
 - changement de la nouvelle adresse IP libre : 
![](https://i.imgur.com/4eNh7Ic.png)

après ce changement d'IP he n'ai plus accès a internet

## II. Exploration locale en duo : 

## prérequis 
aquis
## 2. Câblage 
cablage effectué via adaptateur usb to ethernet 

## 3. Modification d'adresse IP

modification de l'addresse IPv4 en /30


## 4. Utilisation d'un des deux comme gateway
- ma configuration :  
![](https://i.imgur.com/T1aqyC9.png)
- connexion du 2ème PC:
```
Carte Ethernet Ethernet 5 :

   Suffixe DNS propre à la connexion. . . :
   Adresse IPv6 de liaison locale. . . . .: fe80::b929:bcb6:9384:13aa%78
   Adresse IPv4. . . . . . . . . . . . . .: 192.168.137.1
   Masque de sous-réseau. . . . . . . . . : 255.255.255.0
   Passerelle par défaut. . . . . . . . . :
   ```


## 5. Petit chat privé
commande utilisé : 
```
netcat -l -p 3000
```
résultat obtenue 
![](https://i.imgur.com/EPnOjIW.png)


## 6. Wireshark
-message netcat reçu : 
![](https://i.imgur.com/2ZvP2oG.png)
-ping reponse : 
![](https://i.imgur.com/f5oDPmo.png)


## 7. Firewall
- firewall activé autorisation port 3000
```
netcat  192.168.137.1 3000
<jlvhsdbkl
adad
dvdvdvdvdvdvdvdv

```

- protocole ping bloqué : 
```
PING 3000 (0.0.11.184) 56(124) bytes of data.
^C
--- 3000 ping statistics ---
5 packets transmitted, 0 received, 100% packet loss, time 4072ms
```

- bloquer protocole ICMPv4 (le ping)
```
ping 192.168.137.1
PING 192.168.137.1 (192.168.137.1) 56(84) bytes of data.
^C
--- 192.168.137.1 ping statistics ---
11 packets transmitted, 0 received, 100% packet loss, time 10244ms
```


## III. Manipulations dautres outils/protocoles côté client

### 1. DHCP

 Affichage de l'adresse IP du serveur DHCP du réseau WiFi YNOV

- commande utilisé 
```
sudo dhclient -v wlan0
```
- Résultats
```
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/04:ea:56:21:65:4c
Sending on   LPF/wlan0/04:ea:56:21:65:4c
Sending on   Socket/fallback
DHCPREQUEST for 10.33.2.86 on wlan0 to 255.255.255.255 port 67
DHCPACK of 10.33.2.86 from 10.33.3.254
RTNETLINK answers: File exists
bound to 10.33.2.86 -- renewal in 1360 seconds.
```
- adresse IP : 
```
 10.33.3.254
```
Cette commande nous permet de demander une nouvelle adresse ip au serveur dhcp.
Ici, on remarque qu'il nous l'adresse ip : "10.33.2.86" de puis le serveur dhcp : "10.33.3.254"


- Pour exemple, avec NetworkManager, on peut faire cette commande :
```
cat dhclient-f6160ce6-9132-4c76-b7b2-9c6e9cbb88f1-wlan0.lease
```
- résultat 
```
lease {
  interface "wlan0";
  fixed-address 192.168.20.116;
  option subnet-mask 255.255.255.0;
  option wpad 22:a:22;
  option dhcp-lease-time 86400;
  option routers 192.168.20.1;
  option dhcp-message-type 5;
  option dhcp-server-identifier 192.168.20.1;
  option domain-name-servers 192.168.20.1;
  option dhcp-renewal-time 43200;
  option dhcp-rebinding-time 75600;
  option broadcast-address 192.168.20.255;
  option host-name "parrot";
  renew 4 2019/11/14 05:55:29;
  rebind 4 2019/11/14 17:19:08;
  expire 4 2019/11/14 20:19:08;
}
lease {
  interface "wlan0";
  fixed-address 192.168.20.116;
  option wpad 22:a:22;
  option subnet-mask 255.255.255.0;
  option routers 192.168.20.1;
  option dhcp-lease-time 86400;
  option dhcp-message-type 5;
  option domain-name-servers 192.168.20.1;
  option dhcp-server-identifier 192.168.20.1;
  option dhcp-renewal-time 43200;
  option broadcast-address 192.168.20.255;
  option dhcp-rebinding-time 75600;
  option host-name "parrot";
  renew 4 2019/11/14 08:38:29;
  rebind 4 2019/11/14 18:09:41;
  expire 4 2019/11/14 21:09:41;

```

- La ligne qui nous intéresse: 
```
renew 4 2019/11/14 08:38:29;
rebind 4 2019/11/14 18:09:41;
expire 4 2019/11/14 21:09:41;
```

- Demande d'une nouvelle adresse IP
- Commande utilisé
```
sudo dhclient -v wlan0
```
- résultat
```
 DHCPACK of 10.33.2.86 from 10.33.3.254
 ```

### 2. DNS

 Trouver l'ip serveur dns que notre ordi connait : 

- Commande utilisé
```
ip r | grep default
```
- Résultat obtenue
```
default via 10.33.3.253 dev wlan0
```
Notre ordinateur connait 10.33.3.253.

#### lookup
 lookup de google.com
- Commande utilisé
```
dig google.com
```
- Résultat obtenue
```
; <<>> DiG 9.11.5-P4-5.1+b1-Debian <<>> google.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 51547
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;google.com.			IN	A

;; ANSWER SECTION:
google.com.		245	IN	A	216.58.201.238

;; Query time: 4 msec
;; SERVER: 10.33.10.148#53(10.33.10.148)
;; WHEN: mer. janv. 22 10:05:44 CET 2020
;; MSG SIZE  rcvd: 55
```

serveur Dns de google : 216.58.201.238

Lookup de ynov.com
- Commande utilisé 
```
dig ynov.com
```
- Résultat obtenue
```
; <<>> DiG 9.11.5-P4-5.1+b1-Debian <<>> ynov.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58069
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;ynov.com.			IN	A

;; ANSWER SECTION:
ynov.com.		2329	IN	A	217.70.184.38

;; Query time: 5 msec
;; SERVER: 10.33.10.148#53(10.33.10.148)
;; WHEN: mer. janv. 22 10:15:34 CET 2020
;; MSG SIZE  rcvd: 53

```

serveur Dns de Ynov : 217.70.184.38

On remarque que les résultats sont différents car notre "odinateur" ne passe pas par le meme chemin pour aller sur google.com et sur Ynov.com

#### Reverse LOOKUP

reverse lookup de l'IP 78.74.21.21
- Commande utilisée
```
dig -x 78.74.21.21
```
- Résultat obtenue
```
; <<>> DiG 9.11.5-P4-5.1+b1-Debian <<>> -x 78.74.21.21
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45166
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;21.21.74.78.in-addr.arpa.	IN	PTR

;; ANSWER SECTION:
21.21.74.78.in-addr.arpa. 3490	IN	PTR	host-78-74-21-21.homerun.telia.com.

;; Query time: 5 msec
;; SERVER: 10.33.10.148#53(10.33.10.148)
;; WHEN: mer. janv. 22 10:20:48 CET 2020
;; MSG SIZE  rcvd: 101
```

Serveur : host-78-74-21-21.homerun.telia.com.

reverse Lookup de l'IP 92.146.54.88
- Commande utilisée
```
dig -x 92.146.54.88
```
- Résultat obtenue
```
; <<>> DiG 9.11.5-P4-5.1+b1-Debian <<>> -x 92.146.54.88
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 19911
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;88.54.146.92.in-addr.arpa.	IN	PTR

;; ANSWER SECTION:
88.54.146.92.in-addr.arpa. 3425	IN	PTR	apoitiers654-1-167-88.w92-146.abo.wanadoo.fr.

;; Query time: 6 msec
;; SERVER: 10.33.10.148#53(10.33.10.148)
;; WHEN: mer. janv. 22 10:22:12 CET 2020
;; MSG SIZE  rcvd: 113
```

Serveur : apoitiers654-1-167-88.w92-146.abo.wanadoo.fr.

Grace  à la commande dig -x (qui permet de faire un reverse lookup), on peut obtenir facilement le serveur derriere une adresse ip.



