issue204:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue204:c_c [2024/04/28 13:45] – auntiee | issue204:c_c [2024/04/30 14:58] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 7: | Ligne 7: | ||
I am not showing you guys the whole thing, as I have docker installed and that adds another section and I do not want to confuse you, so you do yours and we work from there.** | I am not showing you guys the whole thing, as I have docker installed and that adds another section and I do not want to confuse you, so you do yours and we work from there.** | ||
- | Dans ce numéro, j’aimerais continuer ma discussion | + | Dans ce numéro, j’aimerais continuer ma discussion |
sudo iptables -L | sudo iptables -L | ||
Ligne 15: | Ligne 15: | ||
Je ne vous en montre pas le tout, car, chez moi, docker est installé et cela ajoute une autre section. Je ne veux pas vous embrouiller, | Je ne vous en montre pas le tout, car, chez moi, docker est installé et cela ajoute une autre section. Je ne veux pas vous embrouiller, | ||
- | Because I’m in a virtual machine here, I use NAT, network address translation. | ||
- | We are not doing an in-depth look here, I just want newbies to recognise the patterns. When you look up the man page for iptables, you may notice | + | **Because I’m in a virtual machine |
- | I trust that you noticed that each of these has (policy ACCEPT) in parenthesis. This means that if a rule is not in our list, this is the elif. In other words, a fallback. Now a lot of the time, when newbies do not understand firewall rules, they start with (policy DROP). Don’t do that unless you are an advanced Linux user. Something I often see if I scroll through the command history is: sudo iptables -A INPUT -p tcp - -dport 22 j DROP | + | We are not doing an in-depth look here, I just want newbies to recognise |
- | What this usually means, is that someone new to firewalling, has read up on Fail2ban or some such and copied commands without understanding what they mean. | + | Puisque j’utilise une machine virtuelle ici, j’utilise NAT, network address translation (« traduction d’adresse réseau »). Nous pouvons regarder cette table-là aussi. Elle est différente, |
- | Let’s quickly dissect that line, shall we? The sudo iptables | + | Nous n’approfondissons pas les choses ici, je veux tout simplement que les débutants reconnaissent l’organisation des choses. Quand vous allez à la page man pour iptables, |
- | As we have demonstrated and you hopefully mimicked, you have realised that it is not hard to understand the syntax, and it is not hard to add rules, but you also need to understand what the rule you just implemented does or what it affects. | ||
- | On the other side of the coin, if you set your default policy to DROP, and you work on allow lists, all it takes, is someone to accidentally flush your rules. It is as simple as: sudo iptables -F. Though this clears all the rules, it does not reset the defaults back to the original defaults. This is another issue I have come across with novices, hence why I said not to start with DENY unless | + | **I trust that you noticed that each of these has (policy ACCEPT) in parenthesis. This means that if a rule is not in our list, this is the elif. In other words, a fallback. Now a lot of the time, when newbies do not understand firewall rules, they start with (policy DROP). Don’t do that unless you are an advanced Linux user. Something |
+ | What this usually means, is that someone new to firewalling, | ||
- | TIP: If you are learning, my advice to you is, play on a virtual machine on your system first and do whatever you need to and test if you can access it remotely, before mirroring your changes on a remote server. Set your history to 1000 lines, if you accidentally flush your rules, you can add them from history. Train your eye to look for DENY default rules. Remember that a server serves, it cannot do that if you deny all traffic. Sure, the intruders cannot get in, but neither can your clients. (if you would like to see this in action, look at the Digital Ocean forums, where devs have locked themselves out of their VPS’s, every other day!) | + | J'ose penser que vous avez remarqué que chacun comporte entre parenthèses « (policy ACCEPT) ». Cela veut dire que, si une règle ne se trouve pas dans notre liste, il s’agit du elif. En d’autres termes, une position de repli. Il se trouve que, quand les bleus ne comprennent pas les règles du pare-feu, ils commencent par (policy DROP). Ne le faites pas à moins d’être un utilisateur avancé de Linux. Ce que je vois souvent quand je parcours l’historique des commandes est : sudo iptables -A INPUT -p tcp -- dport 22 j DROP |
+ | |||
+ | Ce que cela signifie la plupart du temps, c'est que quelqu’un qui ne connaît pas les pare-feux a lu un truc sur Fail2ban ou autre et a copié des commandes sans les comprendre. | ||
+ | |||
+ | |||
+ | **Let’s quickly dissect that line, shall we? The sudo iptables is a given, the -A is for adding a rule, the -p is for the protocol, in this case, tcp and dashdash (Office packages and two dashes are not friends )dport is for destination port, in this case 22, then the j is for jump to and the action is DROP. This means that all tcp traffic on port 22 will now be dropped, but not udp traffic. This means that you may now notice that you can no longer transfer files via sctp. It may all be good, until 5 months down the line, you need to transfer a file and now you cannot. (Now comes the swearing like you saw in the previous issue. This is why companies have change requests that need to be signed off and documented, as you can see how this can become a huge problem, when multiple people are involved.) | ||
+ | |||
+ | As we have demonstrated and you hopefully mimicked, you have realised that it is not hard to understand the syntax, and it is not hard to add rules, but you also need to understand what the rule you just implemented does or what it affects.** | ||
+ | |||
+ | Analysons cette ligne-là rapidement, voulez-vous ? Le « sudo iptables » est attendu, le -A est pour l’ajout d’une règle, le -p est pour le protocole, dans ce cas, tcp, et le tiret tiret (les paquets d’Office et le « deux tirets » ne sont pas amis) dport est pour le port de destination, | ||
+ | |||
+ | Comme nous l' | ||
+ | |||
+ | |||
+ | **On the other side of the coin, if you set your default policy to DROP, and you work on allow lists, all it takes, is someone to accidentally flush your rules. It is as simple as: sudo iptables -F. Though this clears all the rules, it does not reset the defaults back to the original defaults. This is another issue I have come across with novices, hence why I said not to start with DENY unless you understand 100% what you are doing. This is really, really important when working with remote machines, that you do not have physical access to. I have had to drive like an hour to the data centre enough times to know not to do this. Making an appointment to see your own server with blood and urine samples is not fun at all, specially if someone else did this. Victor, if you ever read this, know I’m referring to you... LOL. If all of this was not scary enough as it is, realise that there are dynamic ports and you will have to check RELATED traffic as well, but that is a topic for another day. Internalise this chunk we talked about, it isn’t much, but without training your eyes and your brain, you will miss the small things and firewall configurations are all about the small things.** | ||
+ | |||
+ | En revanche, si vous réglez DROP comme défaut et que vous travaillez sur des listes de choses permises, il suffit que quelqu’un « flush » (supprime) vos règles par accident. C’est aussi simple que : sudo iptables -F. Bien que cela supprime toutes les règles, ça ne remet pas les défauts aux défauts d’origine. C’est un autre problème que j’ai rencontré chez les novices, ce qui explique pourquoi j’ai dit de ne pas démarrer avec DENY à moins de comprendre ce que vous faites à 100 %. Cela est vraiment, vraiment important quand vous travaillez avec des machines à distance, auxquelles vous n’avez pas un accès physique. J'ai dû conduire pendant à peu près une heure jusqu' | ||
+ | |||
+ | |||
+ | **TIP: If you are learning, my advice to you is, play on a virtual machine on your system first and do whatever you need to and test if you can access it remotely, before mirroring your changes on a remote server. Set your history to 1000 lines, if you accidentally flush your rules, you can add them from history. Train your eye to look for DENY default rules. Remember that a server serves, it cannot do that if you deny all traffic. Sure, the intruders cannot get in, but neither can your clients. (if you would like to see this in action, look at the Digital Ocean forums, where devs have locked themselves out of their VPS’s, every other day!) | ||
If you think we helped you wrong, misc@fullcirclemagazine.org | If you think we helped you wrong, misc@fullcirclemagazine.org | ||
Ligne 37: | Ligne 55: | ||
Suggested reading | Suggested reading | ||
+ | |||
+ | https:// | ||
+ | |||
+ | ASTUCE : Si vous êtes en train d’apprendre tout ceci, je vous conseille de bricoler d’abord sur une machine virtuelle sur votre système ; faites le nécessaire et essayez d'y accéder à distance avant de réfléchir vos changements sur un serveur à distance. Réglez votre historique à 1 000 lignes, car, si vous supprimez vos règles par accident, vous pouvez les rajouter à partir de l’historique. Entraînez votre œil à chercher les règles DENY par défaut. Rappelez-vous qu'un serveur sert des choses et qu’il ne peut pas le faire si vous refusez tout le trafic. Bien sûr, les intrus ne peuvent pas y entrer, mais vos clients non plus. (Si vous voulez voir cela pour de vrai, regardez les forums de Digital Ocean, où des développeurs ne peuvent pas entrer dans leur VPS parce qu’ils les ont verrouillés, | ||
+ | |||
+ | Si vous pensez que nous vous avez été mal aidé, misc@fullcirclemagazine.org | ||
+ | |||
+ | Réf : man iptables | ||
+ | |||
+ | Suggestion de lecture : | ||
https:// | https:// | ||
+ |
issue204/c_c.1714304701.txt.gz · Dernière modification : 2024/04/28 13:45 de auntiee