Friday, August 28, 2009

Sharing internet using iptables

I am explaining how two share internet from one connection to other, here i am using one connection on my ethernet port to share with the wireless add hoc network.

settings at ethernet port (eth0)
IP : 192.168.1.9
MASK : 255.255.255.0
Gateway : 192.168.1.1

my laptop is configured to get internet from modem connected through LAN port and IP address of Modem is 192.168.1.1

settings for my Wifi Adaptor(wan0)
IP : 192.168.0.1
MASK : 255.255.255.0
Gateway : 192.168.1.1

now after this i have created an add hoc network so the systems connecting to my WiFi add hoc network must have following configuration
IP : 192.168.0.[2-254]
MASK : 255.255.255.0
Gateway : 192.168.0.1
DNS  : 192.168.0.1

Now configuration part is done, next we need to setup sharing, first of all we will enable ip forwarding by issuing following command as root user
sysctl -w net.ipv4.ip_forward=1
To enable it in system startup, edit the file /etc/sysctl.conf and set
net.ipv4.ip_forward = 1
now for sharing do the following commands. this should again be done as root user
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
service iptables save

I use open DNS for better resolution, you can also tryout same
208.67.222.222
208.67.220.220

Sunday, August 23, 2009

Add graphics to fedora 10 boot screen

In order to see the graphical boot, you must enable a mode setting for your video. Most users will find vesafb allows most standard VGA resolutions. Some (older) examples are in Linux Kernel Documentation / fb / vesafb.txt. You must have a proper Kernel mode number. For example I selected: 0x318 for 1024x768x16M resolution on a desktop CRT monitor.

As 'root', edit /boot/grub/grub.conf, and add 'vga=0x318' to the end of the kernel line. For example:

title Fedora (2.6.27.5-117.fc10.i686)
root (hd0,9)
kernel /boot/vmlinuz-2.6.27.5-117.fc10.i686 ro root=UUID=bb061789-157b-4cb2-85c8-633026e8df1e rhgb quiet vga=0x318
initrd /boot/initrd-2.6.27.5-117.fc10.i686.img


The graphic modes are NOT in the list which you get if you boot with vga=ask and hit return. The mode you wish to use is derived from the VESA mode number. Here are those VESA mode numbers:

| 640x480 800x600 1024x768 1280x1024
----+-------------------------------------
256 | 0x101 0x103 0x105 0x107
32k | 0x110 0x113 0x116 0x119
64k | 0x111 0x114 0x117 0x11A
16M | 0x112 0x115 0x118 0x11B

The video mode number of the Linux kernel is the VESA mode number plus 0x200. Linux_kernel_mode_number = VESA_mode_number + 0x200

So the table for the Kernel mode numbers are:

| 640x480 800x600 1024x768 1280x1024
----+-------------------------------------
256 | 0x301 0x303 0x305 0x307
32k | 0x310 0x313 0x316 0x319
64k | 0x311 0x314 0x317 0x31A
16M | 0x312 0x315 0x318 0x31B

installing GRUB

on grub terminal
(in bold are the commands, italics is output to commands)


find /boot/grub/stage1
hd(0,1)
hd(0,3)


to find out which partitions in my computer have GRUB installed in them

root (hd0,1)
Filesystem type is ext3fs, partition type 0x83

telling that this root partition contains grub and is to be installed it will give file system type
f I know I have Ubuntu in partition 2 and Debian in partition 4 and I want Ubuntu's GRUB installed to MBR, I set (hd0,1) as GRUB's root device here. If I chose (hd0,3) that would install Debain's GRUB
here i am installing Ubuntu's grub according to the assumption.

setup (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 d (hd0) (hd0)1+15 p (hd0,1)/boot/grub/stage
2 /boot/grub/menu.lst"... succeeded
Done.


setup (hd0)' is the command to install Grub's stage1 to MBR in the first hard disk.

We have to do some more tricks to install grub to non MBR partition

Various LInux Booting options

Boot time command args:

expert Turns on special features:
- allows partitioning of removable media
- prompts for driver disk

noshell Do not put a shell on tty2 during install.

lowres Force GUI installer to run at 640x480.

resolution= Run installer in mode specified, '1024x768' for example.

nousb Do not load USB support (helps if install hangs early sometimes).

nofb Do not load the VGA16 framebuffer required for doing text-mode installation in some languages.

nofirewire Do not load support for firewire devices

askmethod Do not automatically use the CD-ROM as the install source if we detect a Red Hat Linux CD in your CD-ROM drive.

nousbstorage Do not load usbstorage module in loader. May help with device ordering on SCSI systems.

noparport Do not attempt to load support for parallel ports

noprobe Do not attempt to detect hw, prompts user instead.

nopcmcia Ignore PCMCIA controller in system.

skipddc Skips DDC probe of monitor, may help if its handing system.

graphical Force graphical install. Required to have ftp/http use GUI.

text Force text mode install.

vnc Enable vnc-based installation. You will need to connect to the machine using a vnc client application.

vncpassword= Enable a password for the vnc connection. This will prevent someone from inadvertantly connecting to the vnc-based installation. Requires 'vnc' option to be specified as well.

vncconnect=[:] Once installation is up and running, connect to the vnc client named , and optionally use port . Requires 'vnc' option to be specified as well.

updates Prompt for floppy containing updates (bug fixes).

isa Prompt user

enable root login

Login with default user and type
>>>>>$ sudo su
It will ask for password give password and you are now root user check the shell prompt(#)
Now type
>>>>># passwd
And enter new password for root , confirm it by typing once again
Now your password for root is set
Now open
System > Administration > Login Window
Go for Security tab
Check the box with option Allow system Administrator login
Done
you can do root login

You can play with some more options there like automatic login and Timed login
Enjoy !

Add fonts to linux

one way is to add the fonts to the linux fonts.its a simple procedure.
create a directory for the fonts in /usr/share/fonts/trutype
# cd /usr/share/fonts/truetype
# mkdir newfonts

copy the fonts you want to add to that directory.
Now change the ownership of the fonts as well as make sure they have a right of 644 .
# chown root.root *.ttf
# chmod 644 *.ttf

Now run the command mkfontdir while in the newfonts directory.
# mkfontdir

This will create an index of the fonts in the directory. It will also create two files fonts.dir and fonts.cache-1 .
Now moving to the parent directory, edit the file fonts.cache-1 using your favourate editor and append the following line to it.
#File: /usr/share/fonts/truetype/fonts.cache-1
...
"newfonts" 0 ".dir"

Lastly run the command fc-cache.
# fc-cache

This command will scan the font directories on the system and build font information cache files for applications using fontconfig for their font handling.
That's it. Now you can have access to the new fonts in all your X applications including firefox and OpenOffice.org.

GRUB

So many times i thought to post about GRUB here are COMMANDS TO REINSTALL GRUB:

All you need to do is access the terminal using the installation CD/DVD of your GNU/Linux operating system. Ubuntu installation CD is a live CD and so, when it loads, you can run the terminal from there. Fedora installation CD/DVD offers options through which you will have to choose to upgrade the system using commands(rescue mode). Some other like Knopics LIVE etc also have similar options

Once you are at the terminal, you will have to access the ‘grub’ shell to change the grub configuration.So, give this command at the terminal:
$ grub

If it says that you don’t have the permission, in which case you will not have logged in as root(as in Ubuntu), give this command at the terminal:
$ sudo grub

You will get the grub-shell prompt:
grub>

Now, you will have to find out in which partition Grub had been installed before, so that you reinstall in that partition only. Give this command at the terminal:
grub> find /boot/grub/stage1

(returns value)
It returns the number of the partition in which Grub i.e your GNU/Linux had been installed.

e.g.,
grub> find /boot/grub/stage1
(hd0,2)


You can also reinstall Grub in your GNU/Linux partition, only if this GNU/Linux partition is “primary” and you have another boot loader installed at the MBR (in case of more than one GNU/Linux operating systems) through which you can boot this primary partition. To do that, give this command at the terminal:
grub> setup (returned value)

e.g.,
grub> setup (hd0,2)

Recover from kdeinit CRASH

Although there is excellent power backup in lab, what to do if someone switch off the main input to room when he was trying to switch off lab air conditioners ...

Busy Salam was doing some experiment and was installing some rpm in his linux box.. power failure resulted his kde in poor situation. kdeinit was not starting at all. He used gnome to login to box but whole experiment was going on in KDE desktop environment. Here are the steps used to recover KDE environment back.

STEPS:: (login to root through gnome)
  1. cd /var/lib/rpm
  2. rm __db* ( here two _ underscore)
  3. rpm --rebuildbd
  4. reboot (mandatory)
  5. yum -y update
After yum update completed he did a restart and was able to login to kde (voila).what a relief.