nick.recoil.org

AppleTV & Ubuntu hacking (0)

I’ve finally enabled SSH on my long dormant AppleTV, and am integrating it into my DVB / Rails / Beanstalk / MySQL system for processing data. I’ve used the Patchstick image available from atv4windows. I ended up unpacking and dd’ing the image from the Mac, but the process remains exactly the same. I now have Perian, ssh and a slew of other things enabled, and all I need now is to attempt the hack to get composite output working. I’ve yet to take the plunge and replace my old CRT with an LCD TV.

Incidentally, for anyone looking to figure out the ssh username and password for your freshly enabled ssh daemon, they are both frontrow, and that user has passwordless sudo privileges.

I also had a minor breakthrough with my x86_64 Ubuntu 8.04 machine. I have a Zyxel G-202 Wireless USB stick, to keep the number of trailing wires to a minimum, but I kept getting an error saying:

1
zd1211rw error ioread32(CF_REG1): -110

Which was exceedingly unhelpful. I eventually tried disabling hi-speed USB from the BIOS, and rebooted to find it sprang into life immediately. Great! What was even more strange that when I rebooted and reset the BIOS back to enable USB 2.0, the G-202 kept working. I’m unsure whether this is due to the device not being cold booted, and I’ve yet to see if it stops working after I power the system off, but so far so good, and I don’t need to resort to NDIS.

Saving my blown Seagate Barracuda 7200.10 hard drive

Whilst messing around with my Mini ITX box, I managed to touch the power connector onto the drive backwards, blowing one of the components near the connector. I noticed that the controller board is screwed on with standard torx screws, so I took them out, curious about the connector to the main chassis.

After removing them, the board came away easily, and uses pressure pads as a connection mechanism, rather than ribbon cable or other methods. This set me wondering about whether this would be a replaceable part. I contacted Seagate, who told me that they don’t supply them separately. I then wondered about getting an identical drive, and replacing the old board with one from the new drive, so I went ahead and ordered a replacement; I’d need it anyway, even if this attempt at data recovery failed.

After it arrived, and I’d done the swap, I turned on the machine, and back came my drive with all my data on it, safe and sound. I did worry about whether the IDE controller boards carry some kind of mapping table that’s specific to a particular set of platters, but this isn’t the case, it seems. Unfortunately I’ve no way of repairing the original blown board. Replacing surface mount components is tricky.

For anybody wondering, you can replace the controller board for a Seagate Barracuda 7200.10 500GB drive with no ill effects.

Loopback NAT with pf

A useful trick with hosting servers via ADSL connections at home is to provide something called NAT loopback. In this text, I will be giving an example setup using OpenBSD’s pf tool. Imagine the following:

You have a development server hosted via an ADSL line, behind a NAT router/firewall. You would like this development server to be visible to others via the Internet, and you have assigned a name in DNS which maps to one of the externally visible IP addressed assigned to you via your ADSL hosting company. You then set up a virtual host on the development webserver so that it responds to the DNS name you’ve assigned it.

A problem arises when you need to talk to the machine locally on your network, using the DNS name you’ve given it. Without any special rules, this will not work due to the following series of events:

  1. You generate a request to your webserver’s external IP address, which is bound to your NAT box’s external interface
  2. Your request hits the NAT box, and the destination IP is rewritten as the local address, and is forwarded on
  3. The request hits the webserver, but the source address is on the local LAN. The webserver replies directly to your machine
  4. Your computer receives the reply, but the source IP address is the local address, not the remote address, so the data is discarded

What is required within the pf rules is a redirect that takes traffic bound for the external IP address of the webserver, and rewrites the source address, so the reply gets sent back to the NAT box, and in turn gets rewritten and redirected back to the originating host.


 # DEFINES ##########
 # network interfaces
 internal_if = "sip0" 
 external_if = "sip1" 

 # NAT box
 gw = "192.0.2.1" 

 # webserver 
 www_int_ip = "10.0.0.2" 
 www_ext_ip = "192.0.2.2" 
 # ports to be redirected
 www_ports_tcp = " {80} " 

 # RULES ##########
 # define our general NAT
 nat on $external_if inet from $internal_if:network to any -> $gw

 # define our external sources to the webserver
 rdr on $external_if inet proto tcp from any to $www_ext_ip
    port $www_ports_tcp -> $www_int_ip

 # for local requests, rewrite the destination as the local
 # IP, rather than the remote one
 rdr on $int_if inet proto tcp from $int_if:network to $www_ext_ip
    port $www_ports_tcp -> $www_int_ip

 # don't NAT other traffic
 no nat on $int_if proto tcp from $int_if
    to $int_if:network

 # keep state on traffic going to the webserver's internal IP address
 nat on $int_if proto tcp from $int_if:network to $www_int_ip
    port $www_ports_tcp -> $int_if

More information can be found in the pf FAQ. Thanks go to Jasper Wallace for originally writing the pf rules for the setup in our flat.

Search

Sections

About Nick

I am a freelance technology consultant and developer working in London, with a particular interest in web development and video media.

This site contains my thoughts about technology, the universe and everything. If you would like to get in contact, have a look at the About me page.