ip address

Connecting to MSSQL

I have had to create a few PHP sites that connect to a MSSQL server. Not being down with setting up these servers, there are a couple of caveats you should be aware of if you are not accustomed to the server yourself.

TCP/IP access is turned off by default, so if you are trying to connect via IP address, you will need to switch this on. It is in the SQL Server Configuration Manager under the Server Network Configuration > Protocols for xxx

Also, if you are a MySQL guru, you will use user accounts to connect, and MSSQL can have the same, but they are switched off by default. If you connect to your MSSQL server instance using the Management Studio and right click on the server (the top item in the filetree) and choose properties, you will find a “Security” tab, where you will find an option for allowed authentication types. ¬†Switch it to SQL Server and Windows Authentication mode.

This will save you a few hours!

Redirect certain IP address .htaccess

If you ever wanted to prevent certain IP addresses from accessing your site, you can easily acheive this in the .htaccess file.

Simply list the IP addresses and then redirect them to the desired URL:

RewriteEngine on 
RewriteCond %{REMOTE_ADDR} ^xxx\.xxx\.xxx\.xxx$ [OR]
RewriteCond %{REMOTE_ADDR} ^xxx\.xxx\.xxx\.xxx$
RewriteRule ^(.*)$ http://www.redirection-url.com [L]

If you want to add more then do so, but notice there is no [OR] on the last condition.

Now, this could get messy if you have loads, and I am unsure of the performance hit, but its a quick and easy way of redirecting users. A site I work on has 5 servers located worldwide, and I wanted to send LA users attempting to access the UK server back to their designated server

Get MAC address from IP address

Had a routing issue the other day, and I was remotely trying to forward a port to a device. I didn’t know the MAC address of the device, and my Home Hub was insisting on that information for the forward destination. I knew the IP address, so there is a simple Windows command to get the MAC address from the IP address:

arp -a <ip_address>

I.e.

arp -a 192.168.1.70

Easy. This command works in Windows as well as Linux! Well theres a thing… It also works in Mac, but you drop the -a parameter:

arp 192.168.1.70