Server

From XPUB & Lens-Based wiki

<slidy theme='aa' />

Case study

  • Raspberry PI + Pirate box

Server

Client/Server (wikipedia)

The client–server model is a distributed application structure in computing that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients.[1] Often clients and servers communicate over a computer network on separate hardware, but both client and server may reside in the same system. A server is a host that is running one or more server programs which share their resources with clients. A client does not share any of its resources, but requests a server's content or service function. Clients therefore initiate communication sessions with servers which await incoming requests.

The client–server model was developed at Xerox PARC during the 1970s. It is now prevalent in computer networks. Email, the World Wide Web, network printing are typical examples of the model.

wikipedia:Client–server model

Key terms

  • TCP/IP
  • UDP
  • Socket
  • Port

Layers

wikipedia:Internet protocol suite


Protocols, ports, and programs

Servers

  • HTTP (tcp 80)
    • apache, lighttpd, python
  • SSH
    • openssh
  • FTP (23?)
  • IRC
  • Icecast (tcp? 8000 by default)
  • UPNP
  • RTSP


Server options

Ideally, you have "full access" to a machine to install/start/stop different server programs as you like, this is typical with:

  • Dedicated (machine dedicated just to you -- pzwart3 is an example)
  • Virtual (software that makes one server computer appear to be several "virtual" servers, total control at the price of performance / sharing resources with the other virual servers)

... but also of course you have control over private networks, which may or may also be connected to the Public Internet:

  • Your laptop
  • OpenWRT router
  • Raspberry PI

Less control:

  • Shared hosting

Cloud:

  • New kinds of services offering flexible options of virtual "services" (eg Linode)

Hybrids:

  • VPN


d is for daemon

A daemon is a process (program) that runs in the background, disconnected from a shell. They typically have no user interface perse but rather are started and stopped as needed. While running, they are used via applications that connect to the server program, typically by initiating a connection to the "established" port number.

ps aux

Often names of programs that end in 'd' are daemons.

/etc/init.d/

/etc/init.d/ contains "initscripts" for most of the server programs that are installed on a system.

Typically init scripts take a subcommand like: start, stop, and restart:

/etc/init.d/apache start
/etc/init.d/apache stop
/etc/init.d/apache restart

Some, like apache, might respond to custom commands, such as Apache's reload (to reload changed configuration files):

/etc/init.d/apache reload

Run levels

Run levels represent different stages the computer is in from starting up to eventually a user logging in.

Typically servers like apache start automatically when your system starts up. This is done by adding the script to the "default" runlevel.

One line web server

Servers don't necessarily have to be complex...

python -m SimpleHTTPServer

Access Point

hostapd

http://hostap.epitest.fi/hostapd/

hostapd for Debian
------------------

This package provides two methods for managing hostapd process(es); an
initscript and an ifupdown hook. Both methods require creation of a
hostapd daemon configuration file (eg. /etc/hostapd/hostapd.conf) to
function correctly.

An example hostapd.conf may be used as a template but _must_ be edited
to suit your local configuration. An example is located at:
  /usr/share/doc/hostapd/examples/hostapd.conf.gz

To use the example as a template:
  # zcat /usr/share/doc/hostapd/examples/hostapd.conf.gz > \
  	/etc/hostapd/hostapd.conf
  # $EDITOR /etc/hostapd/hostapd.conf

To use the initscript method of starting a hostapd daemon see
/etc/default/hostapd.

To use the ifupdown method, the path to hostapd configuration file can
be specified in a network interfaces configuration stanza in
/etc/network/interfaces like so:

iface eth1 inet static
	hostapd /etc/hostapd/hostapd.conf
	...
The hostapd process will be started in the pre-up phase of ifup, and be
terminated in the post-down phase of ifdown.

 -- Kel Modderman <kel@otaku42.de>  Tue, 27 Oct 2009 12:03:01 +1000

Please note:
* If you want to use hostapd with a Prism2/2.5/3 card in WPA mode, you'll need
  STA firmware version >= 1.7.0.

 -- Faidon Liambotis <faidon@cube.gr>, Mon, 10 Oct 2005 14:57:11 +0300

Access point projects

  • NewsTweak
  • Pirate Box
  • Onion Box

Access Point

http://learn.adafruit.com/downloads/pdf/setting-up-a-raspberry-pi-as-a-wifi-access-point.pdf

Hutspot

Many wifi cards support an "access point" or "master" mode which allows them to act as a kind of "hot spot" letting other clients connect. Typically a hotspot gives access through to the public Internet, but they don't necessarily have to.


PirateBox

PirateBox, Deconstructed

from /etc/init.d/piratebox:

PIDFILE_DROOPY=/var/run/piratebox_droopy.pid
PIDFILE_HOSTAPN=/var/run/piratebox_hostapn.pid
PIDFILE_DNSMASQ=/var/run/piratebox_dnsmasq.pid
PIDFILE_LIGHTTPD=/opt/piratebox/tmp/lighttpd.pid
PIDFILE_SHOUTBOX=/opt/piratebox/tmp/shoutbox_daemon.pid

Droopy

Python file receiver ?

hostapn

Access point software

dnsmasq =

lighttpd

"Lightweight" / fast HTTP (web) server

shoutbox

IRC

OnionPi

Another project based on Raspberry PI, an access point that proxies all requests through TOR.

http://www.tgdaily.com/security-features/72150-how-to-turn-a-raspberry-pi-into-a-portable-tor-proxy-onion-pi

= Outtakes

  • IceCast
  • UPNP (UDP port 1900 and TCP port 2869)
  • Own Cloud