Create Raspberry Pi as A DLNA Media Center

OS : Raspbian

Access Point


1. Install the following
sudo apt-get install hostapd isc-dhcp-server iptables wpasupplicant

2. Configure AP Daemon
sudo nano /etc/hostapd/hostapd.conf
--
interface=wlan0    #wlan0 will be working in AP mode
ssid=Your_AP_SSID  #your AP SSID
channel=1          #WiFi channel used by AP 
# WPA and WPA2 configuration
macaddr_acl=0      #indicates that you do not use MAC address allow/deny list
auth_algs=1        #indicates algorithm specified by IEEE 802.11
ignore_broadcast_ssid=0 #AP will broadcast SSID
 
#WPA settings
wpa=2              #WPA algorithm used (WPA2 in this case)
wpa_passphrase=my_secret_pass #AP password
wpa_key_mgmt=WPA-PSK #WPA key mangement type
wpa_pairwise=TKIP #encription algorithm
rsn_pairwise=CCMP #encription algorithm
 
#Hardware configuration
driver=rtl871xdrv     #type of driver to be used (in may be different depending on your WiFi dongle chipset)
                      #in majority of cases it will be driver=nl80211 <-- use this for Buffalo Wifi USB dongle
ieee80211n=1          #Whether IEEE 802.11n (HT) is enabled
hw_mode=g             #WPS RF Bands (a = 5G, b = 2.4G, g = 2.4G, ag = dual band)

##Note : for Buffalo Wifi USB dongle (Ralink RT8070)
#country_code=JP
#channel=2
#beacon_int=100
#max_num_sta=5

3. set up /etc/hostapd/hostapd.conf as the configuration file
sudo nano /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"

4. configure the network settings for clients connecting to AP
sudo nano /etc/dhcp/dhcpd.conf
---
ddns-update-style none;   #DDNS disabled
default-lease-time 600; #IP lease time
max-lease-time 7200;
authoritative     
subnet 192.168.10.0 netmask 255.255.255.0 { #AP Subnet definition
  range 192.168.10.10 192.168.10.20  ; #Range of IP addresses available for clients 
  option broadcast-address 192.168.10.255;
  option routers 192.168.10.1; #your client's gateway / router IP
  option domain-name "local-network"; #optional domain name
  option domain-name-servers 8.8.8.8, 8.8.4.4; #your DNS IP
}

5. set up DHCP server configuration file
sudo nano /etc/default/isc-dhcp-server
DHCPD_CONF="/etc/dhcp/dhcpd.conf"
INTERFACES="wlan0"

6. configure wlan0 for static IP adress (the same as router IP in dhcpd.conf file)
sudo nano /etc/network/interfaces
----
auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet static
        address 192.168.10.1
        netmask 255.255.255.0
up iptables-restore < /etc/iptables.ipv4.nat

7. setting up Network Address Translation (NAT). Turn on packet forwarding in /etc/sysctl.conf
sudo nano /etc/sysctl.conf
----
net.ipv4.ip_forward=1

8. start the translation right away by running:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"

9. setting up the actual translation between the ethernet port called eth0 and the wireless card called wlan0
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

10. save the setting
sh -c "iptables-save > /etc/iptables.ipv4.nat"

11. In order to start AP on boot run the following commands:
sudo update-rc.d hostapd enable 
sudo update-rc.d isc-dhcp-server enable

12. When you got trouble with the dhcp server, restarting both hostapd and isc-dhcp-server on start up
sudo nano /etc/rc.local
--- add these line : ---
sudo service hostapd stop
sudo service isc-dhcp-server stop
sudo ifdown wlan0
sudo ifup wlan0
sudo service hostapd restart
sudo service isc-dhcp-server restart
13. reboot

DLNA Server


1. install :
sudo apt-get install minidlna

2. configure :
sudo nano /etc/minidlna.conf
---
# port for HTTP (descriptions, SOAP, media transfer) traffic 
port=8200 

network_interface=wlan0
#Specify paths to directories containing digital media.
media_dir=A,/media/stream/Music 
media_dir=V,/media/stream/Videos 
media_dir=P,/media/stream/Pictures 

friendly_name=Media Server 

db_dir=/mnt/tmp/minidlna 

album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg

inotify=yes 

enable_tivo=no 
strict_dlna=no 

presentation_url=http://192.168.10.1:8200/ 

notify_interval=900 

serial=12345678 
model_number=1

3. start / restart the service
sudo service minidlna force-reload

References :
1. http://raspberry-at-home.com/hotspot-wifi-access-point/
2. http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/
3. http://www.dd-wrt.com/phpBB2/viewtopic.php?t=84881
4. http://terminal28.com/minidlna-upnp-media-server-debian-linux/

No comments:

Post a Comment