Capabale Chromecast Configuration (or, how I got Chromecast to work with Ubuntu)

So, I now own a Chromecast. Having acquired it while the Netflix promotion was in effect, I only ended up spending $11 on it. Not bad for a YouTube machine (the only reason I bought it since Roku still doesn't have YouTube support). I've been pretty happy with it thusfar as it turned out to be a great party tool, and the HDMI CEC support makes it really easy to throw YouTube videos on in the background, even if the TV is off.

However, one feature I was having trouble getting to work under Linux was tab casting. Using the Chromecast Chrome extension, one should be able to transmit the contents of a tab to a Chromecast on the local network. For some, reason, though, I was unable to do so. After some poking around, I determined that my firewall (ufw, the greatest misnomer of them all) was causing this. Since it was using a randomly assigned local port to establish the connection, simply opening a port wasn't the answer. Not to be deterred, I set about conquering this problem. Here's what I did.

  1. Find the Chromecast's MAC address. In my case this was a two-step operation...

    1. Launch the Chromecast app to determine the device's IP address.

      A screenshot of the IP address of a Chromecast desplayed within the Chromecast app.

      The IP address is circled in red.

    2. Ping the device and then check the address resolution stats.

      [aru@Ananke:~]$ ping -c 1
      PING ( 56(84) bytes of data.
      64 bytes from icmp_req=1 ttl=64 time=1.66 ms
      --- ping statistics ---
      1 packets transmitted, 1 received, 0% packet loss, time 0ms
      rtt min/avg/max/mdev = 1.669/1.669/1.669/0.000 ms
      [aru@Ananke:~]$ arp -a
      ? ( at d0:e7:82:7c:15:76 [ether] on wlan0
  2. Assign a static IP to the device. Configure your router to assign a static IP to the MAC address you found in the previous step. If you don't know how to do this, has some decent tutorials. You may have to restart your router after setting up this rule.

  3. Determine your local port range. In my case, since I'm using IPv4, I did the following:

    [aru@Ananke:~]$ cat /proc/sys/net/ipv4/ip_local_port_range
    32768   61000

    The two numbers are the lower and upper bounds of the local ports available for casting.

  4. Whitelist your Chromecast. Using the now-static IP address and your local port ranges, tell ufw to step off!

    [aru@Ananke:~]$ sudo ufw allow proto udp from to any port 32768:61000
    Rule added

Once you've done this, open up Chrome, click on the Chromecast button, and start tabcasting!

Chromecast extension screenshot.

As you can see, I don't use Chrome for very much.