Playing Video Files on Your TV with minidlna

Playing Video Files on Your TV with minidlna

One of my presents from Christmas a few years back was a Sony smart blu-ray player. It was marketed as something that easily streams files from your computer. That is absolutely true for anyone that runs Windows, just point and click. With Ubuntu, it’s a bit more complicated. Enter minidlna.

Installation

First thing, install minidlna. Open a terminal (Ctrl-Alt-t) and type this in:

sudo apt-get install minidlna

If you’d rather use the package manager, just search for minidlna.

Setup

The configuration file is editable by running this in the terminal:

sudo gedit /etc/minidlna.conf

There are 2 settings to note: media_dir and friendly_name. The names used are pretty explanatory. Here’s an example of what to update:

# Path to the directory you want scanned for media files.
media_dir=/path/to/shared/media

# Name that the DLNA server presents to clients.
friendly_name=fileserver

Save and close the file. On the terminal run this to refresh minidlna:

sudo service minidlna restart

That’s it! minidlna is all setup to server the files and folders in your media_dir.

ssh: Remember each host’s settings

ssh: Remember each host’s settings

When you start using ssh to connect to other linux-based computers, you’re probably only going to a handful of machines. Easy enough to remember the username and hostname, but this won’t do when you’re working on 5 or more servers, especially if some offer ssh on a non-default port.

~/.ssh/config

In this file, you can set all the options for each host, including the username, host or ip, port, even which key to use. Here’s an example:

#Contents of $HOME/.ssh/config
Host dev
HostName 192.168.0.1
User dev-deploy
Port 2222
IdentityFile ~/.ssh/id_rsa.deploy.key

Host prod
HostName www.example.com
User prod555deploy
Port 5899

Host www.example.com
User admin123
Port 5899

It’s that easy! To use this config information, simply ssh:

ssh prod

Happy Computing!

X11 Forwarding

A few days, I moved my desktop computer out into the living room. The computer has a tuner card that can receive digital broadcasts. I don’t own a TV, so this is the closest I’ve got to one. I still have to set up lircd before I can use a remote, but I wanted something a bit easier

Today, I discovered a new trick … SSH X11 Forwarding. Now, I can play video on my desktop right from my netbook. It’s wonderful and very simple!

In the following instructions, the “A” refers to the computer playing the video and “B” refers to any other computer.

  1. Make sure “X11Forwarding Yes” is in your sshd_config file on computer A. Restart sshd if you had to uncomment/add it.
  2. On B, run `ssh -XC A`
  3. In the ssh session, type `DISPLAY=:0.0`.
  4. Now run mplayer or any other video player in the  ssh session and it will play on computer A.

If you want  to have a program run on computer A and use the screen on computer B, the process is very similar:

  1. Make sure “X11Forwarding Yes” is in your sshd_config file on computer A. Restart sshd if you had to uncomment/add it.
  2. On B, run `xhost A`
  3. On B, run `ssh -XC A`
  4. Now run mplayer or any other video player in the  ssh session and it will play on computer A.

Step 2 authorizes use of the current display by computer A and only needs to be run once. Also, note that the display variable doesn’t need to be set when using B‘s screen.

Mplayer works wonderfully when playing on my desktop, plus I control it via the ssh session. It has tons of keyboard shortcuts. The ones I use the most are space for pause and the arrow keys for skipping around.

Blocked Port 25 Workaround

Recently, I switched to AT&T DSL. I’m quite happy with the price of $19.95/month. Of course, there was a drawback; they block port 25, the port used to send email. I figured that out after an hour of searching. There are a few solutions for this. Here are my findings.

Update: I use sendmail on a linux  server to run my email.

Solution 1: Change the listening port
This is the most obvious fix, and the one I implemented. You need to admin your own server to do this. Using sendmail, it’s only 2 lines in sendmail.mc:


define(`RELAY_MAILER_ARGS', `TCP $h 2525')dnl
define(`ESMTP_MAILER_ARGS', `TCP $h 25')dnl

The first line changes the smtp port to 2525, and the second line changes the outgoing smtp port back to 25. Without the second line, no email will go out.

Note: when editing the sendmail.mc, you need to compile it by running make or m4 sendmail.mc > sendmail.cf. After compiling it, restart the sendmail daemon. DO NOT EDIT sendmail.cf!

Solution 2: Use a proxy
There are plenty of services out there that will proxy, or relay, for a fee. I am sure there are proxies that are free, but I wouldn’t trust them to keep my information private for a second.

This solution doesn’t require you to have admin rights on the server and it is a lot easier. Each proxy setup is different, so follow the instructions they give.

Solution 3: Don’t send email with that account
Not the best solution, but you can get a yahoo or gmail account for free. You can still receive email from any account. This is probably not acceptible for most people.

Solution 4: Switch to another ISP
This is always an option, even if it means downgrading to dial-up. The only reason why I am keeping AT&T is because of the price.

Well, I hope that you found this information helpful. Happy e-Mailing.

Internet Troubleshooting

What do you do when your internet connection goes does? Go get a board game or cards? Call your IT friend from work? Bang on the desk until the page loads? While most of these are good solutions, getting your connection running again is pretty simple. As long as nothing is wrong on your provider’s end, that is.

Perform each step by itself. Try to load a webpage after each step to see if it is working.

  1. Check your connections.
  2. Shutdown your computer and boot it up again.
  3. Unplug your router, if you have one, for 30 seconds then plug it back in.
  4. Unplug your cable/dsl modem for 30 seconds then plug it back in.
    Wait for the “Internet” or “DSL” or “Cable” light to light up.
  5. Repeat Step 3.
  6. Repeat Step 2.
  7. Open Control Panel -> Network Connections and Delete the “Local Area Connection”, then reboot.

If none of these steps fix your connection, there is probably a problem at your provider and you should call their tech support line.

Hint: Print this page and keep it by your computer so you have it when the internet does go out. Also, write the tech support number on the print out for convenience.

Networking Day 7: Extending your wifi range

General Wifi Range is 75 feet if the line from you to the router is completely open. Most of the time, you have lots of things between you and the router — walls, wires, pipes, etc. Many times you’ll find that 35 feet is where the signal gets tempermental.

Antennae
There are two basic types of wifi extender antennae. Both types connect to the same connector that your basic antenna uses. You may need an adapter though. Some laptops do not have a connector for an antenna, so double check before you go out and buy one for your laptop.

Unidirectional Antennae will boost the signal in one direction only. The best use is when you have a clear line of sight, but are a distance away.

Omnidirectional antennae will boost your signal in all directions. This is helpful if you have a router in the center of your home and the signal in the far corners isn’t all that.

Wireless Access Points
This is like having a second wireless router. If you don’t have a wireless router, you can add one of these to your network to give you wireless access.

There are many reasons why you would add an access point.

  1. If you want to limit access to the internet for your child, just take the power cord to bed with you.
  2. Place it on the porch for access outside.
  3. The list goes on.

Networking Day 6: Shared folders

Sharing a folder is an easy way to copy files from one computer to another. Windows shares work with Windows, MacOS and linux.

Setting your computer’s name
Right-click on My Computer and then click Properties. Under the name tab, you can setup the name. Your computer will reboot after you click OK. This step is not neccessary if you are using a static IP address.

Setting up a share on Windows
Sharing a folder is a snap. Right-click on a folder you want to share and then click “Sharing ans Security”. If you have never shared a folder before, click the link and tell it to enable sharing. Give the share a name. Check the box if you want other people to write to files or create files in this folder.

Connecting to a share on Windows
Click on the Start Button, then click on “Run…”. In the box type “\\COMPUTERNAME\” replacing COMPUTERNAME with the name of your computer or it’s IP address. Click OK and it will show you all the shares on that computer.

You can map a shared folder to a drive, like “Z:\”. Simply, right-click on a shared folder and select “Map Network Drive”. From that popup, select your drive letter. Click OK and you’re done. That drive will attempt to reconnect everytime the computer is booted.

Networking Day 5: Port Forwarding

Today is all about port forwarding.  This is needed when you want to make a specific service available to anyone on the internet.  That service could be a game, a web server, or even Yahoo Messenger.

Ports
Anytime you connect to a server, you are connecting to a specific port. The server listens on that port for incoming connections and respond appropriately. Different port numbers are for different services.  A few examples include:

  • 80 — http
  • 21 — ftp
  • 25 — smtp (sending email)
  • 110 — pop3 (recieving email)

Before you begin the setup, you should find out what port needs to be opened.  You can figure this out by the manual or a quick internet search.

Setting up a static IP
This is necessary for most port forwarding.  Please review Day 2: Subnets for information on selecting an IP address to use.  The static IP must be in the same subnet as the dynamic IP.

Also, make sure that the DHCP on your router will not give out this IP address.  All routers will have a range of IP addresses.  If the range starts at “.100”, you can use “.99”. Also, if the range ends at “.199”, you can use “.200”.

Setting up the forwarding
Log into your router’s admin interface.  There should be “port forwarding” or “port address translation” in the menu, click this.  On this screen it should have somewhere you can enter the port and ip or a link to click to get to enter that information.  Enter the port and IP, click save, and you’re done.

Don’t forget to get your public IP address from a service like WhatIsMyIP.com.

Networking Day 4: Wireless Router Setup

A wireless router is a wired router with 1 or more antennae. You should complete the setup of the wired portion before continuing. The router’s admin tool will have a wireless setup section that we’ll be working in today.

Speeds
Most routers and devices use the “G” form of wifi. It’s technical name is 802.11G. It runs at up to 55 Mbps (megabits per second). The “B” form runs at up to 11 Mbps. The latest version, “N”, runs at up to 600 Mbps.

The speed of your connection will be the lower of the router and the device. So, if your router is “B” and your device is “G” or vice-versa, the fastest you’ll go is 11 Mbps. Just like many other things, you network is only as fast as its weakest link.

AP Name & Channel
The Access Point Name is the name that will identify the wireless network. It will only operate on the channel you select. If you notice that something is interfering with your signal, change the channel. 2.4GHz phones are bad interfering with wireless networks, but changing the channel does the trick most of the time.

Wireless Security
Under the wireless section of your router’s configuration, you can setup your security. WEP is the most common type of security used. It uses 128-bit encryption, the same level used by websites that take credit card payments.

Select WEP from the drop down menu and give it a 13 character password. The better the password, the better the security. A good mix of numbers, symbols, uppercase and lowercase letters is best. Try to use acronyms, like NASA or NFL, instead of words.

Windows and MacOS should have an icon next to the clock to setting it up. Tell it to connect to the AP name and it will ask for the password. Linux uses a utility called wpa supplicant which can be setup graphically or by the command prompt.

Where to purchase
You can get these anywhere. You don’t need all the fancy bells and whistles. The biggest question is whether you want wireless or not. If you’re going wireless, go with the “802.11G”.

One of the best places to purchase a used router is the flea market. It sounds a bit shady, but usually honest and good people work up there, and the price is 50% off the retail version.

Networking Day 3: General Router Setup

For almost all home networks, a router connects the local network to the internet via a cable/dsl modem. Most home routers have other features such as DHCP, a firewall, a de-militarized zone (DMZ) and port forwarding. Some even have a usb port to connect a printer for easy use from any computer.

The router actually has 2 IP addresses
Yes, the router has 2 IP address. One is the public IP address. This is the IP address that shows up to the outside world. WhatIsMyIP.com is one of the many sites that can tell you what your public IP address is.

The other is the local IP address. This is on the same subnet as all the computers on your network. This usually ends with a “.1”.

Configuring the router
Most routers can be configured directly from your web browser. All you have to do is type in the local IP of the router. You should be prompted to enter a username and password. These can be found in the manual along with the subnet IP of the router. If you don’t have the manual, you can download them from the manufacturer.

DHCP
DHCP hands out IP addresses automatically. Make sure this option is turned on. It makes life a lot easier. Also, make sure your computers are configured to use DHCP.

Configuring clients
Either set up DHCP on the computers that are connected or assign them a unique IP address in the subnet. I’d suggest going DHCP, as it makes life easier. If you’re brave enough to try static IP addresses, don’t turn off DHCP in the router, in case you mess up the IP address or subnet mask.

Cables
Standard routers use ethernet cables to connect computers to it and to connect it to the cable/dsl modem. These can be hazards if running across the floor. They can also be expensive. If you want to make your own, it’s fairly simple and inexpensive. Click here for wikiHow’s How to Make a Network Cable. You can even get ethernet wall jacks, they look just like phone jacks.

Where to purchase
You can get these anywhere. You don’t need all the fancy bells and whistles. The biggest question is whether you want wireless or not. If you’re going wireless, go with the “802.11G”.

One of the best places to purchase a used router is the flea market. It sounds a bit shady, but usually honest and good people work up there, and the price is 50% off the retail version.