Posts Tagged ‘server’

Accessing status and diagnostic information for a Motorola Surfboard cable modem

Wednesday, May 28th, 2014

My ISP (to protect its identity, let’s call it Flomflast) drops my internet connection frequently. During the latest occurrence, I noticed from my router’s status page that the WAN address had been assigned to 192.168.100.11. I was surprised to see this since I believed there was no connection to the ISP via the cable line. How could the ISP DHCP server assigned an ip address to the router? And why the private network address?

I guessed that if the DHCP server was assigning addresses in the 192.168.100.x range then itself or another server (the gateway?) might be located at 192.168.100.1. I typed the address in the address bar of my favorite web browser and was greeted with a web page being served by my Motorola Surfboard cable modem.

Screenshot - 05282014 - 11:14:33 PM

On the configuration page I found information that the cable modem has a built-in DHCP server that takes over when the internet connection is dropped. As configured, it begins assigning addresses at 192.168.100.11. Since my router is the only device on that side of the network with the cable modem, it was assigned the first ip address in the range.

The status page for the cable modem is especially handy. From the comfort of my chair I can see that the internet connection is indeed lost without the usual process of several rounds of pinging followed by a walk to another room to check the modem lights. Even with the internet connected, the modem is still accessible at 192.168.100.1.

Update the DNS record for a Namecheap hosted domain automatically

Saturday, May 18th, 2013

I thought I’d share this technique I use to update the dns records for hellonull.com automatically from the web server every 5 minutes. In the event that my ISP issues me a new IP address, my site will hopefully only be down for 5 minutes.

First, you must obtain the dynamic dns (ddns) update password for your domain from Namecheap. At the time of this post, this was done by clicking the ‘Dynamic DNS’ link from the left hand menu, once your domain was already selected. When you enable dynamic DNS, a password will be generated that looks like a long string of random letters and numbers. Copy this down.

Screenshot - 05182013 - 02:59:52 PM

Next, put this password into the updateddns.sh script (below) and edit the wget commands to point to your hosts (@, www, etc.) and domain (hellonull.com). Make this script executable. It’s a good idea to make the owner of this script root and save it in a protected location, like /root because it contains ‘plain-text’ passwords. Anyone who is able to access the script is able to read the password and is therefore able to change your site’s DNS records.

#!/bin/sh
# This script updates the dynamic DNS record for several domains
# hosted on this server. It is run automatically by cron. The crontab
# file that makes this happen is stored in /etc/cron.d/ddns.
# While this script can execute as any user, it should be owned by
# root because it contains 'plain text' passwords.
# Each host (as in host.hellonull.com) must get updated individually.
# In addition, all subdomain records must be updated individually.

logFile="/var/log/updateNamecheapDDNS.log"

# this is the password as generated by namecheap
pass="You'll have to look at the original or get new ones"

# add a wget line for each host and subdomain
wget -a $logFile -O /dev/null "https://dynamicdns.park-your-domain.com/update?host=www&domain=hellonull.com&password=$pass"
wget -a $logFile -O /dev/null "https://dynamicdns.park-your-domain.com/update?host=@&domain=hellonull.com&password=$pass"
wget -a $logFile -O /dev/null "https://dynamicdns.park-your-domain.com/update?host=teachingwiki&domain=hellonull.com&password=$pass"

If you run the updateddns.sh script it should update your DNS records. To automate the process simply schedule the script using cron. I added a crontab file called ddns in /etc/cron.d which executes the script every 5 minutes.

# use this file to schedule ddns updates
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# every 5 minutes
*/5 * * * * root /root/updateddns.sh >/dev/null 2>&1