How to Reset Network Adapter in Ubuntu

Here’s a quick tip on how to reset your network adapter. This could come in handy if a server has an incorrect ip address and requires a reset to obtain the right ip address.

Simply run the following command:

sudo service network-manager restart


How do I reset the network adapter using a terminal command?. askubuntu. [04/12/2016].

How to check if an ip address matches a CIDR

When working in the area of application security, you may come across situations where you need to make sure that only certain servers are allowed to access your web service. Usually checking the ip address is a decent way of making such guarantees.

You can use a function as follows:

function cidr_match($ip, $cidr)
    list($subnet, $mask) = explode('/', $cidr);

    if ((ip2long($ip) & ~((1 << (32 - $mask)) - 1) ) == 
        return true;

    return false;

Example results

cidr_match("", ""): true
cidr_match("", ""): true
cidr_match("", ""): false