Networking

Setup DNS Cache Server Using Dnsmasq and Ubuntu

dnsmasq

I’m always looking for ways to improve on my LAN, especially when it’s free. A friend suggested DNS caching to speed up browsing. I gave it a shot and was impressed with the results. I’m now saving at least 70ms for every DNS query (after it’s been cached the first time of course.) The installation is pretty simple, and takes only a couple of minutes. I’ve logged what I have done getting it running on an Ubuntu 8.04 machine:

Notes before starting: I didn’t need much for this system setup. The machine has a P4, with 512mb RAM. The NIC was only 100mbit, and the hard drive only 40GB. I chose a box to install this on that isn’t pegged with other processes. I don’t think you need to dedicate a whole box to this project if this is for a small LAN (mine is ~10 machines), but one that isn’t constantly being used for network tasks would be a good idea (not much of an incentive to run DNS locally if it doesn’t speed up the response time.) These are just my recommendations, and it will vary depending on the size of your LAN on what you would like to setup. There are many variables differ based on your setup.

As stated before, for this installation I’m using Ubuntu 8.04. I installed the server edition, but eventually installed the ubuntu-desktop packages, because I like having the GUI when working with experimental servers. Obviously, using the ubuntu-server edition will slim the machine down and be much more efficient.

1. Open Synaptic package manager and search for “dnsmasq”. Install both packages shown by right clicking “Mark for installation”.

2. Navigate to System > Administration > Networking to open the network configuration for the machine.

3. Click on the tab “DNS”. This is the list of name servers for the machine. You can keep the original name servers in the list but press “Add” on the side and add in “127.0.0.1″, and make sure it is at the top of the list. For your secondary name servers you may want to consider moving to opendns versus using your local ISP’s.

4. Once your 127.0.0.1 entry is at the top of the list you may press OK to exit the menu.

5. To start/stop/restart dnsmasq service use the following commands:

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

You will most likely need to restart the service after installation and the changes you’ve made. This will also let you the service is starting correctly.

6. Now it’s time to make sure it’s working. Type the “dig” command with the website of your choice and pay attention to the query time. The first time the DNS entry will be cached, and so the second time you try the dig command on the same site the response should be significantly lower. The format is $dig WEBSITE

Another way of testing is enabling logs to syslog so that each query will be logged. You can enable logging by removing the # at the line #log-queries in the file /etc/dnsmasq.conf You will need to restart dnsmasq for changes to take effect. Syslog can be viewed from System log viewer, or any text editor. After verifying that everything was working correctly, I added the # back into the config file so that it no longer logged queries.

7. After you’ve tested all is working correctly, make sure you change the primary DNS server on the client machines to the IP address of the server you have been working on. Here are pictures that show the primary name server being changed to the local machine just setup for DNS. The examples are for Ubuntu 8.04 and Windows XP:

ubuntudns
vistadns

So that’s it. Hopefully this speeds things up for you as it did for my LAN. Thanks for reading.

Creating NAS In 10 Minutes

NASbanner

Network Attached Storage has become increasingly popular the last couple of months. Interest has only grown more since apple’s release of Time Capsule which is a NAS device that also has the capabilities to create incremental backups of computers on the network. NAS can be very useful for any home network with a lot of media. It also places less load on other computers on your home network. Being a technician I hear countless times how all the client wants is pictures from the machine and some home videos, etc. All of this media can be moved to a NAS device so that if a system goes down all can still be accessible from another machine quickly. Backups are also essential in that equation, but it can easily be achieved with an external Seagate drive or countless others. What I would like to discuss today is the use of this free NAS software (with TONS of features for sharing media) to get media shared in less than 10 minutes. This may be extremely useful at LAN parties for those trying to share content to one another (perhaps the latest 600mb patch of Battlefield 2!) Also, this method allows the computer to run the NAS software without disturbing the original OS. Just like any other linux live CD, FreeNAS (freeBSD based) has features that lets you boot from a CD or USB drive. If you need more information on NAS devices to see all the possible uses check out the wikipedia entry.
There are many different configuration options for getting it all up and running, but I will go into detail about that which I found to be the fastest. A few things to note before going through these steps:

-you do NOT need to remove all partitions on the machine you intend to setup as a NAS device. You may if you want to, but it doesn’t really matter unless you are performing a full installation or would like more storage space. You can leave everything intact, and there will be NO changes to the OS if you follow steps as I direct. If you stray from the path you could easily end up formatting the drive, but there are warnings before this would happen as well so don’t worry too much.

-you will need to know how to burn ISO’s onto a CD, just like any other linux distro.

-you do NOT need a lot of technical experience to get it up and running if you just follow this guide. Though the more knowledge you have about your computer hardware the better.
-you do NOT need know how to use linux, or BSD, or even know what they are. If you have hardware problems any time throughout this tutorial you could always hop over to the support forum and someone should be able to help you get on the right track.

-for default setup to work without changes you will need to already have an address such as 192.168.*1*.25. The *1* being the key factor there. Some routers by default are setup on different ones such as 192.168.0.1. It depends on the network.
Alright lets jump right into things. I will explain it step by step as all my other tutorials.

1. Download the ISO here and burn it to a CD.

2. Place the CD you just burned into the drive and boot up. You may want to have your keyboard and monitor hooked up to the machine to make sure your CD ROM drive has 1st boot priority. If it does not, simply go into your BIOS and change the boot order (there should be a button to hit such as F1, DEL, or F10).

3. Your CD should start booting the software automatically. Within about

2 minutes (if there are no errors) it should boot up for you and show the splash screen. You can press Enter and configure options (such as machine IP or connection to use such as wired or wireless) but it is up and running at that point. Note: the only thing your computer actually needs plugged in in the back is power and the data connection (which you would need none obviously if it is wireless).

4. On another machine on the same network open up your browser of choice and type “http://192.168.1.250″ into the address bar. This is the default HTTP control panel for FreeNAS.

5. Hit enter and you will be prompted for a username and password. Default username = admin. Default password = freenas.

6. Hit enter and you will now be at the main page. This is a status page and can give you some basic information about the system. Lets navigate to the left hand side and go to Disks > Management.

7. On the lower right side there is a + in a circle for you to add drives for it to recognize. Click to continue to the next screen.

NASdisk

8. You will need to choose your Disk (make sure and do NOT select your CD ROM drive) to setup. Find your hard drive on the list. Also make sure you select the format type of your drive (if the drive has windows installed on it you will choose NTFS. Click “Add” once completed. Repeat this process for any other hard drives installed in the machine if any.

9. Hit apply changes on the Disk Management screen. It should say “the changes have been applied successfully. If it does not you most likely made a mistake when configuring the disk.

10. Go to the Disks > Mount Point menu on the left side of the window.

11. We are now going to create a mount point for the drive. Click the button on the lower right to continue.

12. Choose your configured disk under the “disk” drop down menu and make sure you select Partition type 1. I’m going by the assumption that most users are going through these tasks with an NTFS formatted drive. Go to the drop down and select NTFS. Name and describe the drive as you wish (note that it is limited on the types of characters, it may be that it only allows spaces, numbers, and letters.)

13. Press the “Save” button and click “Apply Changes” on the following screen once you have configured all of your drives. If it says that all changes have been applied successfully the hard part is over and it is configured. Now we are going to verify, and setup a means by which your files are accessible over the network.

14. Go to Status > System on the left hand side. Look at the “Disk space usage” box at the bottom. It should show your configured drive there along with how much space has been filled on the drive. If all is there then the drive is configured properly and is reading correctly under FreeNAS.

NASdiskspace

15. For the sake of saving time I am going to assume you do not want any security on this box for the time being and will allow anonymous connections for sharing. You may configure them if you wish in the Access > Users and Groups menu. Lets go to the Services > CIFS/SMB menu on the left side.

16. Once in the menu you need to first enable the sharing service to run by clicking the checkbox in the upper right hand with the text “enable”.

17. Click the “Save and Restart” button at the bottom (note: this will just restart the service, not the computer).

18. After changes have been applied, go to the top and click on the “shares” tab.

19. Click the + button

20. Create a share name and comment. You may leave path blank. All other options should be okay by default. Hit the “Save” button and the “Apply Changes” button on the next screen.

21. Now close out of your browser and just open “My Computer”. Replace the text in the address bar to “\\192.168.1.250″ and hit enter. You should see your share listed below as a folder. Open and view, edit, save, delete your files just as if it was a locally connected drive.

NASaddress

Now a few closing notes. There are a lot of options we left blank, a lot of thing we could have changed with this system. Spend some time messing around with it, just be carefull of the “Format” menu. Because this is a live boot all changes you make will NOT be saved once the computer is powered down. You will need to reconfigure all of these settings as we have in this tutorial. After doing it a few times this should only take 5 minutes or less to reconfigure in the future. FreeNAS can also be installed as a full or embedded install. I will not cover this today but may in a future entry. If you are having any difficulties throughout the setup process head over to the support forum for help. Hope this gets you going on creating a NAS device for free.

Setup Remote Desktop in ubuntu 7.10

This is an in-depth tutorial covering the simple act of setting up Remote Desktop in 7.10 and forward the ports on your router so you may access your ubuntu machine from anywhere. I find this handy when in a different city and needing to access a file on my local network. I merely plug my USB thumb drive into the computer, run my portable Ultra VNC Viewer, and connect. I also use it to work in Linux instead of windows (because it is setup to the same screen size as my laptop. I just full screen the VNC connection and work in ubuntu; however I do have to stand connection issues).

So I will go slowly and step by step through this procedure as well. 7.10 makes it EXTREMELY easy to get it up and running, so you should be able to get it up and running in 5 minutes or so.

1. Boot up ubuntu of course and login.

2. As shown in the picture, on the ubuntu menu, go to System > Preferences > Remote Desktop.

gotordp

3. This will bring you to the Preferences window. Check “Allow other users to view your desktop”

4. Check “Allow other users to control your desktop” if you want the user to be able to actually control the mouse and keyboard once logged in. If you are merely letting people login to view your desktop then you can leave it unchecked.

5. Uncheck “Ask for confirmation”. If you have this checked it will make a confirmation window popup every time a user tries to connect remotely. The local user will need to allow them to connect before they can begin their remote session. If there is no local user to confirm this, and you are on a trip and forgot to uncheck it… you sir are SOL.

6. Check “Require the user to enter this password” and enter in the password in the text box below. The remote user will be prompted to enter this password before they are given access to the remote machine. This is a MUST. Otherwise, anyone who connects to that address will be able to control your machine remotely as they please.

rdp

7. Click the close button to close the Preferences window. Your remote connection is now setup for your LAN and you may access that ubuntu machine from any other pc on your network without port forwarding.

For those of you familiar with port forwarding, don’t bother reading the next section because it’s merely a step by step. Basically, forward a port of your choice to port 5900 for the ubuntu machine you are setting Remote Desktop on.

8. Now for some simple router changes. First, we are going to need to gather some information. The gateway and the IP address of the ubuntu machine. This is easy to find out. First, lets open up our network connection by going to System > Administration > Network.

9. Click on the connection type you are using. In my case I am using a wired connection. I would suggest using a wired connection if you are planning to routinely use this machine remotely because it tends to be a lot more reliable than wireless.

10. This will bring up a window with your connection settings. If you are using DCHP then you can’t gather much from this. I recommend switching over to Static IP address (but beware, that this must be enabled in your router, but is usually already enabled by default). I’m not going to go in depth with a lot of router settings, so if you have questions about functions such as router access or static configuration, Google it!

ifconfig

11. Write down the IP Address of your machine, and also the Gateway address. We will need this soon.

12. Open up a web browser and type in http:// and your gateway after. For example http://192.168.1.1 this should bring up the login screen.

13. You should be able to login now. Make sure you have permission to edit your router. If you have another LAN administrator, check with them before logging in and making any changes.

14. This is a part that is different for everyone depending on your router type and model. I am using DD-WRT on a crappy wireless router. All you need to do is go to the section regarding port forwarding.

15. Once you navigate to this section, we have a port to add (to allow the outside connections to this computer on your LAN). The default VNC port is 5900. Your router may have different names for some of this, but it all should be relatively similar. My example is listed in the picture below. So, let me explain what it all means.

portforward

Application: A brief description of what you are forwarding so that you can quickly reference it. I just named it ubuntu because I know that port 5900 is VNC so I don’t need to know the application.

Port from: this is the port the machine not on your LAN will try to make a connection from. It is suggested to make it something that is not the normal 5900 because this is a dead giveaway for attackers. I just made this one 8000. (Be careful, some ports are reserved for certain applications, so if you aren’t sure, Google the port before you choose for sure).

Protocol: TCP and UDP. Can’t remember if VNC needs both, so just go ahead and click both.

IP Address: this is where you will enter in the IP address you previously wrote down. This tells the router what machine to make a connection with.

Port to: set this to 5900. This is the port that the remote desktop application will connect on.

Enable: obviously we want to enable this.

16. After making the necessary changes, you will need to save the new settings, and most likely restart the router for it to take effect. It is a good idea to log back in and make sure the settings saved correctly.

17. Alright, so now you have setup Remote Desktop on your machine, and forwarded the port on your router so you may access from the outside. So, how do you connect? Well… this is a complex question. It really depends on your connection, and if you are on a residential where the external IP changes every few hours or days. If it does then you will need to find a solution such as NO-IP that sets a name while it tracks changes in your IP, and changes the name to that. I won’t go in depth with that so ill just post this link if you need more information. http://www.no-ip.com For a temporary test, lets just use www.whatismyip.com

18. Copy paste your external IP (given from the link above) and :port number into your vnc viewer and test. For example 12.35.33.58:8000 will be your connection if “12.35.33.58″ is your external IP. NOTE** you cannot connect to your external IP from a machine in your LAN. You must test from a computer outside of your network for it to work. After all, this is what you set up the port forwarding for.

19. At this point, if you have a successful test, you are setup and good to work remotely on your ubuntu machine. If you cannot connect, you may want to check that your IP has not changed, and go through our configuration process once again. If you have any simple questions you may refer to the ubuntuforums (which has great user support) or try googling some troubleshooting options.

Whew, that was a little more in-depth than I wanted to get with this simple procedure, but I do want to give as much detail and help for new users as possible. Hopefully this helps one or two of you. Please check back for further Ubuntu 7.10 user tutorials in the near future.

Here is the VNC Viewer I use and enjoy. RealVNC is decent as well. http://www.uvnc.com/

Cracking WEP – Some Words of Wisdom

wificards

Cracking WEP may be a little more difficult than you think. Yes, we’ve all seen the WHAX video of how to crack WEP in 10 minutes and said “yes I could do that if I had time to get the distro… but I have more important things to do.” Well, being a college student with no social life (during the week anyways), I have had the time to have some fun with cracking WEP. Of course, in a lab environment (using my own router to practice with…). Throughout my experimentation, being also new to Linux, I found a few things you may soon realize and should research before attempting to crack WEP that may either encourage you to continue with this activity or give up entirely (but let’s remember, that’s not how you solve problems : ).

Monitor Mode:
A lot of people new to this whole scene think that they can pickup any wireless card, pop in their super secret Linux distro they got from another “computer kid” and “crack the neighbors’ internet for downloading music!” First of all, those who are interested in WEP security and vulnerabilities for this purpose are idiotic and deserve to be caught and prosecuted. There are a lot of people who think that the term “hacker” is cool and buys them popularity points. These kids are easy to point out, and are easily exposed. Don’t get me wrong, I am on no soap box preaching to the naïve and ill informed underneath me…I don’t claim to have any extensive knowledge on this subject. I’m as lost as any other geek trying to get this security stuff figured out and trying to have a little fun with it and share my experiences.
Alright, back to the point I was trying to make before I went off rambling. Monitor mode. This is where the wireless card captures packets without associating with the AP. Monitor mode is only supported for certain cards, and I believe only certain chipsets, but I could be wrong on that one. My original card (Orinoco gold classic FCC ID#
IMRWLPCE2411R) was able to switch to this mode which was great to get started. Do a Google search and see if yours is supported by installing specific drivers or natively. If it doesn’t, you are probably out of luck. Don’t waste your time looking for a way to do it without monitor, in my opinion; you are better off spending that time finding the right card to get instead. I will talk about cards later on. This is usually the 1st issue where those new to WEP cracking get lost and trail off to their social bookmarking site instead.

Card support on OS and program:
This somewhat ties into the monitor mode issue in regards to having a working wireless card. There are a few ways to go about WEP cracking, but the fastest and most effective/popular method I have found is using the aircrack suite. With this you can do just about everything. You will need to capture the packets and use injection to make the process move along more quickly. So, you’ve got a card that supports monitor mode, great! Now is the other thing your card needs to be compatible with, aireplay (included in the aircrack suite). This is the application that will perform 802.11 packet injection. 95% of popular wireless cards are not compatible with this application. If you want to capture packets without injection, but be prepared to sit at that AP for 2 weeks to get enough IV’s for an attempt at cracking.

The other issue is OS support for your card. You may also be lucky enough to have a card that is natively supported in the distro that you choose to use for cracking. However, there are many that require patches, or special drivers. In fact, almost all of them do. Some distros are nice enough to include a patch for your (S-T-D for my Orinoco). Once again, if you are new to Linux, if you think you can figure it out go for it, but if you are running into this as well as the monitor mode and packet injection issue, head to the store, not the BackTrack2 forums for help.

Don’t know how to spoof a MAC? Learn or forget it!
Not that I encourage any illegal activities, and I DO NOT, but to be a good security expert, you need to know what the attacker will do to be able to counter-act. MAC spoofing is a great way to stay anonymous. Now this is an easy thing to learn quickly, but if it’s forgotten or disregarded, then you aren’t really doing it properly. A great simple program I found for this purpose is macchanger. I simply type “macchanger -a eth1″ in my terminal before beginning my test cracking. Simple and effective. This is just kind of a general warning that if you don’t know what you are doing then learn before doing anything. I would love to hear the story of someone who used this knowledge for the wrong purpose and got caught because they didn’t know how to spoof a MAC.

How much are you willing to spend?
Is this just a “Saturday afternoon project” sort of thing? If so, and you are lucky enough to already have a supported card, great for you! If you are like the other 99% of us who had to troubleshoot, again, you may want to consider investing in the right card. I took this route, and just got a deal on eBay for a newer proxim 8470. There are also a few prism 2.5 cards with an amazing 300mW of radio output power. If you have the budget, I would highly recommend them! Also, and antenna is almost a must! These can be relatively cheap, but none the less, adds to your cost.

Do you know Linux?
If you don’t, well this is a great project to get started. However, it’s not exactly user friendly to get started! If you run into any snags you will need to troubleshoot. Following the YouTube video never works hehe. This is a great way to get more familiar with Linux. That is what I did, and I have loved the knowledge I’ve gained from it.

The monitor mode I spoke of earlier not supported with the windows drivers. You can buy an awesome adapter called AirPcap that is said to be great, and work swiftly with Cain. The catch: this adapter is $200. Yikes!

All of the other programs I have found in windows for WEP cracking really suck, and don’t work AT ALL. Like I said, the airPcap is the only one with a reputation of working well. Airsnort has a windows version, but I have tried that too and it didn’t work. Perhaps you can get it working though. I didn’t spend much time on the windows side to find out.

So that is my rant about some common issues with WEP encryption, kind of a heads up for hobbyists, as well as an outlet of frustration with my own experience. Perhaps I will crack a WEP cracking video tutorial once I get it all working correctly with my new card (which is on its way as we speak : ).

Once again let me say that I am no credible expert on this subject, merely a hobbyist and a geek wanting a new project. I’ve spent about a month involved in this topic, and thought it was a worthy entry to write. If I’m wrong on some of my facts, please correct me! Send me an email and I will make sure to change it. Thanks for reading.

5 Uses for an Old PC

Got that old family computer laying around just gathering dust? You hate to throw perfectly good hardware away, and so you toss it aside and say “I will figure something out to do with it eventually”. Well, here are a few ideas I have had in similar situations, all of them turning out to be quite benificial and usefull for old hardware. There are endless ideas and possibilites, but here are 5 pretty basic projects.

1. Experiment with Linux. Linux is a great thing to be at least familiar with. Just grab a “Live CD”, either by downloading or ordering, and boot your PC to its CD-ROM drive. You can then experiment in this environment without making any permanent changes to the system. For those really looking to further their understanding of linux, I would recommend installing it to your local hard drive (assuming you are not overwriting data). Linux file systems can differ dramatically from a windows environment, and for the ones I have dealt with, there are many things to be learned aobut the parition setup and allocation. With a LiveCD you can bypass having to deal with that, but it does limit what you can do as far as playing around with the operating system.

linuxbanner

2. Create a file server. Throw some hard drives in the box (it is up to you whether you would like to setup a RAID array for these drives. For this sort of arrangement, you may also need additional hardware (a RAID controller) for this setup.) Keep in mind that almost all properly setup file servers used in the business world are on some sort of RAID configuration. You can configure the box to any setup you would like. I enjoy a VNC only box (no monitor/keyboard/mouse attached) that I can throw in a closet and only run a patch cable and power cable out for. If you are looking at making a file server please keep some form of backup in mind.

3. Setup a local server for WAN use. I set one of these up a few years ago and couldn’t be happier with it. Best use of old hardware I have found so far! On mine I run VNC and just created a DNS2GO account so I wouldn’t have to stay on top of the always-changing IP of a residential line. This sort of configuration allows for a lot of customization. You could create it to run all messaging protocols, a place to save email using thunderbird, outlook, etc. Also can dedicate one place for any file sharing applications (if you desire to use one). It saves a lot of time having these sorts of applications on one machine rather then spreading the tasks around to 2-3 different ones. Customization is endless, and it’s very convenient to log into a familiar work environment when you are in need of your word processing, graphic design, or other applications at a workstation with only internet access and the minimum Windows XP of Vista system applications.

4. Create a Home Theater PC (HTPC). Now, depending on what you want to do with the machine really depends on the hardware you are using for it, or how much $ you are willing to dump into it. If you would like merely a TV tuner, DVD player, or to play similar video files which don’t demand much from graphics or processor you may be fine with something as minimal as a p3 with 512 MB or RAM. Of course, check the minimum requirements for the TV Tuner you purchase or any of the file formats you play. However, even if you don’t want to spend a fortune re-building an old box, you can do great things by just installing a TV tuner (around $50 nowadays) and a DVD-ROM drive if it is not included. The only other part needed will be an adapter from DVI to HDMI (depending on the desired resolution). There are a lot of variables with creating a Home Theatre PC that will probably need to be covered in a separate entry. Basically, for TV viewing and DVD play, the demand on CPU and memory isn’t too bad, and an older system with a few newer parts may perform well. Play around with it, definitely a worthy weekend project.

5. Mod that case! An entire community within the computer enthusiast world. Case modding is the art of modifying a computer case (usually tower-cases vs. laptops) to improve looks or performance of the unit, or both! There is anything from computers crammed into Nintendo Entertainment System cases, to computers with UV lighted, water cooled components.

modbanner

These communites are mainly composed of galleries, tutorials, and contests about “case mods”. It is easy to find them all around and find something you like and want to imitate or that inspires you. Case mods can range from $1 to thousands of dollars, it all just depends on what you would like to create with the ordinary p3 sitting in the closet and how much time you want to dedicate to making it happen.

Links:
Ubuntu LiveCD Download

Knoppix LiveCD Download

UltraVNC

Bit-Tech – good read for some high budget case mods

I do plan on creating a more in-depth article about HTPC creation, so check back soon. I also may start up with a few photoshop tutorials now that things are a bit more up and running. Thanks for reading!

-MadHatter