Firewalls can limit the network access to or from your resources.
Returns all Firewall objects.
Copy HetznerCloudClient hetznerCloudClient = new HetznerCloudClient ( "apiKey" );
List < Firewall > list = await hetznerCloudClient . Firewall .Get();
Gets a specific Firewall object.
Copy HetznerCloudClient hetznerCloudClient = new HetznerCloudClient ( "apiKey" );
Firewall firewall = await hetznerCloudClient . Firewall .Get( 1012861 );
Creates a new Firewall.
Once created, you can start managing the rules in the 'Firewall Actions' section.
Copy HetznerCloudClient hetznerCloudClient = new HetznerCloudClient ( "apiKey" );
// Create
Firewall firewall = await hetznerCloudClient . Firewall .Create( "firewall example" );
Updates the Firewall.
Copy HetznerCloudClient hetznerCloudClient = new HetznerCloudClient ( "apiKey" );
// Get
Firewall firewall = await hetznerCloudClient . Firewall .Get( 1012861 );
// Change
firewall . Name = "cyberpanel" ;
// Update
firewall = await hetznerCloudClient . Firewall .Update(firewall);
Deletes a Firewall.
Copy HetznerCloudClient hetznerCloudClient = new HetznerCloudClient ( "apiKey" );
// Get
Firewall firewall = await hetznerCloudClient . Firewall .Get( 1012861 );
// You can delete it by passing the Firewall as a parameter
await hetznerCloudClient . Firewall .Delete(firewall);
// You can also delete it by passing the Firewall ID as a parameter.
await hetznerCloudClient . Firewall .Delete( 1012861 );
Copy {
"firewall" : {
"id" : 1112794 ,
"name" : "firewall-example" ,
"labels" : {} ,
"created" : "2023-11-05T19:40:21.506374+00:00" ,
"rules" : [
{
"direction" : "in" ,
"protocol" : "tcp" ,
"port" : "80" ,
"source_ips" : [
"0.0.0.0/0" ,
"::/0"
] ,
"destination_ips" : [] ,
"description" : null
} ,
{
"direction" : "in" ,
"protocol" : "tcp" ,
"port" : "443" ,
"source_ips" : [
"0.0.0.0/0" ,
"::/0"
] ,
"destination_ips" : [] ,
"description" : null
} ,
{
"direction" : "in" ,
"protocol" : "tcp" ,
"port" : "15-20" ,
"source_ips" : [
"0.0.0.0/0" ,
"::/0"
] ,
"destination_ips" : [] ,
"description" : null
} ,
{
"direction" : "out" ,
"protocol" : "tcp" ,
"port" : "any" ,
"source_ips" : [] ,
"destination_ips" : [
"0.0.0.0/0" ,
"::/0"
] ,
"description" : null
}
] ,
"applied_to" : [
{
"type" : "server" ,
"server" : {
"id" : 38976603
}
}
]
}
}