Iptable redirection vers serveur FTP

FW-PROXY:/etc/network/if-pre-up.d# tcpdump -pnvi eth1 port 21 or icmp
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
09:58:34.063359 IP (tos 0x0, ttl 63, id 53316, offset 0, flags [none], proto ICMP (1), length 60) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 512, seq 10241, length 40
09:58:34.133915 IP (tos 0x0, ttl 123, id 54337, offset 0, flags [none], proto ICMP (1), length 60) 212.27.48.                10 > 192.168.1.2: ICMP echo reply, id 512, seq 10241, length 40
09:58:35.069707 IP (tos 0x0, ttl 63, id 53317, offset 0, flags [none], proto ICMP (1), length 60) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 512, seq 10497, length 40
09:58:35.141104 IP (tos 0x0, ttl 123, id 54507, offset 0, flags [none], proto ICMP (1), length 60) 212.27.48.                10 > 192.168.1.2: ICMP echo reply, id 512, seq 10497, length 40
09:58:36.069445 IP (tos 0x0, ttl 63, id 53318, offset 0, flags [none], proto ICMP (1), length 60) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 512, seq 10753, length 40
09:58:36.142064 IP (tos 0x0, ttl 123, id 54680, offset 0, flags [none], proto ICMP (1), length 60) 212.27.48.                10 > 192.168.1.2: ICMP echo reply, id 512, seq 10753, length 40
09:58:37.069481 IP (tos 0x0, ttl 63, id 53319, offset 0, flags [none], proto ICMP (1), length 60) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 512, seq 11009, length 40
09:58:37.140901 IP (tos 0x0, ttl 123, id 54829, offset 0, flags [none], proto ICMP (1), length 60) 212.27.48.                10 > 192.168.1.2: ICMP echo reply, id 512, seq 11009, length 40
09:58:56.691667 IP (tos 0x0, ttl 9, id 65005, offset 0, flags [none], proto ICMP (1), length 284) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 12434, seq 8193, length 264
09:58:56.769115 IP (tos 0x0, ttl 123, id 57935, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48                .10 > 192.168.1.2: ICMP echo reply, id 12434, seq 8193, length 264
09:58:56.776071 IP (tos 0x0, ttl 9, id 65007, offset 0, flags [none], proto ICMP (1), length 284) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 12434, seq 8194, length 264
09:58:56.854163 IP (tos 0x0, ttl 123, id 57946, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48                .10 > 192.168.1.2: ICMP echo reply, id 12434, seq 8194, length 264
09:58:56.859103 IP (tos 0x0, ttl 9, id 65009, offset 0, flags [none], proto ICMP (1), length 284) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 12434, seq 8195, length 264
09:58:56.936218 IP (tos 0x0, ttl 123, id 57964, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48                .10 > 192.168.1.2: ICMP echo reply, id 12434, seq 8195, length 264
09:58:56.941476 IP (tos 0x0, ttl 9, id 65011, offset 0, flags [none], proto ICMP (1), length 284) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 12434, seq 8196, length 264
09:58:57.019245 IP (tos 0x0, ttl 123, id 57978, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48                .10 > 192.168.1.2: ICMP echo reply, id 12434, seq 8196, length 264
09:58:57.024255 IP (tos 0x0, ttl 9, id 65013, offset 0, flags [none], proto ICMP (1), length 284) 192.168.1.2                 > 212.27.48.10: ICMP echo request, id 12434, seq 8197, length 264
09:58:57.102015 IP (tos 0x0, ttl 123, id 57991, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48                .10 > 192.168.1.2: ICMP echo reply, id 12434, seq 8197, length 264
10:00:01.254185 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto ICMP (1), length 84) 192.168.1.2 > 192.168.1.1: ICMP echo request, id 12042, seq 1, length 64
10:00:01.255044 IP (tos 0x0, ttl 64, id 60565, offset 0, flags [none], proto ICMP (1), length 84) 192.168.1.1 > 192.168.1.2: ICMP echo reply, id 12042, seq 1, length 64
^C
20 packets captured
20 packets received by filter
0 packets dropped by kernel

C’est un ping sortant, ça.
Visiblement tu as lancé un ping depuis trois machines différentes (TTL et taille différentes). Une machine utilise un TTL initial de 10, ce qui est très bas pour communiquer sur internet car il y a souvent plus de 10 sauts entre deux points. Si c’est l’AS/400, cela pourrait expliquer l’absence de réponse reçue par le client.

Pourrais-tu refaire une capture avec les mêmes options de tcpdump sur eth0 ou eth1 (pas besoin des deux) lors d’une tentative de connexion FTP à l’AS/400, qu’on voie le TTL de ses réponses ?

Oui ca c’est un ping de l as400 vers IP de free:
Ci-dessous

FW-PROXY:/etc/network/if-pre-up.d# tcpdump -pnvi eth0 port 21 or icmp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:23:18.812899 IP (tos 0x0, ttl 10, id 1845, offset 0, flags [none], proto ICMP (1), length 284) 172.16.0.2 > 212.27.48.10: ICMP echo request, id 12434, seq 8193, length 264
10:23:18.894988 IP (tos 0x0, ttl 122, id 40969, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48.10 > 172.16.0.2: ICMP echo reply, id 12434, seq 8193, length 264
10:23:18.899937 IP (tos 0x0, ttl 10, id 1847, offset 0, flags [none], proto ICMP (1), length 284) 172.16.0.2 > 212.27.48.10: ICMP echo request, id 12434, seq 8194, length 264
10:23:18.982602 IP (tos 0x0, ttl 122, id 40989, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48.10 > 172.16.0.2: ICMP echo reply, id 12434, seq 8194, length 264
10:23:18.987484 IP (tos 0x0, ttl 10, id 1848, offset 0, flags [none], proto ICMP (1), length 284) 172.16.0.2 > 212.27.48.10: ICMP echo request, id 12434, seq 8195, length 264
10:23:19.064371 IP (tos 0x0, ttl 122, id 41002, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48.10 > 172.16.0.2: ICMP echo reply, id 12434, seq 8195, length 264
10:23:19.069284 IP (tos 0x0, ttl 10, id 1850, offset 0, flags [none], proto ICMP (1), length 284) 172.16.0.2 > 212.27.48.10: ICMP echo request, id 12434, seq 8196, length 264
10:23:19.146344 IP (tos 0x0, ttl 122, id 41017, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48.10 > 172.16.0.2: ICMP echo reply, id 12434, seq 8196, length 264
10:23:19.151229 IP (tos 0x0, ttl 10, id 1851, offset 0, flags [none], proto ICMP (1), length 284) 172.16.0.2 > 212.27.48.10: ICMP echo request, id 12434, seq 8197, length 264
10:23:19.229435 IP (tos 0x0, ttl 122, id 41035, offset 0, flags [none], proto ICMP (1), length 284) 212.27.48.10 > 172.16.0.2: ICMP echo reply, id 12434, seq 8197, length 264
^C
10 packets captured
10 packets received by filter
0 packets dropped by kernel
FW-PROXY:/etc/network/if-pre-up.d# tcpdump -pnvi eth0 port 21 or icmp
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes
10:37:25.226992 IP (tos 0x0, ttl 118, id 31588, offset 0, flags [DF], proto TCP (6), length 48) 80.13.102.25.17334 > 172.16.0.2.21: S, cksum 0x2ff5 (correct), 2015302927:2015302927(0) win 8192 <mss 1452,nop,nop,sackOK>
10:37:25.248564 IP (tos 0x0, ttl 10, id 3081, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334: S, cksum 0x5eb8 (correct), 3280938551:3280938551(0) ack 2015302928 win 8192 <mss 536>
10:37:25.866488 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3081, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334:  tcp 24 [bad hdr length 0 - too short, < 20]
10:37:27.849829 IP (tos 0x0, ttl 118, id 31629, offset 0, flags [DF], proto TCP (6), length 48) 80.13.102.25.17334 > 172.16.0.2.21: S, cksum 0x2ff5 (correct), 2015302927:2015302927(0) win 8192 <mss 1452,nop,nop,sackOK>
10:37:28.372633 IP (tos 0x0, ttl 10, id 3086, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334: S, cksum 0x5eb8 (correct), 3280938551:3280938551(0) ack 2015302928 win 8192 <mss 536>
10:37:28.497490 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3086, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334:  tcp 24 [bad hdr length 0 - too short, < 20]
10:37:33.785275 IP (tos 0x0, ttl 118, id 31696, offset 0, flags [DF], proto TCP (6), length 48) 80.13.102.25.17341 > 172.16.0.2.21: S, cksum 0xf785 (correct), 1139900837:1139900837(0) win 8192 <mss 1452,nop,nop,sackOK>
10:37:33.786495 IP (tos 0x0, ttl 10, id 3100, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341: S, cksum 0xa374 (correct), 3283069163:3283069163(0) ack 1139900838 win 8192 <mss 536>
10:37:33.852140 IP (tos 0x0, ttl 118, id 31698, offset 0, flags [DF], proto TCP (6), length 48) 80.13.102.25.17334 > 172.16.0.2.21: S, cksum 0x2ff5 (correct), 2015302927:2015302927(0) win 8192 <mss 1452,nop,nop,sackOK>
10:37:33.856081 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3100, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341:  tcp 24 [bad hdr length 0 - too short, < 20]
10:37:34.568755 IP (tos 0x0, ttl 10, id 3102, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334: S, cksum 0x5eb8 (correct), 3280938551:3280938551(0) ack 2015302928 win 8192 <mss 536>
10:37:34.637139 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3102, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334:  tcp 24 [bad hdr length 0 - too short, < 20]
10:37:36.788214 IP (tos 0x0, ttl 118, id 31743, offset 0, flags [DF], proto TCP (6), length 48) 80.13.102.25.17341 > 172.16.0.2.21: S, cksum 0xf785 (correct), 1139900837:1139900837(0) win 8192 <mss 1452,nop,nop,sackOK>
10:37:36.910623 IP (tos 0x0, ttl 10, id 3105, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341: S, cksum 0xa374 (correct), 3283069163:3283069163(0) ack 1139900838 win 8192 <mss 536>
10:37:37.047205 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3105, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341:  tcp 24 [bad hdr length 0 - too short, < 20]
10:37:42.792196 IP (tos 0x0, ttl 118, id 31831, offset 0, flags [DF], proto TCP (6), length 48) 80.13.102.25.17341 > 172.16.0.2.21: S, cksum 0xf785 (correct), 1139900837:1139900837(0) win 8192 <mss 1452,nop,nop,sackOK>
10:37:43.106256 IP (tos 0x0, ttl 10, id 3120, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341: S, cksum 0xa374 (correct), 3283069163:3283069163(0) ack 1139900838 win 8192 <mss 536>
10:37:43.177328 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3120, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341:  tcp 24 [bad hdr length 0 - too short, < 20]
10:37:46.909071 IP (tos 0x0, ttl 10, id 3125, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334: S, cksum 0x5eb8 (correct), 3280938551:3280938551(0) ack 2015302928 win 8192 <mss 536>
10:37:46.980102 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3125, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334:  tcp 24 [bad hdr length 0 - too short, < 20]
10:37:55.446084 IP (tos 0x0, ttl 10, id 3136, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341: S, cksum 0xa374 (correct), 3283069163:3283069163(0) ack 1139900838 win 8192 <mss 536>
10:37:55.517495 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3136, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17341:  tcp 24 [bad hdr length 0 - too short, < 20]
10:38:11.536578 IP (tos 0x0, ttl 10, id 3158, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334: S, cksum 0x5eb8 (correct), 3280938551:3280938551(0) ack 2015302928 win 8192 <mss 536>
10:38:11.605181 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 3158, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334:  tcp 24 [bad hdr length 0 - too short, < 20]
^C
24 packets captured
24 packets received by filter
0 packets dropped by kernel
FW-PROXY:/etc/network/if-pre-up.d#

guigui69

C’est bien ce que je craignais. Dans la seconde capture, le troisième paquet

10:37:25.866488 IP (tos 0x0, ttl 120, id 0, offset 0, flags [none], proto ICMP (1), length 56) 80.10.215.86 > 172.16.0.2: ICMP time exceeded in-transit, length 36 IP (tos 0x0, ttl 1, id 3081, offset 0, flags [none], proto TCP (6), length 44) 172.16.0.2.21 > 80.13.102.25.17334: tcp 24 [bad hdr length 0 - too short, < 20]
est un message d’erreur ICMP provenant du routeur 80.10.215.86 signalant que le TTL du paquet de réponse émis par le serveur FTP a expiré.

Le TTL initial de l’AS/400 est trop bas, en conséquence la communication n’est possible qu’avec des machines suffisamment “proches” (à moins de 10 sauts). Il faut l’augmenter, une valeur de 64 serait confortable.

A défaut, il reste possible de trafiquer le TTL des paquets lors de leur passage à travers le firewall.

Note : cette règle empêche le traceroute (basé sur l’incrémentation progressive du TTL) de fonctionner depuis l’AS/400.

Au passage la box est hors de cause.

Merci je vais voir avec notre prestataire as400 pour augmenter ce ttl et je reply

Avant tu peux tester la règle iptables pour valider l’hypothèse.

Ok j’applique la règle et je reply après.

2 questions qui concerne iptables aussi:

Je voudrait mettre en place une QOS pour privilégié le protocole SMTP, pop.
Et je voudrait au niveau de http (web) mettre en place une répartition, dans le sens que si l’utilisateur est le seul sur internet cela prend la totalité de la bD passante, mais des qu’il y quelqu’un autre la bande passante est divisé.

Est-ce possible? vers quel outil je doit me tourner?

Merci

guigui69

Gestion de priorité et file d’attente. J’ai fait un script pour ça:

boisson.homeip.net/limiteur

J’ai rajouter la règle iptable et oui s’était bien ca le problème. avec celle la je suis arrivée jusqu’a l’as400.

Concernant ton script, je suis entrain de le lire et d’essayer le comprendre :frowning:

Est-il possible d’indiquer la BP en up et DL car cette gestion sera sur une connexion ADSL?

guigui69

Alors là, je dis bravo pour l’histoire du ttl, parce que c’était pas un diagnostic évident (pour moi en tout cas) :041
:clap:

Je n’y aurais pas pensé non plus a priori, n’ayant jamais vu de TTL initial si bas. Je ne sais pas si c’est la valeur par défaut de l’AS/400 ou si elle a été modifiée. Il a fallu que je voie la valeur du TTL dans une trace de tcpdump (avec l’option -v, les premières traces sans -v ne montrant pas ce champ). Je m’en serais rendu compte plus tôt aussi si j’avais demandé une trace de tout le trafic de l’AS/400, ou au moins incluant les paquets ICMP.

EDIT : mais… j’avais bien demandé de capturer les paquets ICMP depuis le début…

Guigui et François, je vous suggère d’ouvrir une nouvelle discussion pour la QoS, avec un titre approprié qui pourra attirer d’autres participants (pas moi, j’ai bien trop de lacunes dans ce domaine).

Ben tout de même, pour le TTL, chapeau quand même.

Pour le QoS, Guigui: ouvre un fil pour les questions. Pour ta question, il gère la bande passante en upload essentiellement dans le script mais il doit être facile de faire la même chose pour le traffic descendant

[quote=“PascalHambourg”]
[…]
(pas moi, j’ai bien trop de lacunes dans ce domaine).[/quote]
Mouhahaha, quel déconneur ce Pascal :laughing-rolling:

Bon, maintenant qu’on a bien rigolé, on se remet au boulot, hop hop hop :mrgreen: