1 of 20
2 of 20
3 of 20
4 of 20
5 of 20
6 of 20
7 of 20
8 of 20
9 of 20
10 of 20
11 of 20
12 of 20
13 of 20
14 of 20
15 of 20
16 of 20
17 of 20
18 of 20
19 of 20
20 of 20

doc

Network List interface

The Azion.networkList.contains() interface can be used by edge functions on Edge Firewall to match an IP address against a specific network list. If the IP address informed is within the network list, it returns true and the desired implementation logic can go on based on that information.


Syntax

    Azion.networkList.contains(networklistID, ipAddress)

Parameters

Parameter Type Description
networkListId string The ID of the network list to be used for matching.
ipAddress string The IP address to be matched against the network list.

Note: if the network list ID informed is incorrect, an error is thrown.

Find out more about Network Lists on the Azion Platform.


Return value

bool: returns true if the IP address is in the network list and false if it’s not.


Usage

Basic usage of Azion.networkList.contains() with a specific IP address and network list ID:

    addEventListener("firewall", (event) => {

      let ip = event.request.metadata["remote_addr"] // Accessing the remote address

      try {
        let found = Azion.networkList.contains(String(networkListId), ip); // Checking if the ip is in the list
        if (found) {
          event.deny(); // If it's in the list, deny the request
        }
      } catch (err) {
        event.console.error(`Error: `, err.stack);
      }
    });

Error handling

If an error occurs during the execution of Azion.networkList.contains(), an exception may be thrown. Make sure to handle potential errors and provide appropriate error messages or fallback actions in your code.


Best practices

  • Regularly update and maintain the network lists to ensure accurate matching and minimize false positives or false negatives.
  • Combine network list matching with other security measures for comprehensive protection.
  • Ensure the integrity and security of the network lists to prevent unauthorized modifications or access.
  • Regularly review and update the network list configurations to address changing security threats and requirements.

Didn’t find what you were looking for? Open a support ticket.