03 9695 5408 info@melbournecityit.com.au
Melbourne IT services, IT support | Melbourne City ITMelbourne IT services, IT support | Melbourne City IT
  • Home
  • Services
    • – Website development
    • – IT consulting
    • – VoIP
    • – IT Support
    • – Cyber Security
    • – Linux
    • – Cloud Solution
  • Contact
  • Blog
  • Home
  • Services
    • – Website development
    • – IT consulting
    • – VoIP
    • – IT Support
    • – Cyber Security
    • – Linux
    • – Cloud Solution
  • Contact
  • Blog

Security

  • Home
  • Blog
  • Security
  • Block IP addresses by Country in 3CX

Block IP addresses by Country in 3CX

  • Categories Security, VoIP
  • Date September 4, 2020
IT security Service Melbourne

You may want to block the login or phone registration by IP address in 3CX if you are sure your business will be totally local.

Download the database file

We will use the database file (CSV) from https://db-ip.com/db/download/ip-to-country-lite

Open it with Excel, and format as table, then you can filter by the country code, copy the part you want to block, which will looks like below:

A B C D
1 start IP End IP Country
2 2.16.103.0 2.16.103.255 RU
3 2.16.154.0 2.16.154.255 RU
4 2.16.159.0 2.16.161.255 RU
5 2.16.168.0 2.16.168.255 RU

 

User a formula =[@A1]&"-"&[@A2] in D1, apply to all the D column, then D column will looks like: 2.16.103.0-2.16.103.255, select all D column, copy. Select E column, right click, choose selective paste, then choose value.

Convert to CIDR format

 

The 3CX only accept the CIDR format, so we need to convert the data first.

Doing this manually can be daunting , luckily, we can use an online tool to convert them :

Then copy E column, open https://www.ipconvertertools.com/iprange2cidr#, choose multiple IP ranges, paste your data in the text area. click Calculate.

After a few seconds, it will show the:

 

Click the Export to CSV, choose Comma separated, Download the CSV file, open with Excel, delete every column except the first one, rename the title to IP, add another two column: expirationDate, and description. The correspond value will be date value : 2119-10-08T14:53:00+00:00 , and a description "Russia", because I copied the IP addresses for Russia.

CIDR Start IP End IP Subnet Mask Addresses Hosts Wildcard mask
2.16.103.0/25 2.16.103.0 2.16.103.127 255.255.255.128 128 126 0.0.0.127
2.16.103.128/26 2.16.103.128 2.16.103.191 255.255.255.192 64 62 0.0.0.63
2.16.103.192/27 2.16.103.192 2.16.103.223 255.255.255.224 32 30 0.0.0.31
2.16.103.224/28 2.16.103.224 2.16.103.239 255.255.255.240 16 14 0.0.0.15
2.16.103.240/29 2.16.103.240 2.16.103.247 255.255.255.248 8 6 0.0.0.7
2.16.103.248/30 2.16.103.248 2.16.103.251 255.255.255.252 4 2 0.0.0.3
2.16.103.252/31 2.16.103.252 2.16.103.253 255.255.255.254 2 2 0.0.0.1

 

Modified into:

IP expirationDate description
2.16.103.0/25 2119-10-08T14:53:00+00:00 Russia
2.16.103.128/26 2119-10-08T14:53:00+00:00 Russia
2.16.103.192/27 2119-10-08T14:53:00+00:00 Russia
2.16.103.224/28 2119-10-08T14:53:00+00:00 Russia
2.16.103.240/29 2119-10-08T14:53:00+00:00 Russia
2.16.103.248/30 2119-10-08T14:53:00+00:00 Russia
2.16.103.252/31 2119-10-08T14:53:00+00:00 Russia

 

Save this as a CSV file, which will be converted into JSON by another online tool.

Convert to the JSON format

 

https://www.convertcsv.com/csv-to-json.htm

 

Under Step 1: Select your input, click Choose file and select the CSV file.

Under Step 2: Choose input options (optional), tick

Input Options
Keep step 3 and 4 as default, under Step 5: Generate output will show the result, which should be like:
[
{
"IP": "2.16.103.0/25",
"expirationDate": "2119-10-08T14:53:00+00:00",
"description": "Russia"
},
{
"IP": "2.16.103.128/26",
"expirationDate": "2119-10-08T14:53:00+00:00",
"description": "Russia"
},
...

]
you can click Download Result.
Import into 3CX
In the 3CX console, go to security, IP blacklist, import, select the file you downloaded in previous step. All Done!

Tag:3cx, country IP range, security

  • Share:
Frank Fu

Previous post

Fix Remote desktop Frozen issue
September 4, 2020

Next post

Monitoring your Hard disk space with Powershell
August 17, 2021

You may also like

  • VOIP-Phone
    Time To Move On To VoIP
    6 May, 2020
  • https-1024×752
    Why should use HTTPS instead of HTTP
    5 May, 2020

Services

  • Consulting
  • IT support
  • Telephony (VoIP)
  • Cyber Security

Recent Posts

  • Windows Printing issue
  • WordPress pages except homepage showing blank
  • What Challenges Does the Development of Strong AI Face?
  • Monitoring your Hard disk space with Powershell
  • Block IP addresses by Country in 3CX

SERVICES

  • Website Development
  • Cloud Solution
  • Cyber Security
  • Consulting
  • VoIP Service
  • IT Support
  • Linux Service

CONTACT US

  • info@melbournecityit.com.au
  • 03 9695 5408

Blog

Windows Printing issue
Frank Fu
December 16, 2021

Windows Printing issue

WordPress pages except homepage showing blank
Frank Fu
August 30, 2021

WordPress pages except homepage showing blank

What Challenges Does the Development of Strong AI Face?
Frank Fu
August 17, 2021

What Challenges Does the Development of Strong AI Face?

Featured Clients

  • Real Estate Agent Melbourne
  • Essendon Eye Clinic
  • North West Eye Specialist
  • Essendon Retina
  • McKinnon Eye Clinic
  • CATARACT & EYE SURGERY MELBOURNE
  • High Quality Cable Supplier, KMCable
  • iPhone Repair Melbourne
  • Sai Stone
  • How Interior Design

© Melbourne City IT 2020