Keresés

Új hozzászólás Aktív témák

  • iceQ!

    addikt

    válasz ratkaics #18530 üzenetére

    # Created Jotne 2019 v1.2
    #
    # This script add ip of user who with "IPSEC negotiation failed" and "SPI* not registered" to a block list for 24hour
    # Schedule the script to run every 5 min
    # It should run on all routerOS version



    # Find all "negotiation failed" error last 5 min
    :local loglistN [:toarray [/log find time>([/system clock get time] - 5m) message~"negotiation failed"]]

    # for all error do
    :foreach i in=$loglistN do={

    # find message
    :local logMessageN [/log get $i message]
    # find ip
    :local ipN [:pick $logMessageN 0 [:find $logMessageN " "]]

    # Add ip to accesslist
    /ip firewall address-list add address=$ipN list=IPSEC
    # Send a message to the log
    :log info message="script=IPSEC_failed src_ip=$ipN why=negotiation_failed"
    }



    # Find all "SPI* not registered"" error last 5 min
    :local loglistS [:toarray [/log find time>([/system clock get time] - 5m) message~"SPI.*not regist"]]

    # for all error do
    :foreach j in=$loglistS do={

    # find message
    :local logMessageS [/log get $j message]
    # find ip
    :local ipS [:pick $logMessageS ([:find $logMessageS "for "]+4) [:find $logMessageS "["]]

    # Add ip to accesslist
    /ip firewall address-list add address=$ipS list=IPSEC
    # Send a message to the log
    :log info message="script=IPSEC_failed src_ip=$ipS why=SPI_not_registered"
    }

Új hozzászólás Aktív témák