Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Get IP range by AS number

    Scheduled Pinned Locked Moved pfBlockerNG
    3 Posts 3 Posters 299 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • viktor_gV
      viktor_g Netgate
      last edited by

      Found useful site for this https://hackertarget.com/as-ip-lookup/

      You can simply add IPv4 feed:
      https://api.hackertarget.com/aslookup/?q=AS15169

      But is more better to have native ability in pfBlockerNG, and get ip ranges from radb.net
      like this script:
      whois -h whois.radb.net -- '-i origin AS15169' | grep -Eo "([0-9.]+){4}/[0-9]+"

      1 Reply Last reply Reply Quote 1
      • NogBadTheBadN
        NogBadTheBad
        last edited by

        @viktor_g your script only does IPv4

        IPv4:-

        whois -h whois.radb.net -- '-i origin ASS15169' | grep ^route: | awk '{print $2}'

        IPv6:-

        whois -h whois.radb.net -- '-i origin AS15169' | grep ^route6: | awk '{print $2}

        Andy

        1 x Netgate SG-4860 - 3 x Linksys LGS308P - 1 x Aruba InstantOn AP22

        1 Reply Last reply Reply Quote 0
        • BBcan177B
          BBcan177 Moderator
          last edited by

          pfBlockerNG-devel already has ASN support in the IP State setting. Also Radb registry isn't very accurate. The package is using bppview.io instead.

          https://api.bgpview.io/ip/<IP>
          

          "Experience is something you don't get until just after you need it."

          Website: http://pfBlockerNG.com
          Twitter: @BBcan177  #pfBlockerNG
          Reddit: https://www.reddit.com/r/pfBlockerNG/new/

          1 Reply Last reply Reply Quote 1
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.