Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - ble

#1
Hello everybody,
I work with opnsense 23.1.6 the plugin os-firewall is installed.

I look for add dhcp4 statics leases by batch.

The best way for me should be by API but i don't find.

Have you got a idea for this?

best regards
#2
Hello everybody,
I work with opnsense 23.1.6 the plugin os-firewall is installed.
I work with api since severals Days. But i can't create a new filter rule!!

I read the faq and i search in forum.

curl -m 5 -k -u "$key":"$secret" https://$urlOpn/api/core/firmware/status        work fine


curl -m5 -k -u "$key":"$secret" https://"$urlOpn"/api/firewall/filter/searchRule?searchPhrase=$Filtre     

              work fine, if i have manual created a rules in Firewall-->Rules-->automation-->filter

but the script bash above  return {"result" :"failed"}

#!/bin/bash
# Configuration de l'API OPNsense
OPNSENSE_API_KEY=$key
OPNSENSE_API_SECRET=$secret
OPNSENSE_API_URL="https://$urlOpn/api"

# Configuration de la règle de filtrage
RULE_NAME="block 192.168.20.50"
RULE_ACTION="reject"
RULE_INTERFACE="LanWifiTV"
RULE_PROTOCOL="tcp"
RULE_SOURCE="192.168.20.45"
RULE_SOURCE_PORT="*"
RULE_DESTINATION="any"
RULE_DESTINATION_PORT="any"

# Création de la règle de filtrage via l'API OPNsense
response=$(curl -k -u "$key":"$secret" -X POST \
-H "Content-Type: application/json" \
-d '{
    "action": "$RULE_ACTION",
    "interface": "$RULE_INTERFACE",
    "protocol": "$RULE_PROTOCOL",
    "source": "$RULE_SOURCE",
    "sourceport": "$RULE_SOURCE_PORT",
    "destination": "$RULE_DESTINATION",
    "dstport": "$RULE_DESTINATION_PORT",
    "descr": "$RULE_NAME"
  }' \
"$OPNSENSE_API_URL/firewall/filter/addRule")
#*********************
# Vérification de la réponse de l'API
echo $response | grep failed
if [ $? -eq 0 ]; then
  echo "Une erreur s'est produite lors de l'ajout de la règle de filtrage."
else
  echo "La règle de filtrage a été ajoutée avec succès."
fi


some kind soul would be kind enough to guide me to the right solution?

best regards