How to make the Playstation 3 co-exist with Linux and OpenBSD

On Sunday I shelled out the hard earned rupees to the local Game Stop and received a brand new 60GB PlayStation 3 console. I cranked it up on the home LAN and away I went.

I will address two things in this here little article. Getting the “media server” function working with a Linux server, and how to overcome the “NAT Type: 3″ guy.

Media Server
I have a Linux media server in my basement, connected to the network primarily using NFS. I have 400GB or so of movies and music on the server and I wanted to be able to access it via the PlayStation 3′s XMB interface. I know I could install Linux on the PS3, but I’m somewhat massochistic.

The following types of files can be played under (Video).

* Memory Stick Video Format
* – MPEG-4 SP (AAC LC)
* – H.264/MPEG-4 AVC Main Profile (AAC LC)
* MP4 file format
* – H.264/MPEG-4 AVC High Profile (AAC LC)
* MPEG-1 (MPEG Audio Layer 2)
* MPEG-2 PS (MPEG2 Audio Layer 2, AAC LC, AC3(Dolby Digital), LPCM)
* MPEG-2 TS (MPEG2 Audio Layer 2)
* AVI
* – Motion JPEG (Linear PCM)
* – Motion JPEG (μ-Law)
* AVCHD (.m2ts / .mts)

( From the PlayStation(R) 3 Manual [http://manuals.playstation.net/document/en/ps3/current/video/filetypes.html
] )

You may have to re-encode your media files to be compatible with the PlayStation 3, that is outside the scope of this document. There are many mencoder(1) HowTo’s out there, you could also use ffmpeg(1). H264 is rapidly becoming a standard, and the mp4 container is widely supported, so I don’t see any overt reason one couldn’t batch reconvert their media collection. Of course this might be a non-starter for some, so you can either plug on and get the mp3 playback capability (and photos) or you can give up and proceed down to the NAT Type 3 bit. I personally hope that Sony will release DivX and XviD support in a (soon to come?) firmware update.

So, more than you needed to know about the PlayStation 3 media server feature:
This is basically DLNA, an ‘open’ standard that Sony seems to have thrown their weight behind. Essentially it’s UPnP SSDP (Universal Plug and Play Service Set Discovery Protocol) with multicast HTTP on the back end. It’s kind of like the iTunes daap music and video sharing, except instead of using Zeroconf (Bonjour / Avahi / Multicast DNS) for discovery, it uses UPnP. The software I found for Linux that works fairly well is called uShare, it is a subset of GeeXboX, a media-player Linux distribution and can be found on the geexbox website (http://ushare.geexbox.org/). It requires libupnp, which is linked on the page. The installation directions are fairly straightforward though they don’t have many packages available, so if your distribution doesn’t have one then you’ll have to do it the old fashioned way (configure && make && sudo make install). For what it is worth I use Slackware and had no problems whatsoever compiling and installing it. It is configured either in a configuration file that is fairly straight forward or via the command line. For example I have my RAID-5 array mounted on /u01, so I simply did “/usr/local/bin/ushare -D -d -f /usr/local/etc/ushare.conf -c /u01″ and the PlayStation 3 immediately found it sharing movies music and photos.

NAT Type 3
NAT Type 3 hasn’t caused me any problems as of yet, but the manual seems to indicate that direct connections don’t work in this mode. Basically what the 3 types break down to is this:

* Type 1 – Your router has UPnP enabled and I was able to map my ports.
* Type 2 – Your router does NOT have UPnP on but my ports are mapped.
* Type 3 – Your router does NOT have UPnP on and my ports are NOT mapped.

Type 3 sounds somewhat scary, but in reality that just means other PlayStation 3 consoles cannot connect directly to yours. This isn’t really that big of a deal in most cases, however it’s quite easy to solve.

The port numbers for PLAYSTATION®Network servers used for this are TCP: 80, 443, 5223 and UDP: 3478, 3479.

For voice / video chat and online game play, direct communication with other PS3™ systems is used for data transmission during voice / video chat and online gaming. The port number used for this is UDP: 3658. However, you may need to use a different port number when you are connected using a NAT router.

( From the PlayStation(R) 3 Manual [http://manuals.playstation.net/document/en/ps3/current/settings/connecttest.html] )

So I have an OpenBSD router running the pf(4) firewall and was originally getting “Type 3″ when I ran the internet connection test. All I had to do was to map 3658/udp to the PlayStation 3′s IP address and it switched to “Type 2″. Now I have a transparent firewall on the LAN as well that blocks outbound connections from the workstations, in that case I had to allow the other ports listed in the above excerpt OUTBOUND, but as long as you don’t block OUTBOUND connections, all you should have to do is map the one port (3658/udp) and your PlayStation 3 will be able to receive connections from the outside world.

Please feel free to drop me a comment or an e-mail if you have any questions or suggestions. This is not meant to be a step by step, since everyone’s network is a little different but I didn’t find much documentation on the situation so I figured I would write it up.

mernisse at ub3rgeek dot net, PSN-ID: mernisse

mernisse[] - brought to you by: ps3tag.com

Tags:

10 Comments

  • the_kungfu_mcnugget says:

    thanks for those excerpts from the manual…

  • McAwesome says:

    so, did ya figure out how to re-encode the videos?

  • mernisse says:

    I’ve been testing the MediaTomb transcoding feature, it works fairly well so far. The newest entry talks about it a little.

  • bibo says:

    Thanks a lot for the info. I hadn’t seen anything anywhere else on 3658/udp

  • miniupnp says:

    In order to get NAT Type 1, you can install miniupnpd on your OpenBSD router !

  • mernisse says:

    sure could, assuming you feel comfortable letting a remote device alter your firewall settings. Since the PS3 needs very few ports open and only one mapped to function (voice and video chat work fine, PSN games work fine in my experience) I don’t think allowing UPnP to edit your firewall is a good idea in this setting.

  • miniupnp says:

    You can configure miniupnpd in order to allow only redirection to the sony PS3, not to other IPs on your network. You can even configure which ports can be forwarded. That’s not giving control on your firewall to UPnP, that’s letting it punch only the holes that are needed.

  • Kristijan says:

    Are you able to paste the exact pf rules you used to get this working. I’m having trouble with my pf set up, it keeps coming up as Nat Type 3.

  • Czz78 says:

    can you paste nat rule and port forwarding rules?

    TRied these but doesn’t give nat 2

    # Ps3 tcp/udp ports
    ps3_tcp=”9293″ # for remote playing
    ps3_udp=”{ 3478:3479, 3658:3660, 4658:4660 }”
    # nat
    nat on $ext_if from !($ext_if) -> ($ext_if)
    #Ps3 redir
    rdr on $ext_if proto tcp from any to any port $ps3_tcp -> $ps3
    rdr on $ext_if proto udp from any to any port $ps3_udp -> $ps3
    #Ps3 pass in
    pass in on $ext_if inet proto tcp from any to $server port $ps3_tcp keep state queue ps3
    pass in on $ext_if inet proto udp from any to $ps3 port $ps3_udp keep state queue ps3

    boo i don’t understand

  • Czz78 says:

    Found the solution ( i am happy)

    put this on your nat section before all your nat rules:

    nat on $ext_if from $ps3 to any -> ($ext_if) static-port

    This are my ports macros
    # Ps3 tcp/udp ports
    ps3_tcp=”9293″ # for remote playing (only if you want).
    ps3_udp=”3478:3479″ # only 3478 is needed but i put 3479 too

    #Ps3 redir
    rdr on $ext_if proto tcp from any to any port $ps3_tcp -> $ps3 #only if you

    want remote playing

    rdr on $ext_if proto udp from any to any port $ps3_udp -> $ps3

    #Ps3 pass in
    pass in on $ext_if inet proto tcp from any to $server port $ps3_tcp keep state queue ps3 # only if you want remote playing
    pass in on $ext_if inet proto udp from any to $ps3 port $ps3_udp keep state queue ps3

    if you do not do traffic shaping like me don’t put “queue ps3″ at the end of the pass in rules.

    Nat 2 for ps3 with openbsd conf file in /etc/pf.conf

    sorry for my bad english but i am
    ITALIAN FOREVER

    Czz78

Leave a Reply

XHTML: You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

ub[3]rgeek.net is Digg proof thanks to caching by WP Super Cache