Bought a new computer? Old is also useful

    It so happened that I love programming and computers. Therefore, each member of my family had one PC. I have a stationary (Ubuntu), my mother also (Windows XP), and my wife has a laptop (Windows Vista). There was a task - to organize the Internet for all this technology. The provider gives it to me via PPTP. Without thinking twice (and being a bummer), I bought regular Ethernet network cards, plugged them into stationary computers and connected all computers with wires (to be honest, I still bought a WiFi module for my computer, but stupidly could not configure for ubuntu).

    As time passed, needs grew (especially the need for workplace mobility) and I became the owner of a MacBook Pro laptop. What to do with an old computer? Toss out? It was a pity ... After all, he collected it almost with his hands for two years. And then I decided - it will be a server! I cleaned my computer and reinstalled Ubuntu Linux there.

    goal


    I wanted my old computer to be a web (HTTP), file (FTP, SSH, SMB) server. Against the background, I was engaged in downloading all kinds of large files (including from P2P networks). It was a sound server (to connect speakers to it, and transmit sound through WiFi).

    the Internet


    At first, I decided to finally deal with the Internet. After a couple of days on the forums, it was decided to buy a D-Link DIR-300 WiFi router. Since I had to download from P2P networks, I signed up for an external static IP service from an Internet provider. And since the computer that is directly connected via PPTP can have this IP, I decided that a PC would connect to the Internet (of course, there are such things as port forwarding, but I just did not want to bother).

    Setting up the router was not as easy as I thought. There was a disk that officially worked in Windows XP and Windows Vista. I connected the router to my wife’s laptop and spent about an hour, after which I realized that Vista was definitely not supported there. In XP, I set it up quickly, but the setup was to choose a unique name for the WiFi network and enable stealth mode.

    Next, I had to figure out how to give the Internet router. I remembered about DHCP (+ DNS) and NAT. DNS was just installed with the command:
    sudo aptitude install bind9

    The DHCP server was installed with the following command:
    sudo aptitude install dhcp3-server

    His setup was easy - I added the following lines to /etc/dhcp3/dhcpd.conf:
    subnet 192.168.3.0 netmask 255.255.255.0 {
    range 192.168.3.100 192.168.3.150;
    option routers 192.168.3.1;
    option broadcast-address 192.168.3.255;
    default-lease-time 600;
    max-lease-time 7200;
    }

    I have a router on the eth0 interface, so the DHCP server is started by the dhcpd3 eth0 command, then I realized that I need to run all the commands that will often be executed in separate scripts and I got the following file structure:

    / run
    / run / net - here working with the network
    / run / app - here launching additional services
    / run / bind - linking the file system (then I'll tell you)

    So I got the files:
    /run/net/dhcp.sh - starting the DHCP server
    / run / net /vpn-on.sh - connection via PPTP to the Internet
    /run/net/vpn-off.sh - disconnection from the Internet
    /run/net/vpn-ensure.sh - an Internet connection in the event of a break, it was recorded in cron (the system of periodic execution of commands) as follows:
    sudo crontab -e

    The editor opens, in which we add the line:
    * * * * * /run/net/vpn-ensure.sh

    It remains to implement routing. After some searches on the net, I wrote another script ( /run/net/routes.sh ) with the following contents:
    #! / bin / sh
    iptables -A FORWARD -i ppp0 -o eth0 -s 192.168.3.0/24 -m state --state NEW -j ACCEPT
    iptables -A FORWARD -m state --state ESTABLISHED, RELATED -j ACCEPT
    iptables -A POSTROUTING -t nat -j MASQUERADE

    And do not forget to execute in the console:
    sudo -s
    echo 1> / proc / sys / net / ipv4 / ip_forward


    Hurrah! There is Internet!

    Server


    Web and file servers were supplied with one command:
    sudo aptitude install apache2 samba openssh-server proftpd

    I also put a GUI to them (since I am far from professional in configuring these servers):
    sudo aptitude install gproftpd gsambad

    And the VNC server to see the remote desktop of the server from laptops:
    sudo aptitude install x11vnc

    In addition to the servers, it was necessary to think over the file structure. I came to this:
    / share - the root of the FTP / SMB share
    / share / download resource - here all download managers should add the files
    / share / music
    / share / video
    / share / torents - from here the torrent clients should pick up the torrent files and start download
    / share / second - my second hard drive
    / share / third - my third hard drive
    / share / www - the root of the http server. Mount here with the script /run/bind/www.sh (mount --bind / var / www / / share / www /)

    Download Managers


    This turned out to be more difficult. I needed download managers with a web interface, but there were not many of them. But some were found:

    Deluge I just do not have enough words to describe this wonderful torrent client. It has everything, including the Web interface (if it hadn’t been buggy sometimes, it would be very good).
    Put the team:
    sudo aptitude install deluge

    Further after launch I configured it through the GUI.

    mldonkey is a powerful but weird multi-protocol project. I did not like it with just a very confusing interface.

    What happened


    An excellent server for personal needs, accessible from the outside (I sometimes take music from work from there :-)).
    Convenient download from torrent networks (I just put the torrent file in a folder on the server and it is downloaded automatically).
    TimeMachine (data backup system, included in Mac OS X Leopard) works via WiFi and backs up data to the server (allocated 80GB for it). But it was hellishly complicated (even a little disappointed in Apple) - did on this article .

    Unsolved Tasks


    Of the unresolved tasks, there were:
    • Sound Server (and Sound Client for MacBook)
    • Web-based ed2k download manager
    • Web-based dc ++ download manager
    • Web-based HTTP / FTP Download Manager

    What's next


    Now I'm busy looking for a download manager for HTTP / FTP, but for the first time I sketched a web interface for wget (adding a download, progress progress bar, if interested - I can put it in sourceforge - we'll work together).

    PS At my place it turns out “friendship of peoples” :-) Both Windows, Linux, and Mac OS =)

    Also popular now: