Sunday, November 8, 2009

Reliance Netconnect on fedoara 11

Reliance Netconnect coming with dual mode modem, and fedora by default detects it as USB Storage device here are the steps to make it work with fedora 11. As soon as you connect your usb modem check for the kernel message

[apundir@localhost ~]$ sudo tail  /var/log/messages

Nov  8 10:58:38 localhost kernel: usb 5-1: new full speed USB device using uhci_hcd and address 2                          
Nov  8 10:58:38 localhost kernel: usb 5-1: New USB device found, idVendor=19d2, idProduct=fff5                             
Nov  8 10:58:38 localhost kernel: usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3                        
Nov  8 10:58:38 localhost kernel: usb 5-1: Product: USB Storage                                                            
Nov  8 10:58:38 localhost kernel: usb 5-1: Manufacturer: ZTE, Incorporated                                                 
Nov  8 10:58:38 localhost kernel: usb 5-1: SerialNumber: 000000000002                                                      
Nov  8 10:58:38 localhost kernel: usb 5-1: configuration #1 chosen from 1 choice                                           
Nov  8 10:58:38 localhost kernel: scsi3 : SCSI emulation for USB Mass Storage devices


notice the idVendor=19d2, idProduct=fff5 in messages now we need to switch device from usb storage to modem based on this ids. now install usb_modeswitch for this

[apundir@localhost ~]$ sudo yum -y install usb_modeswitch

now you need to look for exact match for target product id in /etc/usb_modeswitch.conf


I have ZTE AC2726 modem here is the configuration i added

[apundir@localhost ~]$ tail -15 /etc/usb_modeswitch.conf

# ZTE AC2726 (EVDO) Reliance Netconnect
#
# Comments: amitpundir@ymail.com

DefaultVendor=  0x19d2
DefaultProduct= 0xfff5

TargetVendor=   0x19d2
TargetProduct=  0xfff1

MessageEndpoint=0x0a
MessageContent="5553424312345678c00000008000069f010000000000000000000000000000"



in case you have a different modem make you need to search your configuration and make it enable by commenting the ";" in the usb_modeswitch.conf file. now lets switch the device

[apundir@localhost ~]$sudo usb_modeswitch

here is what i get from my kernel messages

[apundir@localhost ~]$ sudo tail  /var/log/messages

Nov  8 11:00:42 localhost kernel: usb 5-1: usbfs: process 2562 (usb_modeswitch) did not claim interface 0 before use       
Nov  8 11:00:42 localhost kernel: usb 5-1: USB disconnect, address 2                                                       
Nov  8 11:00:43 localhost kernel: usb 5-1: new full speed USB device using uhci_hcd and address 3                          
Nov  8 11:00:44 localhost kernel: usb 5-1: New USB device found, idVendor=19d2, idProduct=fff1                             
Nov  8 11:00:44 localhost kernel: usb 5-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0                        
Nov  8 11:00:44 localhost kernel: usb 5-1: Product: ZTE CDMA Tech                                                          
Nov  8 11:00:44 localhost kernel: usb 5-1: Manufacturer: ZTE, Incorporated                                                 
Nov  8 11:00:44 localhost kernel: usb 5-1: configuration #1 chosen from 1 choice


now i got my modem connected to my laptop you can see it added to the list of usb devices on your machine

[apundir@localhost ~]$ lsusb
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 005: ID 413c:8103 Dell Computer Corp. Wireless 350 Bluetooth
Bus 001 Device 002: ID 413c:a005 Dell Computer Corp. Internal 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 003: ID 19d2:fff1 ONDA Communication S.p.A.
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub



here ONDA is my modem. modeprobe the new device

[apundir@localhost ~]$  sudo modprobe usbserial vendor=0x19d2 product=0xfff1


after this i have used wvdial to connected to network
installing wvdial is simple with YellowdogUpdateManager

[apundir@localhost ~]$ sudo yum -y install wvdial


now we need to generate a wvdial.conf file for connecting to internet, many blogs say it can be done using  wvdialconf  but i was not able to connect with the conf file i got later after some this and that changes, i got my modem connecting to internet here is my final conf file

[apundir@localhost ~]$ cat /etc/wvdial.conf
[Dialer Defaults]
Modem = /dev/ttyUSB0
Init2 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Modem Type = Analog Modem
Phone=#777
Username=9*********
Init1=ATZ
Password=9*********
Baud=4608000
PPPP Path= /usr/sbin/pppd
New PPPD= 1
Stupid Mode = 1
Tonline = 0

(change username and password in this file. and you may need to change the path of modem for me it got connected to /dev/ttyUSB0)

finally for connecting you need

[apundir@localhost ~]$ sudo wvdial


and output of this will be something like

[apundir@localhost ~]$ sudo wvdial
--> WvDial: Internet dialer version 1.60
--> Cannot get information for serial port.
--> Initializing modem.
--> Sending: ATZ
ATZ
OK
--> Sending: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
OK
--> Modem initialized.
--> Sending: ATDT#777
--> Waiting for carrier.
ATDT#777
CONNECT
--> Carrier detected.  Starting PPP immediately.
--> Starting pppd at Sun Nov  8 11:05:07 2009
--> Pid of pppd: 2719
--> pppd: [18]��
--> Using interface ppp0
--> pppd: [18]��
--> pppd: [18]��
--> pppd: [18]��
--> pppd: [18]��
--> local  IP address 115.184.115.103
--> pppd: [18]��
--> remote IP address 220.224.141.145
--> pppd: [18]��
--> primary   DNS address 202.138.103.100
--> pppd: [18]��
--> secondary DNS address 202.138.96.2
--> pppd: [18]��


I am not sure now what are these mojibake character, but surely they are due to my terminal settings ..

So first thing i am doing after connecting to internet is writing this blog. hope to see your comment when you get connected

Cheers !

Wednesday, September 2, 2009

Split Screen on vi terminal

Sometimes we need to open multiple files even though we are aware of diff and many other ways of file comparison . We can open two or more files in split windows for comparison.
we will open two files in same terminal window..
open first file normally as we do 
$ vi first.txt
for opening second file in same vi display type 
$ :new second.txt
to navigate in between the windows use
ctrl + w
j     (move to lower window)
or
ctrl + w
k   (move to upper window)

for expanding a split window to full big screen 
:only
you can also open a new file by just typing 
:new 

if file opened by :new is now named , you wont be able to save it with just 
:wq 
instead u have to give 
:wq nameForNewFile.txt
Keep giving comments .. :)

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

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