Friday, August 28, 2009

Configuring several networks in a laptop

Nowadays there are several ways to configure network settings for wired and wireless cards. I have proved several applications to do it (mainly Network Manager and ifupdown) but each of them show some problems for my mobility requiriments.

I have to connect my laptop to different wireless and wired networks in my daily work:
  • DHCP wired nework at home.
  • DHCP wireless network at home.
  • Static IP wired usb network at work throw a Conceptronic cable (Prolific PL-2301/PL-2302 device - plusb module).
  • Static IP wired ethernet network at work.
  • Several sporadic wireless networks.
I tried to use Network Manager to solve all these requirements, but I had difficulties:
  1. To store several skills for different networks.
  2. To manage usb network connections.
By other hand, it is difficult for ifupdown to manage several wireless connections and it is not easy to change from one wireless network to another one.

So, I decide to use Network Manager to manage wireless connections while ifupdown take charge of the wired ones (usb and ethernet). Network Manager does not manage devices included into /etc/network/interfaces, so it is easy to use together these two applications.

I combine ifupdown application (ifupdown debian package) with resolvconf one (resolvconf debian pagackage) to allow dns entries inside interfaces file. This is my /etc/network/interfaces:

# Loopback

auto lo
iface lo inet loopback

# Ethernet networks

allow-hotplug eth0


iface eth0-home inet dhcp

iface eth0-work inet static
address w.x.y.z
netmask 255.255.255.0
network w.x.y.0
broadcast w.x.y.255
gateway w.x.y.1
dns-nameserver w.x.y.2

iface eth0-dhcp inet dhcp #default

mapping eth0
script /usr/local/sbin/ping-places.sh
map 192.168.1.254/24 192.168.1.1 eth0-home
map w.x.y.z/24 w.x.y.1 eth0-work

# usb network

allow-hotplug usb0

iface usb0 inet static
address 192.168.5.100
netmask 255.255.255.0
network 192.168.5.0
broadcast 192.168.5.255
gateway 192.168.5.1
dns-nameservers w'.x'.y'.z' w''.x''.y''.z''
dns-search domain.com

# wireless

allow-hotplug wlan0


where mapping stanzas and ping-places.sh script are used. I have copied ping-places.sh from /usr/share/doc/ifupdown/examples (ifupdown package) to /usr/local/sbin.

To configure one network, I have to plug the wire and power on the laptop. It will ping several routers to guess the network where it is wired. If, by error, you power on the laptop before connecting it, you can make:

# ifdown <interface>
# ifup <interface>


as root or sudoer, where <inteface> is eth0 or usb0.

For wireless networks you can work with Network Manager as usual.


Monday, July 6, 2009

Perl script to apply a command to a large number of files

If you need to apply any command or script to a large number of files it is usefull to get a perl script like this one, which applies a command to all files of current directory that verifies a pattern.

The command must obtain its input from stdin and write its result to stdout.

It is very usefull to make massive transformations in text or XML documents. For example, to reformat all xml files of a directory using xmllint command we can do:

$ command.pl "xmllint --format -" xml output

where .xml.output files will include the result of applying xmllint --format to corresponding .xml files.

This script is released under the terms of the GNU General Public License version 3.

Saturday, April 25, 2009

D-Link DI-824VUP+ print server

If you have a D-Link DI-824VUP+ and want to use your USB printer with your Linux computer, you have to do the following:
  1. Create a LPD/LPR printer.
  2. Write the internal IP of your DI-824VUP+ device inside the host field.
  3. Write lpUSB0 inside the queue field.
  4. Select your printer driver (or install it from a ppd file).
  5. Select a name for your printer.
Now you can print into yout printer throw the D-Link device. It means that you can print using a wireless connection. I don't know if it is the same for all printers but, with my Samsung ML-1210, I have to power on the printer before connecting it to the DI-824VUP+ device, otherwise it doesn't work.

D-Link DI-824VUP+ wireless problem

I have a D-Link DI-824VUP+ which causes me more than one headache for several months.

The problem was that sometimes my two Lenovo laptops, with 4965 and 5100 Intel wireless cards respectively, did not connect to the wireless network of my DI-824VUP+ device. I had to reboot the device and try to connect again and, in some cases, I got the connection to work.

I believed the problem was with Linux Intel wireless driver, which logged an "authenticated timout" problem, but after upgrading to different new kernels the problem remained the same.

So, finally I found out a firmware update in australian D-Link page http://www.dlink.com.au (entering in support section and choosing the model name). I have upgraded from 1.5 firmware to 1.6b, and the problem disappeared completely! The wireless connections of my two laptops have success all times, without rebooting DI-824VUP+ device.