Grab MAC From ARP Table With PHP

Cool function you can use on your local network to lookup a devices MAC address, (assuming the device is on your network), using PHP.
For a big company, either look in the remote locations router, or your core router.
// =============================================
// getmac(Device IP, Router, SNMP Read Community)
// Michael Requeny -- http://michael.requeny.com
// - Looks up remote devices MAC
// - SNMP to routers ARP table
// - Converts MAC from HEX to ASCII
// - Inserts : seperators
// =============================================
function getmac($ip, $router, $snmpread) {
	$oid = ".1.3.6.1.2.1.3.1.1.2";
	$mac = snmprealwalk($router, $snmpread, $oid, 1000000 ,10);
	// load up array keys for lookups
	$keys = array_keys($mac);
	foreach ($keys as $key) {
		// if needle contains IP && needle = IP
		// this prevents srch for 10.254.254.1 returning
		// multiple values (like .1, .11, .111, etc.
		if (strstr($key,$ip) == $ip) {
			$mackey = $key;
		}
	}
	$mac = trim(str_replace('Hex-STRING: ', '', $mac));
	$mac = str_replace(' ', ':', $mac);
	return $mac;
}

Disable IPv6 On Ubuntu/Debian

The more formal way of doing this, which fits in with the don’t-change-a-core-system-file-otherwise-it-could-be-replaced-when-you-upgrade-packages-and-your-changes-could-be-lost methodology, and such that it continues across a reboot, is as follows:

# create the long-life config file

echo "net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1" | sudo tee /etc/sysctl.d/99-my-disable-ipv6.conf

# ask the system to use it

sudo service procps reload

# check the result

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

 

Unifi on Debian

1. install unifi, with wheezy provided mongodb (2.0.6)

echo "deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti" >> /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv 06E85760C0A52C50
apt-get update
apt-get install unifi
2. disable mongodb daemon
nano /etc/init.d/mongodb
ENABLE_MONGODB="yes" -> "no"

3. use small files for unifi journals

echo "unifi.db.extraargs=--smallfiles" >> /var/lib/unifi/system.properties

3.a optional: change the default ports in this file for added security

4. remove the 3-4 GB folders created for journal files

du -a / | sort -n -r | head -n 20
rm -rf /var/lib/mongodb/journal
rm -rf /var/lib/unifi/db/journal
du -a / | sort -n -r | head -n 20

5. reboot computer or stop the mongodb service and restart unifi service

6. log in on port https://……:8443/

Bad Behavior has blocked 135 access attempts in the last 7 days.