> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IP Ban System

> Block suspicious PlayFab logins by creating single-address or CIDR range IP bans from Game Manager or the Services SDK, with permanent or timed expiration.

The IP ban feature allows you to restrict access to the game from specified IP addresses or ranges. When an IP ban is applied, future authentication attempts made from that IP address or within the banned range will be rejected. IP bans may be permanent or temporary with a specified expiration date, and may be applied to a single IP address or IP range expressed in CIDR notation. An IP ban is scoped to a title and doesn't apply to any other titles in your [namespace](/services/playfab/live-service-management/game-configuration/entities).

The following tutorial shows you how to use the IP ban system, using the PlayFab API and Game Manager.

## Identify

You can identify an IP address to ban through the PlayStream Monitor. If you notice suspicious login activity, find a **Player logged in** event and select the curly braces in the **JSON** column to view its details. Copy the address from the **"IPV4Address"** field.

<img src="https://mintcdn.com/microsoft-4404708b/U1LR64ZWxo45eXwl/images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-suspicious-login-event.png?fit=max&auto=format&n=U1LR64ZWxo45eXwl&q=85&s=8cc7a5e0fd83557e26642cf5c762c03b" alt="Game Manager - IP Bans - Suspicious Login Event" width="1370" height="673" data-path="images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-suspicious-login-event.png" />

<Note>
  If "Store full user IP addresses" in **Settings > Data Collection** is disabled for your title, the last octet of the IP address will be obfuscated.
</Note>

## Applying bans

If you deem it necessary, you might create an IP ban. There are two ways to create bans: manually through Game Manager, or programmatically through the [Services SDK](/services/playfab/sdks/playfab-sdk-intro).

<Note>
  A title may create IP bans for up to 200 IP addresses or ranges.
</Note>

### Creating an IP ban from Game Manager

Your community manager might want to apply a ban using Game Manager.

1. Navigate to the IP Bans section.
2. Select **New IP Ban** to display the **New IP Ban** form.
3. Paste the IP address you wish to ban, or type in the CIDR range you wish to ban.
4. Select **Permanent** for a permanent ban, or select an expiration date and time for your ban.
5. Optionally, type in the reason for your ban.
6. Finally, select the **ADD BAN** button.

<img src="https://mintcdn.com/microsoft-4404708b/U1LR64ZWxo45eXwl/images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-new-ip-ban.png?fit=max&auto=format&n=U1LR64ZWxo45eXwl&q=85&s=42567eb75f0d8ea839a865fc3bac832c" alt="Game Manager - IP Bans - New IP Ban" width="1372" height="685" data-path="images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-new-ip-ban.png" />

If everything is set correctly, you see a new IP ban in the table with the **"Active"** status.

<img src="https://mintcdn.com/microsoft-4404708b/U1LR64ZWxo45eXwl/images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-table.png?fit=max&auto=format&n=U1LR64ZWxo45eXwl&q=85&s=21604260c8ec2c76cc13ecc5ab558000" alt="Game Manager - IP Bans - Table" width="1376" height="701" data-path="images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-table.png" />

### Managing IP bans from Game Manager

You can manually disable IP bans by selecting them and then selecting **Disable selected bans**. Their status changes to **"Disabled"**.

<img src="https://mintcdn.com/microsoft-4404708b/U1LR64ZWxo45eXwl/images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-disable.png?fit=max&auto=format&n=U1LR64ZWxo45eXwl&q=85&s=c7fbdc60e6a109011eff1684882b474c" alt="Game Manager - IP Bans - Disable" width="1369" height="827" data-path="images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-disable.png" />

You can edit a ban by selecting the IP address field in the table. This brings you to the **Edit IP Ban** form. Here, you can disable (or re-enable) bans as well as modify the expiration date and reason. Select **Save** to save your changes.

<img src="https://mintcdn.com/microsoft-4404708b/U1LR64ZWxo45eXwl/images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-edit.png?fit=max&auto=format&n=U1LR64ZWxo45eXwl&q=85&s=c8fa5ea054f8f74b7cddf3297bf714f8" alt="Game Manager - IP Bans - Edit" width="1366" height="692" data-path="images/playfab/player-progression/player-data/tutorials/game-manager-ipbans-edit.png" />

When a ban's expiration date passes, its status becomes **"Expired"**. To reactivate the ban, you must define a new expiration date. Only IP bans with the **"Active"** status prevent logins.

### Creating a ban from a server or service

<Warning>
  Due to their broad-reaching nature and potential high impact to players, we caution against automatically or programmatically creating IP bans.
</Warning>

From a trusted server or service, you can use the [Services SDK](/services/playfab/sdks/playfab-sdk-intro) to create an IP ban through the Admin API. The Admin API requires your title's developer secret key and must not be called from a game client.

```csharp theme={null}
public async Task CreateIPBanAsync(string ipAddress, DateTime expirationDate)
{
    var response = await PlayFabAdminAPI.CreateIPBanAsync(
        new CreateIPBanRequest
        {
            IPAddress = ipAddress,
            Expires = expirationDate.ToUniversalTime(),
            Reason = "Automatic IP ban"
        });

    if (response.Error != null)
    {
        Debug.LogError(response.Error.GenerateErrorReport());
        return;
    }

    // Handle response.Result.IPBanData
}
```

IP bans applied through the API are also displayed in the table of IP bans for the title in Game Manager.


## Related topics

- [Player Ban system](/services/playfab/player-progression/player-data/player-bans.md)
- [API Feature Settings in the PlayFab Game Manager](/services/playfab/live-service-management/gamemanager/api-feature-settings-in-the-playfab-game-manager.md)
- [PFAccountManagementServerBanUsersAsync](/services/playfab/api-references/c/pfaccountmanagement/functions/pfaccountmanagementserverbanusersasync.md)
- [PFAccountManagementBanUsersRequest](/services/playfab/api-references/c/pfaccountmanagementtypes/structs/pfaccountmanagementbanusersrequest.md)
- [PFAccountManagementBanRequest](/services/playfab/api-references/c/pfaccountmanagementtypes/structs/pfaccountmanagementbanrequest.md)
