Archive for March, 2010
USB modem: Autodialer script for linux
Mar 8th
I am using Tata Indicom’s “Plug to Surf” USB Modem for my laptop. Its handy and gives a better speed so I also suggest this to my friends as well. I have given a Ubuntu Desktop for many of my non-techie friends and dialing using wvdial and keeping the terminal open looks mess to them. I wanted them to enjoy Plug and Play features and hence I worked on this.
Plug your USB Modem to your laptop/PC just wait for a few minutes and your are ready to surf the net. Pretty interesting, huh?
Well the recipe is given below.
Assumptions:
1. I assume you have Tata Indicom’s “Plug to Surf” USB Modem duly configured on your Linux machines.
2. If your are not able to figure out how to do that just read the bundled CD carefully, its pretty well mentioned on it.
So, first things first. What files will you need to touch?
i. /usr/bin/wvdial
ii. a new file may be /etc/udev/rules.d/85-autodial-usb-modem.rules
Change permissions of your wvdial so that any user can run that as root. Sounds security violation but thats okay if you are a single user on laptop or desktop.
ameya@ameya-laptop:~$ sudo chmod a+s /usr/bin/wvdial
ameya@ameya-laptop:~$ ls -l /usr/bin/wvdial
-rwsr-sr-x 1 root 0 76220 2007-03-09 03:23 /usr/bin/wvdial
Now you need to know the USB device ID of your modem.
ameya@ameya-laptop:~$ lsusb
Bus 004 Device 001: ID 0000:0000
Bus 003 Device 001: ID 0000:0000
Bus 002 Device 001: ID 0000:0000
Bus 001 Device 016: ID 1b7d:070a
Bus 001 Device 001: ID 0000:0000
Notice that Bus 001 is shoing ID as 1b7d:070a
Here the first number before a ( : ) is the vendor id and later is the Product id. Now its time to tell your UDEV service about it. Create a new file sumthing like this.
ameya@ameya-laptop:~$ sudo vi /etc/udev/rules.d/85-autodial-usb-modem.rules
Now insert the below line in this rules file and save and close.
ACTION==”add”, SUBSYSTEM==”usb_device”, SYSFS{idVendor}==”1b7d”, SYSFS{idProduct}==”070a”, OWNER=”ameya”,RUN+=”/usr/bin/wvdial”
Make sure to change the idVendor and idProduct values as per your USB Vendor ID.
ameya@ameya-laptop:~$ sudo chmod 644 /etc/udev/rules.d/85-autodial-usb-modem.rules
ameya@ameya-laptop:~$ ls -l /etc/udev/rules.d/85-autodial-usb-modem.rules
-rw-r–r– 1 root 0 128 2008-06-08 18:46 /etc/udev/rules.d/85-autodial-usb-modem.rules
Now restart the UDEV services.
ameya@ameya-laptop:~$ /etc/init.d/udev restart
This is it. Now whenever you connect your USB modem to the port just wait for a minute and it then you are ready to surf the internet. You will not need to dial any services. Now, I have noticed that when you connect the USB Modem it first gives you a red light indication which means that Modem is searching for Network Range. When it turns to green it is actually ready to dial. At this time our script is dialling the modem. Once it is done it will give you blinking green signal which means it is sending/receiving the packets meaning you can now surf the web.
Well, now that its auto-dialling there should be some easy way to terminate the modem. Here it is.
We only need to create 1 file as below.
ameya@ameya-laptop:~$ vi byebye
Insert the below line to it and save and close.
kill -9 `ps aux |grep wvdial |grep -v grep | awk ‘{print $2}’`
Now, make the file executable with,
ameya@ameya-laptop:~$ chmod 755 byebye
ameya@ameya-laptop:~$ ls -l byebye
-rwxr-xr-x 1 root 0 63 2008-06-08 10:25 /home/ameya/byebye
Copy the file to your bin directory.
ameya@ameya-laptop:~$ sudo cp byebye /usr/bin/
How to use this file?
When you are connected to the net and wish to disconnect just go to the terminal and run the below command.
ameya@ameya-laptop:~$ sudo byebye
It will ask the user password to disconnect. Isn’t it easy?
Or you can copy the file on your desktop so that you can double click the executable to disconnect.
ameya@ameya-laptop:~$ sudo cp byebye /home/ameya/Desktop/
Now, double click on the file and open in a terminal.. provide password to disconnect the internet.
Do let me know if it finds useful to you.
BSNL / MTNL / SIFY / PACENET / HATHWAY on Ubuntu
Mar 8th
BSNL Broadband
Prerequisite
BSNL Broadband provides different types of ADSL modem/router:
Huawei ADSL modem/router with ethernet and USB port
DareGlobal ADSL modem/router with ethernet port.
Huawei ADSL modem/router with ethernet port, USB port and built-in wireless access point.
You should have a working ethernet card to connect the modem/router. No information is available about connecting using USB (PPPoA).
Instructions
Note: The router/modem would trigger the connection if configured this way.(Router on -> Connected)
Ethernet Connection
Connect the modem/router to the ethernet card
Assign an IP address for the ethernet card; the router has a fixed interface address of 192.168.1.1, so you can use 192.168.1.2 for your ethernet interface.
$ sudo ifconfig eth0 192.168.1.2
Add 192.168.1.1 as default gateway.
$ sudo route add default gw 192.168.1.1
Enter the address of some DNS servers in /etc/resolv.conf. These DNS adresses are provided on BSNL’s instruction manual.
$ sudo vi /etc/resolv.conf
The entry will be of type nameserver 61.1.96.71, where the IP will be the one provided in your BSNL Broadband instruction manual.
Access the router’s management interface via a browser by typing the address 192.168.1.1. The admin username/password is admin/admin
Set the connection type to `PPPoE’. On my MT882 box, this comes under `WAN Settings’
Enter your user name and password (username is of the form xyz@dataone)
Reset the router. It will take 2-3 minutes for the box to come up again
Steps 2, 3, 4 can also be done from menu System->Administration->Network in GUI
Alternate Method:
Connect your ethernet wire to the port at the back of your computer.
Fire up the terminal and type in sudo pppoeconf
It should detect your modem.
Keep on pressing enter. Fill in your user name and password when indicated.
It should be easy to stick on to defaults.
You should be prompted back to your terminal when it would say pppoe loaded. Simple. That’s the end of terminal.
Now go to System>Administration>Networking. Click on it. You would be asked for your password to carry out the administrative job as root. You should be prompted to enter the following details.
Activate the Wired connection.
Highlight the wired connection and click on properties.
Check the box “enable the connection”
Configuration as Static IP.
IP Address : 192.168.1.2
Subnet mask fills on it’s own as 255.255.255.0
Gateway address :192.168.1.1
Wireless Connection
Assign an IP address for wireless NIC; the router has a fixed interface address of 192.168.1.1, so you can use 192.168.1.2 for your wireless NIC.
$ sudo ifconfig wlan0 192.168.1.2
In some cases you may need to replace wlan0 with with eth0 or eth1.
Add 192.168.1.1 as default gateway.
$ sudo route add default gw 192.168.1.1
Add network ESSID.
$ sudo iwconfig wlan0 essid WA1003A
Default ESSID for the modem/router provided by BSNL are same as model names. You can change it from modem/router’s admin console.
Enter the address of some DNS servers in /etc/resolv.conf. These DNS adresses are provided on BSNL’s instruction manual.
$ sudo vi /etc/resolv.conf
The entry will be of type nameserver 61.1.96.71, where the IP will be the one provided in your BSNL broadband instruction manual.
Access the router’s management interface via a browser by typing the address 192.168.1.1. The admin username/password is admin/admin
Set the connection type to for PVC0 connection as ‘PPPoE’. On WA1003A modem/router, this comes under ‘Setup’
Enter your user name and password (username is of the form xyz@dataone)
Set the modulation to GDMT. On WA1003A modem/router, this comes under ‘Setup->Modem Setup’
Save and restart the modem/router. On WA1003A modem/router, this can be done under ‘Tools->System Commands’ It will take 2-3 minutes for the box to come up again
Wireless security
In admin console, ‘Advanced->Wireless Security’ set security to WEP.
Add a 64 bit authentication key, 10 characters in hex format i.e 0-9 and A-F
Add this key to wireless NIC configuration.
$ sudo iwconfig wlan0 key A1B2C3D4E5
Save settings in router and restart it. Reactivate the card, probably using ifdown and ifup
One stop instruction for wireless NIC:
Add following lines to /etc/network/interfaces
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
wireless-essid WA1003A
wireless-key A1B2C3D4E5
auto eth0
Most of the steps can also be done from menu System->Administration->Network in GUI
(Note: Most of the instructions are based on the document at http://www.calcuttatelephones.com/dataoneinstall/bb008.html)
Alternative
Note: Ubuntu would trigger the connection if configured this way.(Router on -> Ubuntu on -> Connected)
Make sure your Ethernet card is configured
Open a Terminal: Applications->Accessories->Terminal
Enter sudo pppoeconf
Follow instructions on the screen. The defaults are fine for most cases. Make sure you enter your username and password carefully. Beware : The password will be visible on the screen.
Checking Usage
Casanova has made a python script for checking dataone usage.
NOTE: For bug reports, feature requests go to http://code.google.com/p/doufs/
Dataone usage script
MTNL Triband
MTNL Triband offers DSL 502T Dlink Router for ADSL for those who opt not to buy one. However, I would recommend buying the same router, if one chooses not to pay rent to MTNL for this modem. This router has known to work without issues.
Users who try out Ubuntu Live CDs would have to set up DNS as shown below. For Kubuntu Users, Konqueror automatically detects the network (if through ethernet) and one can access without any configuration.
Ethernet
For users, who have connected their router to the Ethernet card, only have to setup the DNS address as provided by MTNL.
Follow the following steps
Go to System->Administration->Network
Move to the DNS Tab
Click on the default entry (which could be 192.168.1.1) and click on “Delete” button
Click on “Add” button and enter the DNS address. You would have to call up on 1504 and get DNS addresses.
USB
Works out of the box for Kubuntu 6.06 (and onwards – need confirmation)
Works for Ubuntu 7.10 (One would have to setup the DNS. Please see the ethernet section above to setup the DNS)
Checking usage
To find out your usage, you can log on to http://register.mtnl.net.in and input your telephone number as “username” and the password as your “CA” number, if you haven’t changed it. Click on Account Summary on the left pane, when you are in.
Sify
Obtaining the sify dialer
Download the client from the same place where you got the windows client. This should ideally be http://202.144.65.70:8090 , and at the time of writing the file is can be found at http://210.18.11.199:81/bbandclient/sifyconnect-1.3-bin.tar.gz. or http://210.210.4.74:81/bbandclient/sifyconnect-1.3-bin.tar.gz
Installing the dialer
Untar the the dialer using your favorite untar program , or do this :
$ tar -xzvf sifyconnect-1.3-bin.tar.gz
Then run the following commands as root :
$ cd sifyconnect-1.3-bin/
$ bash install.sh
Using the dialer
Run the following commands :
$ sifyd
$ sifyconnect -l
This will prompt you for your username & password , give them. Once you do that your as good as logged in , you can now close the terminal and use the internet.
Troubleshooting
Sometimes the client on trying to log in says something like –
“Login failed : Get the latest version of the client”
This is because after upgrading it’s protocol in some places, sify has discontinoued support for the old protocol . It has also stopped development of it’s GNU/linux and Mac clients , so you might have to call sify customer care and tell them your problem. They probably just allow you IP and account to use the old protocol It took them about 8 hours to fix the problem when I had it.
Another problem that might occur would be like –
“-bash: /etc/init.d/sifybb: No such file or directory”
Pacenet
Following is a guide for configuring Pacenet on Fedora. Should be somewhat helpful for Ubuntu users. http://www.fedoraforum.org/forum/archive/index.php/t-82441.html
Airtel Broadband
Adsl Router
PPPoE (non bridged)
In this mode, your router will connect as sson as it is switched on. If you are billed for time connected then you need to use bridged mode
Go to System->Administartion->Networking and make sure you have configured an ip (192.168.1.2, for example) and have set your DNS (supplied by Airtel) and Default gateway (192.168.1.1). If your router is handling DHCP then you needn’t configure an ip.
Navigate to http://192.168.1.1
Enter the username and password (default is admin for both)
Click Run Wizard
Click Next
Select your time zone (+5:30)
Click Next
Select
Click Next
Enter your username and password. VPI = 1, VCI = 32, Connection Type = PPPoE LLC
Click restart
Hathway
Note down the IP address, gateway and DNS server addresses given by Hathway.
Navigate to System => Administration => Network
Enter your password
In Connections tab, select your ethernet card, in my case it’s Wired Connection(eth1)
Click on properties and set the tabs as follows, (replace the details with your own details)
Configuration: Static IP address
IP Address: 202.88.100.15
Subnet Mask: 255.255.255.0
Gateway Address: 202.88.100.5
Go to DNS Tab.
Click on Add next to DNS box and type the address of DNS server.
For adding more DNS servers, repeat the above step.
Click on Close to finish.
Exim Mail Queue
Mar 8th
Like thousands of others Email Server Administrator problem, our Exim mail server was targeted by spammers. I found that there was approximately 10000 emails residing in my mail queue. The exact number of emails in the queue were known by running :
exim -bpc
It was a tough job to clean up the queue. I tried the “exiqgrep” command to clean the emails those were older than 1 day from the queue.
exiqgrep -o 86400 -i | xargs exim -Mrm
Where 86400 are the seconds of 1 day.
However the above command was not of much help instead it keep on giving me errors. I had to think calmly to delete all the spams. I first decided ran the below command to Run additional queues in the background.
exim -qff &
I given this command multiple times. So that many queues were running at the same time. The next step was to clear all the Frozen messages from the mail queue.
exim -bpr | grep frozen | awk {’print $3′} | xargs exim -Mrm
Clearing the Frozen messages was a wise decision as it the mail queue was showing now 4000 messages in it. The other job was to find similar messages. I checked the queue again.
exim -bpr |more
I could guess that most of the emails are 2 or 3 days older. To clear all these spams the next command was helpful, which checked the mail queue then searched “2d” in it and taking the 3 argument which is Message Id… it deleted all those emails.
exim -bpr | grep 2d | awk {’print $3′} | xargs exim -Mrm
The queue was under my control after clearing the email older to two and three days. Still there were couple of hundreds emails in the queue. I noticed that there are many emails without a sender residing in the queue. It was very simple to clean these spams now.
exim -bpr | grep <> | awk {’print $3′} | xargs exim -Mrm
Yippie… I cleared the mail queue.
Some other useful Exim Queue managing commands are below :
exim -Mvh msgid View message header
exim -Mvb msgid View message body
exim -M msgid Force delivery of message
exim -v -M msgid View the transact of message
Force another queue run
exim -qf
Force another queue run and attempt to flush the frozen message
exim -qff
View the log for the message
exim -Mvl msgid
Remove message without sending any error message
exim -Mrm messageID
Giveup and fail message to bounce the message to the Sender
exim -Mg messageID
How much mail in the queue?
exim -bpc
How many Frozen mails in the queue
exim -bpr | grep frozen | wc -l
Deleteing Frozen Messages
exim -bpr | grep frozen | awk {’print $3′} | xargs exim -Mrm
To force exim update:
/scripts/eximup –force
Exim ACL
Mar 8th
We cannot stop spam completely but we definitely can reduce the number of spams and/or the spam attack using some good logical ACLs. The ACL I found very useful are given below. Hope you will also find it useful to protect your EXIM server against spam.
These are very simple ACLs. You need to edit the Exim’s main configuration file: exim4.conf.template
The code should be as below..
################################################## # MAIN CONFIGURATION SETTINGS #
##################################################
Under the main configuration search the ACL Configuration.
##################################################
# ACL CONFIGURATION #
# Specifies access control lists for incoming SMTP mail #
##################################################
Often spammers send for the HELO argument the name or the IP of your host. We can specify our own domain with the ipaddress to reduce the spams. My own domain is “ameyapandit.com” and my own IP is 208.113.170.151.
—————————————————————————————————————————-
acl_check_helo:
accept
hosts = +own_hosts
# If the HELO pretend to be this host
deny condition = ${if or { \
{eq {${lc:$sender_helo_name}}{ameyapandit.com}} \
{eq {${lc:$sender_helo_name}}{208.113.170.151}} \
} {true}{false} }
# by default we accept
accept
—————————————————————————————————————————-
Sender checking
We can refuse some senders, from some marketing companies.
acl_check_sender:
deny senders = /etc/exim4/filters/sender_reject.list
accept
—————————————————————————————————————————-
A Batchelor’s Year (Edited: Sensored)
Mar 8th
Comments:
recent comments