Skip to content

Instantly share code, notes, and snippets.

@jeffreyvr
Created December 3, 2018 15:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeffreyvr/440a79e06b408308554f5a87a44f8017 to your computer and use it in GitHub Desktop.
Save jeffreyvr/440a79e06b408308554f5a87a44f8017 to your computer and use it in GitHub Desktop.
Generate commands to whitelist Cloudflare IP's (iptables)
<?php
$ips = file_get_contents( 'https://www.cloudflare.com/ips-v4' );
$ips = explode( PHP_EOL, $ips );
$result = '';
foreach ( $ips as $ip ){
if ( empty( $ip ) )
continue;
$result .= str_replace( '#IP#', $ip, 'iptables -I INPUT -p tcp -m multiport --dports http,https -s "#IP#" -j ACCEPT' ) . '<br>';
}
echo $result;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment