Community discussions

MikroTik App
 
danihill
newbie
Topic Author
Posts: 27
Joined: Wed Dec 17, 2014 9:07 pm

Add to Address List

Mon Jun 08, 2020 5:05 pm

Good afternoon all,

I have a small project and am looking for a way to add a clients IP address to the IP-Firewall-Address List.

The best way for me would be that the clients goes to our client area on our website and clicks on a link and there current IP address is added to the address list.

Has anybody got any ideas of how we could do this?

Thanks all.

DH
 
danihill
newbie
Topic Author
Posts: 27
Joined: Wed Dec 17, 2014 9:07 pm

Re: Add to Address List

Mon Jun 08, 2020 5:28 pm

Seen some people who have put a file on a router and when a client accesses this file it adds their IP address to the address list.
 
User avatar
merlinthemagic7
Frequent Visitor
Frequent Visitor
Posts: 61
Joined: Fri Sep 16, 2016 8:49 pm

Re: Add to Address List

Mon Jun 08, 2020 6:06 pm

You need an intermediate service to make it safe. e.g. click fires off ajax to a server that performs the addition to the ACL.

If you dont mind exposing the address of your router:
/ip firewall mangle
add action=add-src-to-address-list address-list=knockKnock address-list-timeout=1d chain=prerouting dst-port=8900 protocol=tcp
Then have the following link in the HTML (assuming your router is on 10.10.10.10)

<a href="http://10.10.10.10:8900/">Click me to let me in </a>

 
danihill
newbie
Topic Author
Posts: 27
Joined: Wed Dec 17, 2014 9:07 pm

Re: Add to Address List

Mon Jun 08, 2020 6:31 pm

Great thank you it works perfect.

Regards

DH
 
pe1chl
Forum Guru
Forum Guru
Posts: 10568
Joined: Mon Jun 08, 2015 12:09 pm

Re: Add to Address List

Mon Jun 08, 2020 7:41 pm

Of course it still is extremely unsafe as those systems that scan all the internet on many different ports will hit your "magic port" and then add themselves to the addresslist, possibly your next step is to grant them more privileges e.g. logon to the router.
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3352
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Add to Address List

Tue Jun 09, 2020 8:43 am

Agree with pe1chl

Scanning all ports will hit the one port that opens all.

I have done the following.
You need to knock three port in correct order withing certain time limit.
If you try one port that is not part of the knock or is not open for a service, you will be added to a black list for 24 hours, so you does not see any ports open.
 
User avatar
jvanhambelgium
Forum Guru
Forum Guru
Posts: 1120
Joined: Thu Jul 14, 2016 9:29 pm
Location: Belgium

Re: Add to Address List

Tue Jun 09, 2020 9:29 am

...you can call it quick & dirty but you can also call it plainly insecure...
Is this something to be deployed in the public Internet ?

As a minimum, your website should parse the client-IP headers (eg. X-Forwarder-For, HTTP_Client_IP) and extract this IP address!
Then your webserver/appserver should apply some formatting and talk to the Mikrotik API (eg. through PHP) to add that client-IP to a certain ACL on the Mikrotik.
(eg. viewtopic.php?t=40472)