EmbarqCenturyLink goes down so often, I finally had to hack together a lame heartbeat script to bounce the connection if it’s down. I run the script below via cron every 5 minutes. The target IP is this blog host, because it ought to be up and reachable. I later considered using the default route’s IP, but am too lazy to write the two pipes needed to tickle out just the IP from `ip route`.
#!/usr/bin/ruby1.8 require 'rubygems' require 'net/ping' require 'open4' # Another idea is to use `ip route` and grep default. # If the default ISP route is missing or cannot be pinged # then the modem should be reset. Net::Ping::TCP.service_check = false # seems to have no effect for TCP p = Net::Ping::TCP.new('208.75.86.204', 80) unless p.ping? or p.ping? or p.ping? # debugging puts `ip route` puts `/sbin/ifconfig eth0` status = Open4::popen4("/bin/netcat -q0 192.168.2.1 23") do |pid, stdin, stdout, stderr| # Magic sequence to restart device stdin.puts "passwd" stdin.puts "24" stdin.puts "4" stdin.puts "21" stdin.close end end