Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] dropping any IP that tries port 22?
- Date: Fri, 19 Jan 2007 22:43:22 +0900
- From: "Stephen J. Turnbull" <stephen@example.com>
- Subject: Re: [tlug] dropping any IP that tries port 22?
- References: <52599.210.168.237.209.1169184208.squirrel@example.com> <45B05710.6090005@example.com> <1169200640.29848.19.camel@example.com>
scott writes: > This is a great idea. I'm not familiar with what position 1 is so I've > gotta do some more reading... In "iptables -I <chain> <n> ..." <n> is the position of the rule (starting from 1), which is checked in order. Since this is a LOG rule, it doesn't hurt to have it before unrelated rules, and you do want it before the rule that stops port 22 altogether. I guess a reasonable alternative is iptables -A INPUT -d yo.ur.i.p --proto tcp --dport 22 --syn -j LOG iptables -A INPUT -d yo.ur.i.p --proto tcp --dport 22 -j REJECT *in that order* so it gets LOGged then REJECTed (instead of REJECTed and stop processing---without LOGging). I choose REJECT here because presumably you'll be smart enough to see "connection refused" and realize you forgot to use -p or knockd before you get your own IP banned. Also, a more sophisticated ban script could count tries and only ban after three, or something like that. Or you could put the ACCEPT on the port you have selected as your nonstandard SSH listener *before* the REJECT/DROP rules (which you would then add with "iptables -I INPUT 2 ..."). Anyway, once you've got the IP that you want to ban, you want to insert it at position 1 so that (a) you don't waste time processing other rules and (b) you don't log it and add it again (maybe iptables is smart enough not to dupe entries, but it seems unlikely). > Or maybe there is a simpler way? The inverse Postel Principle: be lenient about what you send out, and an absolute bastard about what you allow in: # maybe the knock ports only need to ACCEPT on --syn? iptables -A INPUT -d yo.ur.i.p --proto tcp --dport KNOCK1 -j ACCEPT iptables -A INPUT -d yo.ur.i.p --proto tcp --dport KNOCK2 -j ACCEPT iptables -A INPUT -d yo.ur.i.p --proto tcp --dport ALTSSH -j ACCEPT ... any other traffic you know you want ... iptables -P INPUT REJECT
- References:
- [tlug] dropping any IP that tries port 22?
- From: scott
- Re: [tlug] dropping any IP that tries port 22?
- From: Birkir A. Barkarson
- Re: [tlug] dropping any IP that tries port 22?
- From: scott
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] Re: CJK Printing from Web Browsers in Debian 3.3.2
- Next by Date: Re: [tlug] dropping any IP that tries port 22?
- Previous by thread: Re: [tlug] dropping any IP that tries port 22?
- Next by thread: [tlug] dropping any IP that tries port 22?
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links