Sharing an Internet Connection between two Ubuntu Computers

, , , May 19th, 2008

If you follow my blog regularly, you would have known that my father has brought a new computer running Ubuntu, and that I have completed my BE degree course and have brought my computer home from college.

At home, we have a broadband Internet connection that we share between the two computers. Here’s how I setup my father’s computer as a gateway for my computer.

Both computers had an inbuilt ethernet port and we bought an extra ethernet card for my father’s computer and use it as an internet gateway. Sharing internet on two windows computers is a very straight forward procedure. You just have to connect the broadband modem to one of the ethernet ports and use additional ethernet ports to connect other computers to the gateway.

In Linux however, this doesn’t work automatically. Port forwarding is disabled by default in Ubuntu. This has to be enabled if the computer should forward packets it recieves to other computers. Here’s how this is done.

On the computer you want to use a gateway

  1. You need to connect the internet cable to eth1 and the client computer to eth0. Since the computer has two network cards, you have to figure out which one is connected to the internet and which one to the other computer. Here’s an easy way to do this
    1. Pull out the cable connecting the two computers
    2. Goto Applications -> Accessories -> Terminal and enter the following command
    3. $ sudo ifconfig

    4. You will be shown 2 or more sections with eth0 and eth1 being the first two. In the two sections, one of them will have a line similar to this:
    5. inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0

    6. The section that has this line is the one connected to the internet. If this is in eth0, remove the internet cable and plug it in the other ethernet port and the cable from the client to eth0. If it is in eth1, you can connect the client cable back to its original port
  2. Next you have to give a static ip address to eth0. In terminal, type
  3. $ sudo gedit /etc/network/interfaces

  4. And add the following lines to the file and save it
  5. auto eth0
    iface eth0 inet static
    address 10.8.16.1
    netmask 255.255.255.0
    broadcast 10.8.16.0
    network 10.8.16.0

  6. This will assign the static ip address 10.8.16.1 to eth0, but these changes take effect only after a reboot. To use these settings temporarily for the current session, use the command
  7. $ sudo ifconfig eth0 10.8.16.1

  8. Once your network card serving the client has a static ip address, the next thing to do would be to enable port forwarding:
    1. Goto terminal and open the local startup script as root. To do this, type
    2. $ sudo gedit /etc/rc.local

    3. Add the following lines before the exit 0 line in the file.
    4. sysctl -w net.ipv4.ip_forward=1
      /sbin/iptables -P FORWARD ACCEPT
      /sbin/iptables --table nat -A POSTROUTING -o eth1 -j MASQUERADE

    5. Before closing the script, make sure it is enabled. See the first line of the script. If it isn’t present already, just add a '-e' to the first line so that it would look like '#!/bin/sh -e'
  9. That’s all you have to do on the server. Just do a restart for the settings to take effect. If that’s not possible, you have to execute all the commands you have added to the rc.local script one by one for all of them to take effect

On the client

  1. Go to System -> Administration -> Network There should be a wired connection. Select it and click ‘properties’. Choose ‘Static IP Address’ in the Configuration list box.
  2. Use 10.8.16.2 as the ip address and set the gateway address to 10.8.16.1
  3. Network manager should give you a subnet mask automatically. You won’t have to change that.

This should be enough. This is what I did. If this doesn’t seem to work, just let me know and I’ll help you out.

P.S. You can use a Windows computer to connect to Internet through the linux gateway too. Nothing needs to be changed on the server. Just make 10.8.16.2 the IP address of the client in LAN Settings which can be found in Network Connections. Also, set 10.8.16.1 as the default network gateway address.

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

Correcting Errors in Synaptic Package Manager

, May 12th, 2008

I don’t know if this happens to everyone often, but I usually screw up the Synaptic Package Manager in my computer very often. Most often, there errors are due to some stupid packages that don’t get installed properly or have some compatibility issues with other installed packages.

The most grave error is this:

sahasranaman@sahasranaman-desktop:~$ sudo apt-get install flock
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: The package awcommon needs to be reinstalled, but I can’t find an archive for it.

When apt-get or Synaptic Package Manager gives this error, I would always have to reinstall Ubuntu because there is no direct way to correct this. A few days ago, I came across this hack to correct all package related errors in Synaptic Package Manager.

There is a file in Debian based Operating Systems called /var/lib/dpkg/status that stores a list of all installed packages. It is a text file in Human-Readable format. All you have to do is to remove the entry of the software package that is causing trouble from the list. Here’s a step by step procedure that can help you solve the problem:

  • Press Alt + F2 to open the “Run Command” dialog box.
  • In the Run Command dialog box, type gksu gedit /var/lib/dpkg/status and hit Enter.
  • Type your password when asked. This step opens the package list in a text editor.
  • In the text editor, look for the package that is causing the trouble. Press Ctrl + F to find the package that you want to remove
  • Once you find the entry of that particular package, remove it completely.

For example, if I want to remove a package called finger, I start removing from the line

Package: finger

and remove all lines upto the start of the next Package entry.

I’m not sure if this is the best way to solve such problems, because what we actually do here is remove the entry from the list of packages installed without actually uninstalling it, but it does the trick anyway.

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

Ubuntu - The OS for all Parents

, May 12th, 2008

My father bought his first computer a few weeks back. They had given a free Ubuntu 7.10 CD, but had not installed any operating system. My guess is that they hadn’t installed Linux on the computers is that they expected the users to install pirated Windows on purchase. When companies give computers with Windows preinstalled, why can’t they install Ubuntu, which is faster and easier to install?

Anyways, upon my recommendation, my father decided to install Linux. And right now, he’s browsing and listen to Carnatic music on Rhythmbox. And he’s safe online. Nothing can really hurt his computer, he won’t have crashes and so, won’t have to wait for the engineer to come and fix his computer. He thinks Firefox, OpenOffice.org, spell check and stuff are really easy to use, but needs to get used to the cut-copy-paste thingy.

So if your parents are buying a new computer or are having trouble with their Windows installation, I’d suggest that you install an easy to use Linux distro like Ubuntu on their computer. Please don’t try to teach them all things you do to keep viruses away from your windows computer, they’d find learning a new operating system much easier.

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

Path Variable in Ubuntu

, , , February 5th, 2008

Unlike most other linux distros, the PATH environment variable cannot be set in Ubuntu by adding an assignment statement in the ~/.bash_profile script. This has been annoying me for some time and I was trying different things until I eventually thought of googling for it. Here’s how it is done.
There is a file called /etc/environment. This is where you set the path variable. Goto terminal, type

$ sudo vim /etc/environment

to edit it.

Ubuntu is known for wandering away from conventions, but why did they have to change this? The /etc/environment file is ok, the ~/.bash_profile method doesn’t work anymore. That means, there is no standard startup script in Ubuntu except the System -> Preferences -> Sessions dialog. Nobody would want the terminal to lose its power. I hope the Ubuntu developers know what they’re doing.

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

Ext3 Sucks!!! ReiserFS Rocks!!!

, , December 3rd, 2007

I’ve been using Windows XP on my computer for some time before switching to Ubuntu. Ubuntu was really great. Really fast to start up, load apps, everything was cool. But there was one really big problem.

The computer would slow down drastically while copying huge files, and I even lost a few DVDs by trying to start a music player while burning! I thought it was some hardware compatibility issue. “Of course, Ext3 is a great filesystem. Everything that is FOSS is great!”, was what I was thinking. How very wrong I was!

It was because of the really bad design of the Ext3 filesystem! Its not only slow, it also wastes much more space than any other filesystem. On a 160GB partition, around 15GB would be reserved by the file system for its own use! Thats almost 10% of the entire space! What the fuck were the designers thinking?

Anyways, it took me a while to figure out the alternative. ReiserFS!! And when I tried it, it was loads better than Ext3 or NTFS. Actually, I’ve never given much attention to the filesystem, but after Ext3, ReiserFS is like heaven! 8-)

Just to do a benchmark, I used a simple script to create 10,000 files on an empty folder. The script took around 8 hours in an Ext3 partition, where as, on an Reiser drive, it took 20 minutes to complete. And from what I read on the internet, Reiser is as stable as Ext3, and is even more fault tolerant!

I just dont know if its possible to convert a partition from Ext3 to ReiserFS without losing data. If it is possible, I’d be really happy to find out how.

Lets hope Ext4 does better than this. Wiki says Ext4 can support volumes that are as big as 1 ExaByte (EB), which is more than a billion GigaBytes (GB). I wonder if there will ever be single volumes that big.

Well, somebody please tell me that its not some patent infringement issue thats preventing Ext3 from performing. :-|

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

Running Winamp in Ubuntu

, , , , September 16th, 2007

Wine Finally supports Winamp with Enhancer. The latest version of Wine, the Windows Emulator was launched a couple of days back and now u can run Winamp with Enhancer without any problems with installation or configuring. Ofcourse there are a few problems. The Media Library doesnt work, Modern skins dont work and a few other minor problems as can be seen from the screenshot below.

If you’re running Ubuntu or any other Debian based OS like Debian itself, here’s how you can install Wine 0.9.45:

  • Goto System -> Administration -> Software Sources and choose the Third-Party Software tab.
  • Now click the Add… button near the bottom left corner.
  • Enter the following in the Apt-Line text box and click Add Source

deb http://wine.budgetdedicated.com/apt feisty main

  • Click Add… once again, type the following and click Add Source

deb-src http://wine.budgetdedicated.com/apt feisty main

  • Click Close to close the Software Sources dialog box and a dialog asking you to reload the software list appears. Click Reload.
  • Goto System -> Administration -> Synaptic Package Manager, search for Wine from the software list, and Mark it for installation by right-clicking the item. This installation will remove any previous versions of Wine that you might have.
  • Now click Apply at the top of the SPM window to complete the installation.
  • Once Wine is installed, you can install Winamp by double clicking on the Winamp installer .exe file.
  • Make sure you deselect Modern skin support and Winamp Agent before starting the installation.
  • When done, you can start winamp with the launcher on the desktop or by choosing Applications -> Wine -> Programs -> Winamp -> Winamp
  • If, for some reason the launchers dont appear, you can create a launcher from the installed executable.
    • Goto your Home folder and press Ctrl+H to display hidden folders.
    • Open the .wine directory and follow this path: ~/.wine/drive_c/Program Files/Winamp
    • In here, open winamp.exe to start. You can create a shortcut by right-clicking winamp.exe and choosing Make Link. You can copy the link to the desktop or to a panel.

Phew. That’s a long procedure. If only XMMS, Audacious, Beep or any of the Linux music players have a DSP plugin as good as Enhancer0.17, life would have been much easier!

Blogged with Flock

Tags: , , , ,

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

gDesklets - yummy eye candy for the Linux desktop

, , , September 6th, 2007

I don’t know why, but I’ve been concentrating a lot on eye-candy stuff these days. I was getting extremely annoyed when I found that my nVidia display card won’t support compiz(the desktop effects thing on System -> Preferences in feisty), which is the ultimate eye candy for any Linux computer. I was googling for more eye candy and I found gDesklets to be interesting.

And here it is! My desktop with a cool looking analog clock, an analog calender, and analog sticky note, a countdown and ofcourse, Chad Smith’s picture.

It was available on the Debian repository, so installing it was extremely easy. Alright. Now I gotta go and download more desklets!

Blogged with Flock

Tags:

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

The easiest way to install software in Ubuntu

, September 3rd, 2007

Downloading applications from the internet and installing them every time can be a tedious job. This article, for Ubuntu newbies, contains a small introduction to the Debian package manager and using the Debian DVDs as software sources and installing applications in Ubuntu. You’ll have to download the three Debian DVD images, and burn them on DVDs. Downloading with BitTorrent is the easiest way to get Debian.
Read the rest of this entry »

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

The funniest thing in the web :))

, , , August 28th, 2007

How is something with three the same vowels to compete with Vista? That name almost is as stupid as Google! Those hackers really can’t think of names, they sound as if it were the first and last sound a newly born baby made when he choked on an apple his evil babysitter gave him.

~ Bill Gates on Ubuntu forks
del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati

Age of Empires II on Linux!!!

, , August 4th, 2007

screenshot-2.png

This is a screenshot of me playing Age of Empires II using VirtualBox on my computer running Linux.

del.icio.us Digg DZone IndianPad Newsgator reddit Simpy SlashDot StumbleUpon Technorati