Thursday 12 April 2012

Connecting to LAN Internet using Linux OS

internet
If you're reading this, its most likely that you have no clue how to connect to the LAN Internet (also referred as Cable connection) using your brand new Linux operating system. Don't feel bad, you're not alone.

Everybody had to ask few questions on how to get the freakin' internet work, and without the help of some folks on the online, I would have still been using Microsoft's Windows because connecting to the internet with it is so easy.

Internet is an important element when it comes to general computing, so if someone wants to introduce a new computer system such as Linux, at least let it run the most used service.

Now remember, you will not connect directly to the internet. Basically I'm going to teach you how to connect to a network that will enable you to use the internet. I'm not going teach how to use a certain Distro, or a certain GUI. Distro's network settings sometimes differ, so what I'm going to help you with is ignoring all the distro's default settings and write your own internet .sh script that would let you connect to the internet as easy as 1, 2, 3... So lets see what you have: A cable coming down from outside directly plugged to your NIC (Network Card), normally if you have one NIC, it would be named: eth0 (ethX -> X will change if you have more than one NIC). In this example we're gonna use only one NIC to enable Internet on one station only. General internet connection requirements:
  • an IP address + netmask
  • a Gateway address
  • a DNS address
  • and sometimes a Proxy server address.
Know what you need. It's important to know what you need to connect to your ISP's (Internet Service Provider) network. You will definitely not guess those. While having a nice conversation with your ISP, ask them for the following:
  • Your personal external IP address + netmask (will use 192.168.0.55 and netmask: 255.255.255.0 as example)
  • Your network address (If your IP is xxx.xxx.0.xxx then your network address would be xxx.xxx.0.0) - The gateway's (Server) internal IP address (will use 192.168.0.1 as example)
  • Your DNS (usually same as the gateway) internal IP address (will use 192.168.0.1)
  • and finally, ask him if he uses a proxy server, write down it's IP address and port if the ISP uses one. (Will use 10.3.3.1 port 8080 as example; don't get shocked if the proxy's ip address is the same as the gateway and/or DNS).
You also need to know the following:
  • Path for Ifconfig
  • Path for Route
To do that do the following, open a terminal and write down:
haytham@sadusbox:/$ whereis ifconfig && whereis route

You'll get something similar to:
haytham@sadusbox:/$ whereis ifconfig && whereis route
ifconfig: /sbin/ifconfig /lib/ifconfig ...
route: /sbin/route /usr/share/man....

We're just interested in these:
ifconfig: /sbin/ifconfig
route: /sbin/route

Now that you gathered enough information, open your favorite editor,
(will use VIM here, know how to use your editor for the following commands, open,
save as, close)

Write down what is written in the box, and change the variables to your needs
(Variables start from the START EDIT comment to the END EDIT comment)
#!/bin/bash

#-------START EDIT--------
#Setting some variables
echo "Setting Variables..."
NICNAME=eth0
EXTERNALIP=192.168.0.55
SUBEXTERNALIP=255.255.255.0
NETWORKIP=192.168.0.0
GATEWAYIP=192.168.0.1
DNSIP=192.168.0.1
IFCONFIG=/sbin/ifconfig
ROUTE=/sbin/route
#-------END EDIT--------

#Initialize external NIC IP address
echo "Initialize external NIC ($NICNAME) IP address"
$IFCONFIG $NICNAME $EXTERNALIP netmask $SUBEXTERNALIP up

#Setting Network and Gateway Settings
echo "Setting Network and Gateway Settings"
$ROUTE add $EXTERNALIP $NICNAME

$ROUTE add -net $NETWORKIP netmask $SUBEXTERNALIP $NICNAME
$ROUTE add default gw $GATEWAYIP eth0
$ROUTE add -host 127.0.0.1 lo

#Adding a DNS server
echo "Adding a DNS"
echo " " > /etc/resolv.conf
echo nameserver $DNSIP > /etc/resolv.conf

#Detecting default route settings, this may take 5 seconds of wait
echo "Detecting pre-default route settings, this may take 5 seconds for probing"
$ROUTE | grep default

echo "..."
echo "Internet is enabled, happy surfing..."

Save this file as: internet.sh in your /home/user/ directory and then set its 
permissions to 755 by doing the following command:
haytham@sadusbox:/$ chmod 755 /home/user/internet.sh

You can now login as SuperUser and just write:
haytham@sadusbox:/$ su
Password:
root@sadusbox:/$ sh internet.sh
Internet should be smiling at you. If your ISP uses a proxy server address don't
forget to add the proxy server's address (10.3.3.1 and port 8080) inside your
favorite web browser so that you would be able to surf the pages and most importantly
in your .bashrc script so that it would let you connect to the proxy from bash.To do
that open with your favorite editor the file .bashrc and write the following in the
first lines:

export http_proxy=http://10.3.3.1:8080
export ftp_proxy=http://10.3.3.1:8080
Hope you enjoyed reading this comprehensive guide to help you connect to the Internet on Linux using your cable.

Tuesday 3 April 2012

9 best tips recommended exclusively for Debian

best-tips-pic
The Debian operating system comprises software packages which are released as open source and is well known for the abundance of options it offers.

Below is a comprehensive compilation of some of the best tips exclusively recommended for Debian.
  1. Never install new packages with long dependency lists unless you make sure (packages.debian.org) that they do not contain any major bugs or are currently broken, or might break other packages in the tree.
  2. Its advised you run apt-get update weekly. Package lists tend to change very often.
  3. Never EVER run apt-get upgrade OR apt-get dist-upgrade. Doing so, you will have signed a deal with the devil. Those two commands are very dangerous to run as they tend to upgrade a very long list of packages which are considered core system packages. This will result in lots of painful package downgrading which you really don’t want to spend time doing.
  4. Always keep an eye out for security packages and patches which are available via apt. Those things are often life savers.
  5. If you have multiple Debian boxen, you NEED apt-proxy, which serves as a local Debian mirror to all running systems on your network. This will save you endless hours if you have a slow internet connection.
  6. In case you ever feel your hard drive space is mysteriously vanishing, then a quick look with -ch /var will show you that the cache directory is keeping hold of all your downloaded Debian packages. You can choose to keep them somewhere else or simply wipe them out by using apt-get clean.
  7. If you need a new kernel installed then the folks at Debian have compiled one just for you. It’s a modular kernel with security and Debian patches applied. A simple search for "kernel" and "2.4.xx" should suffice. Find the right architecture, and install it. Look out though, you will have to modify Lilo (or grub) to use the provided initrd.img file so you can load the cramfs file system and boot.
  8. If on the other hand you're "I'm a real hacker and I compile my own kernels thank you!" kind of person, then feel free to get your own kernel source and use make-kpkg to compile it and create a Deb file from it. This will make installing and removing kernels easier and more "in sync" with the whole Debian packaging system.
  9. The last and final tip is, um, actually, there's no last tip. I just wrote this cause I like the number nine, and I thought I'd just waste some more of your time.
I hope that you find this helpful as educational and fun as I did.

Saturday 10 March 2012

OS News rated Fedora Core 1 as Mild

Well I read it a while ago and I expected that, but I thought I wouldn't judge until I see myself. Its not like I am going to use fedora or anything. I am happy with my Gentoo settings on my pc and my laptop. I still have Redhat on my gateway. I doubt I will remove it from there. Since I wont update it or anything. Well Redhat lovers can try fedora and tell us their opinion.

In my humble opinion I would say for all users stick to Debian or a Debian based Distro. did you ever look at their software tree?? thousands of apps... I think it reached over 17000 lately.

news-image
For developers I advice Gentoo because of its high customizability that u don't find in any binary Distro. I know... the first install is a b*tch it takes hours. but once its done its done. its not like you have to install it everyday.


There is Mandrake 9.2 out in the market too. as a Desktop machine. Mandrake has always been great specially with their extra support. like Arabic support that I doubt any other Distro has it properly.


Well there is still Slackware. I used slackware for like 8 months. Its not for everyone. its for someone who wants to get his hands dirty. Slackware isn't a "normal" Distro. its directory structure is way different. Libraries location etc.... try to compile an app for Slackware.. oh boy... what a headache... but u know it teaches you everything. its because of Slackware that I can nearly solve any problem on my machine. it taught me how to read. something that not a lot people know how to do.


Maybe u are thinking Gentoo is as dirty because of its source nature. I'll reply no. except for first time its abit annoying since u have to learn a lot specially about cflags and make configuration. But once its up and running, Gentoo is full of Perl and bash scripts to automate a lot of things. like for example to add a SSH at boot:
rc-update add SSH default.

Writing init file is damn easy as well, those little things that make developing and configuring way faster than other Distros. but is it for everyone? NO, and don't think about putting Gentoo as desktop with X on a pc under 800 mhz.. its not because it wont run. it will run perfectly and better than most Distro. but the first install for example on a 233mhz can last 2 days.

There is SUSE as well. frankly the only time I used suse was for 2 days, it was SUSE 7.1 I don't know how it is now but I still remember YAST, was great.

I think I said it all. as its the longest article I have written in ages.