When on the blacklist, the traffic coming from these source IPs is dropped regardless the TCP/UDP port filtering policies.

The size of both whitelist and blacklist cannot go over more than 512 different class C networks.

Setting IP address or IP range

PacketShield accepts two types of IP addresses:

  • Single host, i.e.: 10.0.0.1

  • IP range based on class C networks, 10.0.0.0-255 or 10.0.0.10-20

    Note

    IP range is inclusive, which means that the lower and upper IP addresses describing the range are included in the range when matching packets.

Use sysfs entry

PacketShield manages source IP blacklists using the sysfs entry:

/sys/packetshield/<instance name>/<context id>/b_sources.

Add an IP

When you add an address to the IP source blacklist, it is automatically removed from the whitelist.

sysfs

Write the IPv4 address or the range prefixed by character + in the sysfs entry.

To add a single host:

echo "+10.0.2.3" > /sys/packetshield/myinst/Other/b_sources

To add a whole class C subnet:

echo "+10.0.3.0-255" > /sys/packetshield/myinst/Other/b_sources

To add 11 consecutive IPs of the same range:

echo "+10.0.4.10-20" > /sys/packetshield/myinst/Other/b_sources

GUI

Use the statement <instance name>/<context id>/b_sources followed by the IP address or range.

To add a single host:

<instance name>/<context id>/b_sources 10.0.2.3

To add a whole class C subnet:

<instance name>/<context id>/b_sources 10.0.3.0-255

To add 11 consecutive IPs of the same range:

<instance name>/<context id>/b_sources 10.0.4.10-20

Remove an IP

Removing an IPv4 address in the middle of a range in the same class C network will split the range into two ranges.

sysfs

Write the IPv4 address or the range prefixed by the character - in the sysfs entry.

echo -10.0.3.100 > /sys/packetshield/myinst/Other/b_sources
echo -10.0.4.10-15 > /sys/packetshield/myinst/Other/b_sources

GUI

Remove the statement <instance name>/<context id>/b_sources <IP address> that matches the IP address or range.

If the IP address to remove is in the middle of an existing range, then provide the rules to follow.

To remove the IP address 10.0.3.100 from the subnet 10.0.3.0/24:

myinst/Other/b_sources 10.0.3.0-99
myinst/Other/b_sources 10.0.3.101-255

List IPs

This function is only available using the CLI.

To list IPs currently configured in the source IP black list, read the content of the sysfs entry.

It displays one IPv4 address or range on a class C network per line.

cat /sys/packetshield/myinst/Other/b_sources
10.0.2.3
10.0.3.10-20
10.0.4.0-255