Linux Summer Project

Associate
Joined
24 Jun 2007
Posts
1,869
Location
Landan.
Evening all,

I've decided to relearn some of the Linux fundamentals and also hopefully acquire some new knowledge along the way.

The plan is to completely redo my home network and incorporate a host of new services. As such I hope to make this thread a bit of a project log, that will hopefully spur me to keep going and maybe inspire some others (ego++)...

I'll post links to whatever articles/posts/sites I've used, and give information where I've had to deviate from the info given within.

To start:

Proposed Network Layout
(changed from topology to layout as to not seem like a ****** :p)


homenetwork2.png


And here's a brief description of what each machine is doing:

[1] Maya

OpenWRT installed on a Netgear DG834G. I've got OpenWRT successfully onto the box, but it's losing its settings upon a reboot. Furthermore, doing a df every partition is full, that suggests something is wrong with where/how it's installed/flashed. Has anybody on here modded the DG834G before?

Once I can get OpenWRT to keep its settings, this box is going to be a preliminary firewall (with the O2 router/modem just acting in bridge mode (presuming it can do that!)). It's main purpose is to segment the network with it's support for VLANs.

If you look at the diagram, Remus is my work PC, and it's in the office along with the existing router. There is then a Cat5 cable that trails half way around the house to the computer room which houses all the rest of the equipment.

The idea is to have Maya keep all internet traffic on VLAN1, and pass it via Port 2 to Zanex in the other room. Zanex will then act as a firewall for any external traffic, and pass VLAN2 onto my computer room network, or back along the same cable to Remus in the office. Remus will be on an untagged port, so will be oblivious to the fact that it's on a VLAN. The only tagged ports will be the two that connect Zanex and Maya.

[2] Zanex

Router, firewall, DNS and DHCP.

DNS

Started on DNS yesterday (albeit a dry run on Zeno) with help from this guide, and it all seems to work fine, as can be seen using dig on zanex:

Code:
root@zanex:/home/lm# dig xenon.lmorgan69a.doesntexist.org

; <<>> DiG 9.5.1-P2 <<>> xenon.lmorgan69a.doesntexist.org
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 8731
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;xenon.lmorgan69a.doesntexist.org. IN    A

;; ANSWER SECTION:
xenon.lmorgan69a.doesntexist.org. 38400    IN A    192.168.1.20

;; AUTHORITY SECTION:
lmorgan69a.doesntexist.org. 38400 IN    NS    zeno.lmorgan69a.doesntexist.org.

;; ADDITIONAL SECTION:
zeno.lmorgan69a.doesntexist.org. 38400 IN A    192.168.1.10

;; Query time: 0 msec
;; SERVER: 192.168.1.10#53(192.168.1.10)
;; WHEN: Sun Jul  5 20:42:33 2009
;; MSG SIZE  rcvd: 101

root@zanex:/home/lm#
However, I am having a strange problem - when doing an nslookup or a ping, the reverse DNS string is being appended to the name - a la:

Windows (Xenon)

Code:
C:\Users\Luke>nslookup google.com
Server:  [B]lmorgan69a.doesntexist.org.1.168.192.in-addr.arpa[/B]
Address:  192.168.1.10

Non-authoritative answer:
Name:    google.com
Addresses:  74.125.127.100
          74.125.45.100
          74.125.67.100
Linux (Zanex)

Code:
root@zanex:/home/lm# ping zeno
PING zeno.lmorgan69a.doesntexist.org (192.168.1.10) 56(84) bytes of data.
64 bytes from [B]lmorgan69a.doesntexist.org.1.168.192.in-addr.arpa [/B](192.168.1.10): icmp_seq=1 ttl=64 time=0.161 ms
64 bytes from lmorgan69a.doesntexist.org.1.168.192.in-addr.arpa (192.168.1.10): icmp_seq=2 ttl=64 time=0.209 ms
^C
--- zeno.lmorgan69a.doesntexist.org ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.161/0.185/0.209/0.024 ms
root@zanex:/home/lm#
Anybody any idea why it's doing that? I know it'll be something stupid, but gave up looking at 4AM last night :p

Update:

Figured the above out, or rather a colleague did - I'd forgotten the . on the end of the reverse DNS string :o DNS is working now; just doing some more testing.


Firewall


Think I'm going to just stick with iptables, as it's the firewall I know most about or rather have the most experience with. Though just for arguments sake - is there anything else I should be looking at?

It would be nice to have a web interface for iptables, as I don't always want to shell into a box and debug tables for a simple problem. The initial configuration will be done via the command line though, merely as a test to prove I can actually do it.

Just thinking about it... is this a stupid place to have a firewall? Should I just be using iptables on Maya? Furthermore... should Maya look after all the essentials (DHCP/DNS/Firewall/Routing)?

I suppose that could make more sense in hindsight. However, Zanex will still have to act as a gateway/firewall in order for the VLANs to work...

Hmm, confused myself now.

Routing

I've used OSPF on Cisco routers in the past, and as such I've come to like dynamic routing protocols for their ease of use and reduncancy. I realise in a small network such as mine the needs are small, and it could all be done statically.

However, this is as much about taking on new skills as being practical. As such, I've been doing some research into Quagga - has anybody used it before? And if so, any good links to how-to's or docs?

Zanex is also going to be my OpenVPN gateway for work, and also as a OpenVPN server for my own network. The purpose being that I can access my (remote) work network from anywhere on the internal network - and also, if I'm working remotely from anywhere, I connect via OpenVPN to my server at home, and can then route through to my work network via the VPN. Just to clarify before I go any further with this, does anyone know if it's even possible to have a single box acting as both a server and a client?

DHCP

DHCP Setup is going to be pretty simple. I'm going to do DNS mapping, so the entries are going to look like:

Code:
host xenon{
        hardware ethernet 00:1d:09:35:dd:2d;
        fixed-address xenon;
}
I'll then have a pool of five for random clients to connect, however I want to be warned, by e-mail or indeed text if possible, when an unknown MAC address connects. My first thought would be to use logwatch and filter using a regexp or similar for the suspicious DHCP requests - does anyone know of a better way to do this?

It would also be awesome if unknown clients are only allowed out to the internet, and not allowed to reach anywhere in the internal network. What would be the the way to do this? Plug another network card into zanex and hook up WAP1 directly, and then do firewalling on there?

[3] Zeno

Zeno is to act as:

  • Web Server (Apache2)
  • GlassFish Java WebApp server
  • TFTP/PXEboot Server
  • SVN Repo
  • Mail Server
  • SSH Server
  • Kerberos PDC
  • OpenSSL Certificate Authority
  • Usenet grabber (SABnzbd)
  • Transmission client
  • iSCSI client
  • Asterisk Server
In addition to this, it's also my 'day-to-day' Linux workstation, and sits on my desk along with Xenon.

Web Server (Apache 2)

Going to host a basic, publicly accessible WordPress install, already hacked together a WordPress theme here. It isn't going to be a blog as such, just giving links etc to things I've found useful.

In addition to that it'll host a web interface for the underlying mail server, haven't quite decided on what interface to use. I really like @Mail's interface, but the fact that it costs a couple of billion quid to buy a license, I may avoid using it. What's currently 'the best' in the webmail stakes? The only one I have any experience with is squirrelmail, and that had a pretty awful GUI when I used it last (albeit a few years ago now..).

GlassFish Server

For use with NetBeans; have yet to set it up in Linux/manually, but I imagine a simple apt-get will get it halfway there.

Just had a quick look in apt-cache, apt-get install glassfishv2 looks like it'll do it. Will have a play with that tomorrow.

TFTP/PXEboot Server

The idea behind this is to have imaging across the network, to an iSCSI target on Archos. To backup an entire workstation/laptop, all I want to do is reboot, select network boot, and then have pxeboot load a linux rescue CD, which in turn auto-diskdump's any partitions.

This could potentially be a lot of work, and at the moment is low priority.

Subversion Server

Got this all working today, and imported all my existing Java projects via Netbeans on Xenon. Install was pretty painless, used this guide whenever I got lost/stuck.

However, it's only working over HTTP at the moment, and so passwords are sent in clear text. Once I've got my OpenSSL CA set up I'll move it over to SSL using the rest of the guide mentioned above.

Mail Server

Now this is one thing I have little experience of: setting up a mailserver. We use exim in work - should I stick with that? Any advice on this subject would be gratefully received.

Update (08/07/09):

Decided to go with exim and cyrus, using the guides here and here. Tis a work in progress, just going to take another look at it in a minute. I mistakenly installed both services on zanex instead of zeno :o Teach me for working so late.

I'm also looking at web based front ends for my mail server. Squirrel Mail is looking really dated, are there any others I should take a look at? Shame @mail isn't free, it's excellent in GUI terms.

SSH Server

Pretty much bog standard. However, I want external access to only be allowed if a certificate is provided as well as the usual credentials. The thing is that I use Windows on my laptop, and so I'd need to pass the cert via Putty. Does anybody do a similar thing at the moment?

Kerberos

Ideally I'd like Kerberos authentication on all of the Linux machines, so after a kinit lm/admin I can then shell to any other box and authenticate using my keberos ticket from there on in...

This isn't something I've looked at in great depth and so I'll have a lot of reading ahead of me I'm sure. With that said, reading this article/post it may be easier than I'm lead to believe...

OpenSSL CA

I'm currently porting over the OpenSSL config from an old VM, though I'll probably recreate the whole thing from scratch anyway as it's a bit of a mess as it stands. I'd like to have the CA publicly accessible so the CRL can be accessed via the cert's inbuilt URI. The CA will also be responsible for key and cert generation for OpenVPN.

Usenet/Transmission/iSCSI client

I'm going to run the clients on Zeno, and have them save via iSCSI to Archos... simple as that really, though I doubt in practice it will be that easy.

Asterisk Server

I've set up a working Asterisk server in the past using AsteriskNOW in a VM (purely as a SIP gateway), and after a brief learning curve (namely learning the asterisk conf file) everything worked smoothly. However, that was cheating - I want to now set it up from scratch (from binary, not source :p) to really get to grips with it. I'm also planning on buying a cheap Cisco IP phone off eBay considering they're now around £40. Yes, I'm only buying it for the ringtone - "du-du-duu-dooo" :o

[4] Archos


A relatively low powered machine with a shed load of storage. Currently have one 250GB SATA drive, and 1 x 250GB, 1x 500GB, 1x 300GB external drives to donate to it.

However, considering everything minus the 250GB SATA drive is already full, I'm going to order two 1Tb drives on Wednesday, and two further 1Tb drives a month later (no guesses for why :p)...

I'll then decide what RAID configuration to have them in. The idea will be to have the 4 1Tb drives in RAID (either two arrays in RAID1 or RAID10), and have the external drives as expendable dumps (for downloads and backups etc).

However, without splurging on a hardware RAID card, I don't know if I'll be asking too much of an old P4 system to do two software RAID arrays. Even if it does run and work fine, will it be dog slow?

There is also the great debate of what to run on it, FreeNAS or OpenFiler... currently I'm siding with OpenFiler, as it's a generally more polished product and the word on the 'street' is that development has slowed on FreeNAS. And whilst FreeNAS has a wider support for protocols etc, I just want this as a dedicated storage box, with apps like transmission running on Zeno. Also, it's built around FreeBSD, and I've had issues with hardware in the past...

----------------------------------------------------------------------------

Things that I wish I'd known when I'd started


This segment is for the stupid little things that would have saved me an awful lot of time wasted had I known them when I first started playing with Linux...

Bash

bash#> CTRL-R
- search through your bash history
bash#> sudo !! - repeat the last typed command as root
bash#> !55 - repeat the 55th typed command from your bash history (view your history by using the history command)

bash#> Alt-. - Add the argument to your previous command to the terminal (keep pressing it to cycle). (Submitted by vidda)

$ while [ 1 ] ; do command1 ; done - run `command1` on a loop.
$ while [ 1 ] ; do command1 ; command2 ; sleep 10 ; done - run `command1` the `command2` on a loop every 10 seconds.
$ mount | awk '{print $2}' - print column 2 of a tabulated output (replace mount with the command that produces the output)(this is called using a hammer to crack a nut, as awk is a whole nother programming language), you can also set the delimiter by hand.
$ grep -i terms /file/to/search - case insensitive grepping.
$ grep -v terms /file/to/search - inverse grepping.
$ command | grep terms - grepping the output of a command.
$ command | wc -l - count the lines of the command output.
$ echo $(($NUM+9)) - do maths between $(( and )), in this case adding 9 to the variable "NUM".
$ ./configure && make && sudo make install - && does the latter command only if the prior command returned status 0 (ie. it worked).
$ echo $? - show the status code of the last command to run (remember echo is a command).

(Submitted by BigglesPiP)

-------------------------------------------------------------------------

Well, that's it for now. I'd welcome feedback/advice/criticism on any aspect of the above.

I'll try and keep the thread updated as often as possible.

EDIT: Damn. Huge post is huge. :o
 
Last edited:
Interesting, I think I'll definitely be keeping an eye on this thread. May I ask what software you used to create the "topology" diagram? ;)
 
Interesting, I think I'll definitely be keeping an eye on this thread. May I ask what software you used to create the "topology" diagram? ;)

A nice free (ignore the 'trial' malarkey) webapp by the name of Gliffy :) Only discovered it today after realising I didn't have Visio installed and doing a 'I'm feeling lucky' search for "online visio" :D

Much better than Visio for knocking up quick diagrams too :)
 
hmm, Interesting.

My network (in MS paint):



Pretty simple TBH, other than the Dual physical networks, rather than VLANs. One day I'll make a saerver/NAS general dooby box. to take over some of the work the Fon really can't do.
 
I just completed my linux home server using debian feeding media to a PS3, 2 x computers, data backup to our laptops.

Debian was very nice to work with!!
 
TFTP/PXEboot Server

The idea behind this is to have imaging across the network, to an iSCSI target on Archos. To backup an entire workstation/laptop, all I want to do is reboot, select network boot, and then have pxeboot load a linux rescue CD, which in turn auto-diskdump's any partitions.

This could potentially be a lot of work, and at the moment is low priority.

Take a look at Cobbler https://fedorahosted.org/cobbler/ if you want something a bit funkier.

Zeno could be a CENTOS 5 server.
 
Take a look at Cobbler https://fedorahosted.org/cobbler/ if you want something a bit funkier.

Zeno could be a CENTOS 5 server.

Thanks for the tip off :) Just having a read of that now...

I'm a really big fan of CentOS, and run a small cluster on a PE2600 not included in the diagram with the help of it (currently trying to get GFS up and running :mad:)... however, for 'day-to-day' servers, i.e. servers I like to tinker with and expand etc, I can't fault Debian/Ubuntu.. or more specifically, I can't fault the package management system.

Whilst yum is great, it's no apt-get.

However, I do have a little P4 Dell unit lying around, and I could well whack a couple of Gb cards in there and have it acting as the PXEboot server with CentOS :)

Will take a closer look tonight.
 
BigglesPiP - is that eeepc running the Matrix? So much for performance vs. battery life :D

The thing that stops me doing something similar is the lack of a wired network. I'm stuck with wireless 802.11g which is good for Internet usage and not much else.

I'll be interested to read about the web server and mail server.
 

Things that I wish I'd known when I'd started


This segment is for the stupid little things that would have saved me an awful lot of time wasted had I known them when I first started playing with Linux...

Bash

bash#> CTRL-R
- search through your bash history
bash#> sudo !! - repeat the last typed command as root
bash#> !55 - repeat the 55th typed command from your bash history (view your history by using the history command)

Here's another little neat one:

bash#> Alt-. - Add the argument to your previous command to the terminal (keep pressing it to cycle).

Example:

bash#> mv /path/to/file /new/path/to/file
bash#> vim 'Alt-.' -> /new/path/to/file

Not many people know it, however it's really useful! :D
 
BigglesPiP - is that eeepc running the Matrix? So much for performance vs. battery life :D

That's my screensaver. :D



And some tips:

vim:
:set number - turns on line numbering.
:set nonumber - turns line numbers off.
:syntax on - turns syntax highlighting on, use off to turn it off again.
:n - go to line number.
G - last line
A - append to end of line (enter edit mode).
dd - remove line.
u - undo/redo last change (vi), undo last changes (vim).
:%s/cat/dog/ - replace every instance of "cat" with "dog".

bash:
$ while [ 1 ] ; do command1 ; done - run `command1` on a loop.
$ while [ 1 ] ; do command1 ; command2 ; sleep 10 ; done - run `command1` the `command2` on a loop every 10 seconds.
$ mount | awk '{print $2}' - print column 2 of a tabulated output (replace mount with the command that produces the output)(this is called using a hammer to crack a nut, as awk is a whole nother programming language), you can also set the delimiter by hand.
$ grep -i terms /file/to/search - case insensitive grepping.
$ grep -v terms /file/to/search - inverse grepping.
$ command | grep terms - grepping the output of a command.
$ command | wc -l - count the lines of the command output.
$ echo $(($NUM+9)) - do maths between $(( and )), in this case adding 9 to the variable "NUM".
$ ./configure && make && sudo make install - && does the latter command only if the prior command returned status 0 (ie. it worked).
$ echo $? - show the status code of the last command to run (remember echo is a command).


Linux:
$ uptime - how long I've been on.
$ sudo -k - forget my sudo login (does it after 10 mins anyway).
 
Last edited:
Here's another little neat one:

bash#> Alt-. - Add the argument to your previous command to the terminal (keep pressing it to cycle).

Example:

bash#> mv /path/to/file /new/path/to/file
bash#> vim 'Alt-.' -> /new/path/to/file

Not many people know it, however it's really useful! :D

That's fantastic! :D

Mind if I add it to the list? Full credit given of course ;)
 
No worries, just a few other things from your newly added set of commands:

:se nu - (same as :set number but quicker ;) )
o - Put a new line after current line and start editing.
O - Put a new line above current line and start editing.

I don't think :%s/cat/dog/ - replace every instance of "cat" with "dog". works like that, it only substitutes under from your current location and below. To do a full file replacement you need to put a g after it: :%s/cat/dog/g
 
No worries, just a few other things from your newly added set of commands:

:se nu - (same as :set number but quicker ;) )
o - Put a new line after current line and start editing.
O - Put a new line above current line and start editing.

I don't think :%s/cat/dog/ - replace every instance of "cat" with "dog". works like that, it only substitutes under from your current location and below. To do a full file replacement you need to put a g after it: :%s/cat/dog/g

%s is does the whole file.

.+s does from here down the file.

.s does just this line

Nice ones on the new line though, I didn't know them.
 
Sorry for the lack of updates.

Just ordered my domain through 123-reg.co.uk - and instantly regret the decision. After using them a few years ago and having a terrible experience with them, I vowed never to do so again. Today in work a friend told me that they've changed tact and are much improved.

So I choose the domain and SSL cert, and decide to pay through PayPal for convenience. After clicking 'Pay' I'm returned to 123-crap and get shown a host of errors. Check my PayPal account and the payment has gone out, and lo-and-behold the domain isn't registered in my cPanel.

Arrrrrggghhh :mad:
 
Quick update:

I've bought one of the WRT54GL's from OcUK, and DD-WRT is now installed. The idea was to use the DG834G as the modem, and then let the Linksys do the routing.

Tested it last night and it all worked well. However, the Netgear has a slower sync speed than the vanilla O2 box. So I'm now going to as is discussed in this thread and potentially b0rk my spare O2 box. :D

Also, I've been a bit of a wimp - I've decided to use ClarkConnect to act as my gateway for the LAN and also act as my OpenVPN server. I'll still have zanex handling the DNS and DHCP though. But ClarkConnect gives me a great interface that bundles everything together nicely.

Even worse... I've decided to install SBS on my PowerEdge 2600 and use Exchange rather than a Linux based solution :o :o The reason being is that nothing but @Mail comes close to matching OWA for interface slickness.

With that said, the PE2600 is only 32-bit, and so I can't use SBS2008 (and therefore Exchange 07) - so if OWA provided with Exch2003 is crap, then I'll stick with @Mail/Exim/postfix.

Lots of things up in the air currently.

I now have my domain though - and will soon have Apache/GlassFish up and running. I'd tell you the URL but I'm not in the position to withstand the deluge of nmap's just yet :D
 
Back
Top Bottom