Somebody tries to connect my ftp from internet. How can I block his address not to connect to mine?
error is:
login failure for user Administrator from (ip address)
You need only two “drop” rules to completely block a particular IP address. One in the input chain and the other in the forward chain. This rules must then be placed above all other “allow” rules, preferably at the very top of the filter rules.
Here is are some of the rules that we use on our production routers that allow for connection blocking by IP address and dynamic blocking for specified time by IP for given protocol (e.g ICMP). Just another method of blocking connections that I find to be a little easier to manage (which is needed when you have 40+ routerboards in the field). Also for the advanced users please forgive the step by step instructions, just trying to make it as easy to understand for beginners as possible. I know I still need the instructions from time to time.
# Define Source lists for connections to block/allow
add action=drop chain=ProtectRouter comment="Drop connections from bad people" disabled=no src-address-list=BadPeople
add action=accept chain=ProtectRouter comment="Accept connections from good people" disabled=no src-address-list=GoodPeople
# Allow related connections
add action=accept chain=ProtectRouter comment="Allow related connections" connection-state=related disabled=no
# Dynamically Allow Connections
add action=accept chain=ProtectRouter comment="Accept < 5 pings" disabled=no limit=5/10s,1 protocol=icmp
add action=accept chain=ProtectRouter comment="Allow < 3 SSH attempts" disabled=no dst-port=22 limit=1/6s,1 protocol=tcp
# Dynamic Connection Blocking
# address-list - This parameter is set to the list we defined for our "BadPeople" list
# address-list-timeout - This parameter can be set to block for timed period if removed this equals always block
# chain - This parameter is set to the "ProtectRouter" chain for rule grouping and to allow related connections
add action=add-src-to-address-list address-list=BadPeople address-list-timeout=1h chain=ProtectRouter comment="Block > 5 pings" disabled=no protocol=icmp
add action=add-src-to-address-list address-list=BadPeople address-list-timeout=1d chain=ProtectRouter comment="Block > 3 SSH attempts" connection-state=new disabled=no dst-port=22 protocol=tcp
add action=add-src-to-address-list address-list=BadPeople address-list-timeout=1d chain=ProtectRouter comment="Block Port Scanners" disabled=no protocol=tcp psd=21,3s,3,1
To block/allow connections permanently you can add static entries into the BadPeople/GoodPeople list via the console like this:
are those enough to keep only badperson from my network? Anybody can ping and try to connect my router except that person who has xxx.xxx.xxx.xxx ip address. I just want to do that.
sarpkaya:
I apologize for the confusion, let me try to clarify the information in my original post.
If the only thing you want to do is block a single IP address then following two lines will accomplish just that.
add action=drop chain=ProtectRouter comment="Drop connections from bad people" disabled=no src-address-list=BadPeople
/ip firewall address-list add list=BadPeople address=xxx.xxx.xxx.xxx
Having said that I am ever the pessimist and like to take a proactive approach and preemptively block the otherwise nefarious would be intruders. These three entries monitor inbound traffic and look for possible bad people that might be attempting to compromise your network and temporarily ban their IP for x amount of time.
# If a person pings my IP more than 5 times then block add their IP to the BadPeople list for 1 hour
add action=add-src-to-address-list address-list=BadPeople address-list-timeout=1h chain=ProtectRouter comment="Block > 5 pings" limit=5/10s,1 protocol=icmp
# If a person attempts more than 3 SSH connections in x time their IP to the BadPerson list for 1 day
add action=add-src-to-address-list address-list=BadPeople address-list-timeout=1d chain=ProtectRouter comment="Block > 3 SSH attempts" connection-state=new disabled=no dst-port=22 protocol=tcp limit=1/6s,1 protocol=tcp
# If a person attempts to port scan the router add their IP to the BadPerson list for 1 day
add action=add-src-to-address-list address-list=BadPeople address-list-timeout=1d chain=ProtectRouter comment="Block Port Scanners" disabled=no protocol=tcp psd=21,3s,3,1
I hope this clarifies any confusion that I may have inadvertently caused.
John Annis
The Wireless Web
Do you ever get the feeling that you always forget to include something important, I always re-read my post before submitting and inevitably always for get something important. To apply those three rules via the console you need to be at /ip firewall filter.