W
W
walkerstech2021-06-04 12:49:52
Laravel
walkerstech, 2021-06-04 12:49:52

Accessing the site from certain autonomous network IPs?

In fact, here is a list of all facebook IP networks https://api.hackertarget.com/aslookup/?q=AS32934 .
How to get all IP addresses from subnets 31.13.74.0/24 and enter them into the
IP config config

<?php
return [
    '127.0.0.1',
];

IP Access Middleware:
<?php
namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Illuminate\Http\Response;

class IPAccess{
    public function handle(Request $request, \Closure $next)
    {
        if(!in_array($request->ip(), config('ip'))){
            return new response(view('closed'));
            //return redirect()->route('closed');
        }

        return $next($request);
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
U
UksusoFF, 2021-06-04
@walkerstech

https://github.com/grntartaglia/php-netmask

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question