Showing posts with label how-to. Show all posts
Showing posts with label how-to. Show all posts

Sunday, December 2, 2007

Installing a home server -- Networking Considerations

Hopefully, if you have read by article on building a home server, you have a good idea what you want to do with your box that you will be building. My detailed tutorials are going to be from the perspective of setting up an all-in-one router/firewall/gateway/webserver/media server. You can most likely omit any of the sections and ignore what you will not be needing. If you have a hardware firewall/router, for example, you can ignore the steps about sharing the network connections and setting up the firewall. Some of the steps depend on the others, like the need to install an sql database if you wish to properly use php. But If you don't need to have a shared drive, you can skip the file sharing part.

But the one aspect of this server that pretty much cannot be ignored is that it is going to be on a network. I thought that I would lay out some of the networking concepts that I will be using in building our home servers. This is by NO means a course on networking. If that's what you are looking for, hit a search engine and see what you can find. There are literally countless pages that have as much networking info as you need.

First and foremost, lets discuss IP addressing. An IP address is like a phone number that tells others on the network where the computer is located. If you are using the machine as a router/gateway, you will probably have 2 network connections on the machine. One probably goes to your cable modem or DSL modem. The other will go into a switch or hub in your house that your other computers are going to connect to. Let's call your internet connected network "external" or the "outside" connection, and the other will be called the "internal" or "inside" connection. If you are already network savvy, the outside connection is the WAN connection, and the inside interface is the LAN. Each of these connections will have a different IP address. You probably will not have many options for your external IP. Either that interface gets its IP from your Internet service provider (ISP) automatically using the DHCP protocol, or you will have been assigned a static IP address and subnet mask. This is vital information and you will not be able to complete this setup without it.

The internal address is something I want to touch on a little bit. Your internal interface is pretty much going to HAVE to be set to a non-changing, static address. The reason for this is that you do not want it to change because then the internal computers will not know where your server is exactly, and using DHCP to configure this interface will not always guarantee this. (There are some ways to make it happen, but those are beyond the scope of this article). When it comes to IP addressing and networks, certain rules have to be followed. Your internal network most likely is a private network, so you will have to use ip address ranges in the "Class C" range. This is a special range of IP addresses that can be used for internal private networks like yours. Valid ranges are : 10.0.0.0 - 10.255.255.255 and 192.168.0.0 - 192.168.255.255. Any addresses in those range are valid and legal. For example you can give your internal interface of 10.0.0.5 or 192.168.1.1. For various reasons that will be illustrated during the XP routing section in the next article, I recommend that you assign your internal interface to the address of 192.168.0.1 with the default subnet mask. In addition to XP's special requirements, I recommend using this as your internal IP even if you are going the *nix route. It will simplify many of the subsequent steps. You do not HAVE to do this, but I really see no reason why you wouldn't use 192.168.0.1.

Next you will want to decide the way your clients will be connecting to your server. You may either run a DCHP server on your home server and assign your clients addresses automatically, or you may manually assign static IP addresses to your client PC's (or you can have a mix of the two if you follow some guidelines). To be honest, DHCP can sometimes have problems if your outside interface also uses DHCP, but I will show you how to use either way, and really this is a case of personal preference. Decide on this before you start, however.

Also, you need to think about how this machine will be administered. If you are going to want to administer your server over the internet and you have a static IP address, then don't worry, you should be able to access your static IP from any internet connected computer. If you have an ISP that gives you a DHCP address, you can never know when your assigned IP is going to change. If this is the case, hope is not lost. you can use something called a Dynamic DNS. I use No-ip, and if you are willing to use their domains, you can get an actual internet address like mysrvr.noip.com. There is a little program that we can install on the server that will let your dynamic DNS always know the location of your machine no matter how many times it may change. There are other dynamic DNS services, and you should pick one out. For a fee, you can usually get an actual domain and register it with these services like www.mysrvr.com. If you have a static IP you can just register a domain name and have it point to your static address.

Finally, you will need to know about NAT and port forwarding. NAT or Network Address Translation, in layman's terms is essentially this: As far as the outside network or internet is concerned, a request to the internet from any of the clients in your private network looks like it is coming from your outside interface ip address. If you Google NAT you will find extensive information about its nuances, but it's just a principle that says that the ONLY IP address that the rest of the world can see is your outside interface. Here's a dirty little diagram

remote computer--> Outside interface( 9.6.74.15)<-NAT Router-> insideinterface(192.168.0.1) --- client 1(192.168.0.7)

Say remote computer one is an internet web server. Client 1 types this web server address into his browser. The remote computer's web site appears. But as far as the remote computer can see, the request to display his site came from 9.6.74.15. In fact, it isn't even aware that 192.168.0.7 even exists. But how does the outside interface know to send the web site information back to client 1? It uses NAT routing. This is exactly what NAT is designed to do. Most home servers and hardware firewalls/routers use this exact mechanism. This is NAT in a nutshell.

One of the problems with NAT is that if the request for information is NOT initiated by one of the client computers, there is not a way to send any information to client 1. Say remote computer is your work PC at your office, away from your private network. Also, lets say you are not running a web server on your NAT router, but you are running it on client 1. If you type in 192.168.0.7, chance are you will get a page not found message. Thats because your office PC doesn't even see 192.168.0.7. It has no direct route to get there. So how can you access that machine's web server from your office?

This is where port forwarding comes in. You can set the NAT router to route all traffic from remote computers to port 80 (the default web server port) directly to 192.168.0.7. So any request that is made to 9.6.74.15 on port 80, will get sent directly to client 1. So after you set up port forwarding, at your office computer type 9.6.74.15 and poof, you will be shown the web page being served on 192.168.0.7. Any other port will still get processed by the NAT router, but all port 80 requests will go to client 1. You can even run web servers on BOTH machines if they use different ports. I'll touch on that during the installation of the server software.

The great part about this comes with respect to hackers and intruders. Because of NAT, the only machine that malicious intruders will ever be able to hit without being invited or knowing about your port forwarding scheme is your home server. That means that if you run a firewall on the server, you can block any malicious traffic to any of your clients. This eliminates the need to install software firewalls on any of your clients, because the NAT router blocks all of those attacks before they ever hit any clients. Cool, huh?

So do some research, get familiar with the above concepts, and in our next installment we'll begin building a windows XP based home server. I'm really looking forward to it.

Friday, November 30, 2007

Installing a home server

One of the things that I am the most proud of in my technical life has not been anything I have done at work (though there is quite alot of stuff I have done at work that I am proud of). Nope, one of the most things that I am proud of is my home server. There is alot of talk about Windows Home Server , but in my opinion, this kind of implementation is just the tip of the iceberg. It's a file server, a glorified NAS box. My home server fulfills many roles like:


  • webserver

  • ftp server

  • shared media drive

  • NAT router (yes router)

  • firewall

  • video encoder (from command line no less)

  • WiFi AP

  • streaming music server

  • remote bittorrent downloader

  • mail server

  • group ware server

  • database server

  • DNS Server

  • DHCP Server



My server fulfills all of the roles above, and can be remotely administered through ssh. The entire thing runs on commodity hardware. In fact it runs on a nearly seven year old Celeron 1GHZ with 384Megs of ram and a 17GB and 120GB hdd. That, combined with an Ethernet switch, is one powerful little network. Regardless of being a "home" server, learning how to build and use one can teach principles of large servers and corporate networks. You can even expand to include other servers and have your own little cluster.

When building a server like this, first, ask yourself WHY you want to build it. What do you need it for, what do you want it to do, are there better alternatives? Before you ask, "because it would be cool and I can learn all sorts of things" IS a perfectly viable answer as to why you want to build your own server. What you want it to do however, is something you want to spend more time on. You should try to plan a little bit for this. What role is this machine going to fulfill? Is it going to just be a firewall/router? Then perhaps m0n0wall is for you. Just an NAS device? Try Freenas . For versatility and growth however, you may want to stick with a full OS like Linux or FreeBSD . It's even possible to use some versions of Windows.
In fact, my server started as a windows 2000 server and it ran great for a few years. I'd recommend using one of the *nixes, because I find them more robust for a server, and keep in mind, even if your desktop clients are all Windows, you can still use Linux or BSD for your server. They do play nice together with a little work.

In subsequent weeks, I will take a look a closer look and give more of a how-to for setting up some of the particulars of home servers, but I'd like to make some reccomendations here on what to decide in the planning stage.

One, decide how you are going to interact with your server on a regular basis. You will most likely need a mouse, keyboard, and monitor when you set up your server, but one of my goals was to have a box that was a mere appliance, and that meant headless. All administration on my box is done remotely through SSH. I can do this from work or from my home desktop. The caveat about this is that you really need to learn how to use the command line and command line tools. But you CAN load the Xorg gui or using windows remote desktop. You are going to want to keep your box running efficiently though, and you will find that graphical interfaces take up more overhead than most of you are going to want.

Two, decide what sort of hardware you are going to run on. Even Windows 2000 can run on some pretty thin hardware. FreeBSD and Linux headless machines can run on almost a pocket calculator (ok well not THAT thin, but you will be surprised). The processing power and memory are not the only considerations. Do you want to run RAID to handle your files? How much storage are you looking at? Will you have a separate drive for the operating system than you do for storage? If you are running as a router, you will need at least two network cards. If it's also going to be an access point, you will need a compatible WiFi card. Is it going to be in a little box in the closet, or will it be on your desk? How far away are you going to be running? Do you need to run Ethernet cables? Do you want to upgrade your network hardware to gigabit speed? I personally find that 100Mbps is fine for serving video and audio, but you may want to run multiple clients and feeds. Do you have plans to backup your data on an external drive?

Three, try and figure out some of the roles that your machine will be performing? Do you already have a hardware firewall/router? Do you need a DNS? Do you want to keep everything static, or use DHCP? Do you understand the basic theory behind IP addressing, subnets and NAT? Are you going to need a database for anything (if you plan on running php web pages, the answer to that is yes)? Is it going to be on all of the time? How are you going to secure the system or your shares?

Fourth, there are some miscellaneous considerations to think about. What kind of internet connection are you going to use? How is your internet connectivity? When I first set up my servers, my ISP had blocked incoming ports 80 and 25, which are the standard web server and mail server ports. I had to run both of those services on non-standard ports. See I learned something almost right off the bat. Then there is a time factor to be considered. My server grew and evolved over time to the machine that it is now. Don't try to do everything at once. It can take quite a while to install the various things on the machine. Give yourself time. Remember, this is a project. If you need this to be a mission critical machine, you may want to familiarize yourself with commercial server technologies. This is also beyond the scope of this article.

So get prepared, think about what you want, and next week, I will give a step-by-step guide to setting up a Windows based server, and for the two weeks after that, we'll look at using Fedora and FreeBSD for a similar purpose. I'm splitting the open source version into two weeks worth, and since many of the princples are the same for FreeBSD and Linux.

Monday, November 26, 2007

Did you remove everything in the FreeBSD /usr/local/bin ?

Classic post again. This one is a boneheaded moment I had during an administration of my FreeBSD server. Since I learned from this mistake, many mistakes can be fixed on a nix based OS. Here you go.

Posted 2005-11-10

So I get an epiphany. I'll just write a script that manually deletes all of the trash out of my user's maildirs at a given time. So I was experimenting and decided to write a script that starts:

"rm -r /usr/home/*/Maildir/.Trash/cur/*"

that should do an rm -r in usr/home and the all of the users Maildir/trash/current folders.

I called it cleantrash and put it in /usr/local/bin.
I added it to the Crontab of the system to purge all trash at 3am.



Unfortunately I must have had a typo in the script. I must have written
"rm * -r /usr/home/*/Maildir/.Trash/cur/*"

because when I tested the script. I did an ls -l on /usr/local/bin


NOTHING ALL GONE

At least it isn't /usr/bin or even *gasp* /bin, but that was ALL of the binary files for all of my ports. (installed programs) Web didn't work, email didn't work...

Well just when I though all hope was lost, I figured I would rebuild portupgrade and try a portupgrade -faO.

Seemed to work at least partially. I couldn't access any of my php based hosted sites (including this one) and now I can. I HOPE this is the end of my bone-headedness. But at least with FreeBSD, almost anything can be fixed without a reimage of the whole os.

Sunday, November 25, 2007

How to become a geek in 10 easy steps.

One of the things that I wanted to do with this site was to educate people into what I think makes a "geek." "Geek" used to be a dirty word. It was a title that I did not want to have in high school. (Yet I got that title nonetheless) I suppose that it still is to some extent, but far less people are ashamed of using it to describe themselves, myself included. I wish to welcome geeks and non-geeks to this site.

I realize that there are alot of people who think that they are geeks because they use myspace and facebook all day. Sure your email box might be filled to the brim, and you may spend more time online than you do sleeping. You might have the fastest, fanciest computer on the market. You get so many IM's you need a second monitor. You might be sitting there with this smug grin on your face saying to yourself, "Oh yeah, he's talking about me." You might even have a nice, cushy job in the IT industry. However, that does not necessarily make you a "geek".

Sure many geeks do that kind of stuff. But there is a certain patina to a real geek. Geeks have a specific feeling, a sort of flair to them. It's not even tangible. But when you are a geek, you know it - through and through. And perhaps the most telling part? Other geeks know it. They can smell it all over they instantly know when they are talking to a geek. The worst pitfall though? They can instantly weed out "wannabe geeks". For some strange reason, some normal people try to pass themselves off as a geek. Perhaps they think it will help them in the IT industry (it won't), or perhaps they think that they can gain some respect among non-geeks. This method will backfire on you if you try it around a real geek. Not only will it backfire, but the geek that sniffs you out will surely tear your ego to ribbons. Trust me, geeks are good at belittling non-geeks.

Well, for those of you who are wannabes, there are ways to become a geek, but understand this: most geeks do/did not try to be geeks. They were born that way. So don't blame me if you do all these things and you still aren't considered a "geek". It's likely that if you don't get it, most likely you never will.

1. Unix/Linux COMMAND LINE USE

This one is probably one that will get you the most cred. If you can use the *nix command line, you are well on your way to becoming a geek. Heck, there are probably geeks out there that have only this requirement. Learn Bash. Learn other shells. You want to be able to administer an entire *nix box from SSH command line ONLY. I also think it is fair to say that if you can master VI then you pretty much instantly become a geek.
NOTE: Though necessary in the modern world, Gnome and KDE are not a show that you are a geek. In fact, if you can muddle through a Linux install and just get to an X gui and never learn the command line at all, then you are pretty much the textbook definition of
POSER.

2. Fanboy-ism




This one is also pretty much a requirement. To be considered a REAL geek, you have to be completely obsessed with some form of entertainment. And I mean obsessed. You are the source of all information on the subject. In fact, you know more about this than the creators of the work. There is a little latitude with this, but some good examples are Star Trek, Star Wars, Lord of the Rings, Dr. Who. You could also be a fanboy of forms of entertainment like Anime or Horror movies.
NOTE: Being a sports geek does not count. I don't care who you are or how much you know, but knowing obscure details about the 4th game of the 1974 world series isn't going to impress any geek. Knowing what the "T" in James T. Kirk on the other hand might get you somewhere. (It's Tyberius)

3. The art of the Flamewar

If you are unable to start an internet flamewar, then you need to learn. It's actually pretty simple. You just find a nice, unsuspecting messageboard where people are having a civil conversation, and you pretty much make a post telling everyone how wrong they are. The art of it, and this is something that only geeks seem to have mastered, is keeping a flamewar going for a long, long time. Bonus points if you know that you are totally wrong, but you start a flamewar anyway. Remember, politics and religion are the best ammo for this.

4. RPG's


Since Dungeons and Dragons came out, it has been a refuge for the geek imagination. Other RPG's are good too, but I am specifically talking about pen and paper RPG's. Computer and console RPG's count to some degree, but there is nothing geekier than dice and books. ALL NIGHT LONG. Yes, participate in an all night RPG session, and chances are you will climb that geek ladder that much faster.
Live action RPG's or Larps, are another insta-geek thing. If you LARP, you probably are a geek.

5. Old school

Geeks are all about "old school". The concept is kind of hazy and ambiguous but trust me, if you want to be a geek, you have to be "old school". This is another one where you have a little latitude. you can be an old school gamer/programmer/hacker, and this includes things like Interactive Fiction, Sierra or Lucasarts adventure games, old Unix distros, programming in FORTRAN, using BBS's playing a MUD, using gopher, the list goes on and on. It doesn't really matter if most of these things happened before you were born, you just need to learn how to be old school. And you have to constantly complain that things aren't like they used to be. For example, "DSL? Pfft. I used to log on to bulletin boards all the time and get stuff on a 9600bps modem. " Now that's old school.

6. Pr0n

Not a single geek is EVER going to admit it but geeks are experts at finding porn. And they all have tons of it. Like I said every one of them will argue to the last breath, but just because it's well hidden, doesn't mean it isn't there.

7. Freedom

Geeks love their freedom. Okay, maybe not politically, but geeks love to have freedom in the digital world. Being involved in an open source project is like getting a geek tattoo. Many geeks will not use anything but free software. Whereas some of the above geek attributes are parodies, I actually agree with free software. But for this to be geek necessity, you must understand, you have to be a Nazi about it. Here is a little example of this attribute at work:

User: Hi, I was having a problem with IE. It seems to crash on a specific page and it takes down my whole computer. can you tell me how to fix it?
Geek1: Switch to Linux.
Geek2: Get rid of Windows.
User: Right but I have to use IE for this.
Geek1: If you don't use Linux you are stupid.
Geek2: Linux is superior in so many ways.
User:But that doesn't solve my current problem...
Geek1: Hey man if you wanna be part of the Borg, this is the kinda stuff M$ is gonna pull. Switch to Linux and help us fight the MAN!

See, the geeks didn't even try to help this user. They didn't even let him speak. Now THAT is freedom at work ladies and gentlemen. Everyone is free to make their own decision about their operating system. As long as it's Linux. Notice that they didn't try to fix the problem that the user was having. You can usually see this in action by a geek's constant use of cute little symbols and sayings: M$, Microshaft,Winblows, etc. Strangely, BSD users don't seem to suffer this kind of affliction, they just seem to be happy using what they like.
NOTE: There are also multiple kinds of free. Free as in beer, free as in speech, free as in not wearing any underwear... you name it.

8. Slashdot


If you really want to get good at the above skills, hang out on Slashdot. On it's own, its actually a really good news site. The comments section however? Oh yeah. That's were you separate the men from the geeks. It's the veritable Mecca for geeks. And every geek on that site knows everything about everything. Really, just ask them.

9. The constant critics


Ever see a movie that sucked? Sure, everyone has. But to a geek, EVERY movie sucks. Geeks are never satisfied with anything. EVER. Oh sure you get some geeks that actually like George Lucas now and again, but most geeks will say that everything sucks. Modern video games: they suck. Modern music: it sucks. Movies: they suck. The current Internet: it sucks. You don't even really have to hate these things, but never admit to liking anything that is popular. EVER.

And finally:

10. Vastly inflated self worth

As a geek, the most important and smartest genius in the universe is you. You can't be a geek without that I'm-so-much-better-than-you mentality. Oh sure lots of people on the planet are like this, but with geeks, almost every one, without fail will have this quality. They can solve all of the world's problems, they know what is good and not good and they all are capable of doing anything, they just don't feel like it.
Like nuclear war, geeks could stop it, but the world doesn't deserve to benefit from said geek intelligence. But it's not only intelligence. If you ask them, every geek on the planet could kick your ass, if it wasn't for their asthma or shin splints or glasses or whatnot.
And it doesn't stop there. Geeks have a long history of taking credit for things that they couldn't possibly have done. Oh you know that stock market crash in 2000? Oh yeah, that was them. hacking the CIA? Yeah they all did that too. The Chicago fire? Yup you guessed it. Geeks.


So there you go, follow these steps and you too will be a hardcore geek. But don't forget I will always be more hardcore than you. ALWAYS.