Community discussions

MikroTik App
 
jaxed8
Member Candidate
Member Candidate
Topic Author
Posts: 195
Joined: Tue Jul 27, 2021 8:25 pm

Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Sat Nov 26, 2022 5:43 pm

Hello everyone
I was wondering if there is a script for resolving and adding all the IPs of the websites which are on a link (example: https://test.com/sitelist.txt) to a address-list and add the host name as comment to the first IP of each website.
Example: Link/txt file is containing the following:

google.com
yahoo.com
android.com
apple.com

then the script resolve those addresses to find their IPs, then it will add them as following to the address-list:


add address=123.123.123.123 comment=google.com list=scan
add address=123.123.123.124 list=scan
add address=123.123.123.125 list=scan
add address=78.16.85.1 comment=yahoo.com list=scan
add address=124.15.21.110 comment=android.com list=scan
add address=124.15.21.120 list=scan
add address=141.165.84.125 comment=apple.com list=scan
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 3279
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Sat Nov 26, 2022 6:46 pm

Why do you like to do that. To try to block some?
Google etc changes IP all time and gives different IP depending location etc.
 
jaxed8
Member Candidate
Member Candidate
Topic Author
Posts: 195
Joined: Tue Jul 27, 2021 8:25 pm

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Sat Nov 26, 2022 8:27 pm

Why do you like to do that. To try to block some?
Google etc changes IP all time and gives different IP depending location etc.
Not blocking them but to bypass the traffic from VPN tunnel.
google was only an example, the list is full of websites that mostly have only 1 IP.
 
jaxed8
Member Candidate
Member Candidate
Topic Author
Posts: 195
Joined: Tue Jul 27, 2021 8:25 pm

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Mon Nov 28, 2022 1:15 pm

Any idea/solution?
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 2855
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Mon Nov 28, 2022 1:35 pm

You should read this topic:

viewtopic.php?p=606832#p606832
 
User avatar
vklpt
newbie
Posts: 36
Joined: Mon Feb 18, 2019 1:13 pm
Location: Izhevsk
Contact:

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Tue Nov 29, 2022 6:41 pm

Any idea/solution?
You can literally add hostnames to address-list and they are will be resolved automatically.
 
jaxed8
Member Candidate
Member Candidate
Topic Author
Posts: 195
Joined: Tue Jul 27, 2021 8:25 pm

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Wed Nov 30, 2022 1:59 am

You can literally add hostnames to address-list and they are will be resolved automatically.
Yeah that's totally right but in that case router is gonna query them every few minutes and spam up all my pi-hole query list.
 
jaxed8
Member Candidate
Member Candidate
Topic Author
Posts: 195
Joined: Tue Jul 27, 2021 8:25 pm

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Mon Dec 05, 2022 3:01 am

You should read this topic:

viewtopic.php?p=606832#p606832
Thanks man but I didn't get how to use it, would you be so kind and elaborate it?
 
jaxed8
Member Candidate
Member Candidate
Topic Author
Posts: 195
Joined: Tue Jul 27, 2021 8:25 pm

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Thu Dec 15, 2022 9:31 pm

Up!
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11967
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: Create/update address-list from a .txt file/link IPs and add the hostname to the comment's of each

Fri Dec 16, 2022 3:56 pm

Open the file in an advanced text editor which allows advanced search and replace of one text block.

example file code

google.com¶
yahoo.com¶
android.com¶
apple.com¶
search only "¶" / "return" / "new line" / "enter" / \n / \r\n, or what is that "button" called in your country,
and replace with

replace code

"; :execute "/ip firewall address-list add address=[:resolve $site] comment=$site list=scan"
:local site "
Fix first and last line.

You obtain the script:

script code

:local site "google.com"; :execute "/ip firewall address-list add address=[:resolve $site] comment=$site list=scan"
:local site "yahoo.com"; :execute "/ip firewall address-list add address=[:resolve $site] comment=$site list=scan"
:local site "android.com"; :execute "/ip firewall address-list add address=[:resolve $site] comment=$site list=scan"
:local site "apple.com"; :execute "/ip firewall address-list add address=[:resolve $site] comment=$site list=scan"

Speaking of doing it with scripts in RouterOS, it's just not worth it to me.

Who is online

Users browsing this forum: xrlls and 15 guests