### IP Validation Script Usage (Bash) Source: https://context7.com/anthemaker/goodbots/llms.txt Provides examples of using the `clean_ips.sh` script to clean a list of IPs by removing invalid entries and validating IPs inline. The script filters out invalid IP addresses. ```bash # Clean a list of IPs, removing invalid entries cat raw_ips.txt | ./.github/scripts/clean_ips.sh > cleaned_ips.txt # Validate inline echo "192.168.1.0/24" | ./.github/scripts/clean_ips.sh # Output: 192.168.1.0/24 echo "invalid-ip" | ./.github/scripts/clean_ips.sh # Output: (empty - invalid IP filtered out) ``` -------------------------------- ### Fetch and Clean GoogleBot IPs (GitHub Actions YAML) Source: https://context7.com/anthemaker/goodbots/llms.txt An example GitHub Actions workflow step to fetch GoogleBot IP ranges from their official API, clean them using `clean_ips.sh`, sort uniquely, and save to a file. It uses `curl`, `jq`, and a local script. ```yaml # Example: How GoogleBot IPs are fetched - name: Fetch GoogleBot IPs run: | curl -s https://developers.google.com/search/apis/ipranges/googlebot.json | \ jq -r '.prefixes[] | .ipv4Prefix // .ipv6Prefix' | \ ./.github/scripts/clean_ips.sh | sort -u > iplists/googlebot.ips ``` -------------------------------- ### Download and Use Combined IP Whitelist (Bash) Source: https://context7.com/anthemaker/goodbots/llms.txt Demonstrates how to download the complete IP whitelist using curl and then process it with iptables for firewall rules. Assumes the 'all.ips' file is available. ```bash # Download the complete whitelist curl -O https://raw.githubusercontent.com/[repo]/main/all.ips # Use with iptables while read ip; do iptables -A INPUT -s "$ip" -j ACCEPT done < all.ips ``` -------------------------------- ### Download Service-Specific IP Lists (Bash) Source: https://context7.com/anthemaker/goodbots/llms.txt Shows how to download IP lists for specific services, such as GoogleBot or Cloudflare, using curl. This allows for granular control over which IP ranges are whitelisted. ```bash # Download only GoogleBot IPs curl -O https://raw.githubusercontent.com/[repo]/main/iplists/googlebot.ips # Download only Cloudflare IPs for CDN trust curl -O https://raw.githubusercontent.com/[repo]/main/iplists/cloudflare.ips ``` -------------------------------- ### Validate IPv4 Addresses (Bash) Source: https://context7.com/anthemaker/goodbots/llms.txt A bash function to validate IPv4 addresses and CIDR ranges. It checks the format and range of the IP address and the CIDR suffix. Returns 0 for valid and 1 for invalid. ```bash # validate_ipv4() - Validates IPv4 addresses with optional CIDR suffix # Returns 0 for valid, 1 for invalid validate_ipv4() { local ip_cidr="$1" if [[ $ip_cidr =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}(/[0-9]{1,2})?$ ]]; then IFS='/' read -r ip cidr <<< "$ip_cidr" IFS='.' read -r a b c d <<< "$ip" [[ $a -le 255 && $b -le 255 && $c -le 255 && $d -le 255 && (-z "$cidr" || ($cidr -ge 0 && $cidr -le 32)) ]] return $? fi return 1 } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.