Experiences in the community

Just another WordPress.com weblog

Faster DHCP, network-test and APG.

Hi all,
This would be about few things I have been wanting to document about my debian configuration for sometime now.

Let me start by quoting Enrico Zini’s quote (a free software Developer and a DD) :-

I refuse to be bound by software I cannot trust and negotiate with.

– Enrico Zini

Years before when I started on this journey, it was a simple case of viruses, gaming and installation-re-installation of the OS and my irritation with the same which prompted the move from MS-Windows to GNU/Linux.

Cut to date and the advantages on free software far outweigh whatever fancy graphics and UI MS-Windows provides. This is not to say that we cannot have fancy graphics, anybody who has seen any of the newer GNU/Linux distros like Bodhi Linux (as an e.g.) of excellent use of the GUI in a desktop environment.

However, my issues were never about GUI but about functionality and openness. I would start with a simple example to illustrate my point.

My network is a very simple affair. I have two options, one is getting connected to an ADSL modem directly, the other systems have a router connected to an ADSL modem as well. In both the cases, Ethernet is being used and as people know provided the wiring is done properly, getting connected on Ethernet is loads faster than on Wi-Fi or any other way.Fiber and other exotic interfaces need not apply.

In both the cases, once you are authenticated by your ISP via the modem, getting the link to the user is in mini-seconds.This is where the debian-booting infrastructure failed for me because by default, it takes almost a minute or a bit more for Debian to realize if the system is connected to the network or not. This was too much of a time being spent I felt at least during the booting up process esp. for the networking .

Here is one of the examples of the network connection time taken before the change I did :-

$ time ifup eth0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/xx:xx:xx:xx:xx:xx
Sending on LPF/eth0/xx:xx:xx:xx:xx:xx
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 15
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPOFFER from 192.168.1.1
DHCPACK from 192.168.1.1
bound to 192.168.1.2 -- renewal in 37597 seconds.

real 0m24.107s
user 0m0.040s
sys 0m0.016s

I tried it a few times and few scenarios and it seemed to take between 24 secs. to a minute to get the interface up and connected. Here’s another take.

$time ifup eth0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/eth0/xx:xx:xx:xx:xx:xx
Sending on LPF/eth0/xx:xx:xx:xx:xx:xx
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 9
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 18
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 9
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
No DHCPOFFERS received.
No working leases in persistent database - sleeping.
shirish[15743]: WARNING: Initialising interface eth0 which does not have link
WARNING: Cannot check for duplicate IP address in the network as the script could not find the ip address of eth0. You can disable this test by setting DO_ARPING to 'no' in /etc/default/network-test .


real 1m2.008s
user 0m0.012s
sys 0m0.016s

Note: The xx:xx:xx:xx:xx:xx is nothing but the MAC ID of your network card.

Similarly, it used to take a minute+ if the network was down. While I don’t reboot much, for both ways (when connected or not connected) it was quite irritating to wait for a full minute or more to know the result when in fact I know what the result is or going to be.

The above is the above single machine scenario connected to the ADSL modem.

This is the /etc/network/interfaces file of that same system.


# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp

After looking in the system I came to know that a probable solution was in /etc/dhcp/dhclient.conf . I just added the timeout to 10 seconds, so if there is no network the boot up would complete faster and if the system was already connected to the net, it gets the required credentials within 10 seconds or so. In both the scenarios it has worked beautifully. The line added in /etc/dhcp/dhclient.conf

timeout 10;

and this was enough.

For people thinking why I used ifupdown then network-manager, NM tries to do it all and fails many a times. I wouldn’t go into much detail but the fact (for me) is ifupdown is much lighter and cleaner than network-manager and that’s the reason I use it and endorse it.

Example two :- For a long time, I had been looking for a simple tool to validate network connectivity and also give some details about the connection. Enter network-test via the ifupdown-extra package. See :-


$ network-test
INFO: This system has exactly one default route
INFO: Host localhost answers to ICMP pings
INFO: Loopback interface is working properly
INFO: The eth0 interface is up
INFO: The eth0 interface has IP address 192.168.1.2 assigned
INFO: The eth0 interface has tx and rx packets.
INFO: The router 192.168.1.1 is reachable
INFO: This system is configured to use nameserver 192.168.1.1
INFO: Host 192.168.1.1 answers to ICMP pings
INFO: Dns server 192.168.1.1 resolved correctly http://www.debian.org
INFO: The nameserver configured for this system works properly
INFO: System can reach Internet host http://www.debian.org
INFO: System can access web server at Internet host http://www.debian.org (port 80)
INFO: System can access web service at http://network-test.debian.org/moo
INFO: System can connect to the Internet and received files without changes
INFO: System can access web server at Internet host http://queryip.net/ip/
INFO: System public IP address is 117.195.xx.xx

Now you can’t help but fall in love with the tool.It gives almost all kinds of info. you could ask for. To top it, it also gives the public IP address given for the session. I enjoyed and found the tool thoroughly useful to troubleshoot simple networking issues. I had been searching for such a tool for quite sometime so it was nice to see this in action.

The last tool I would like to share is the tool APG which is short for ‘Automated Password Generator’. I have been using this tool for a while now. With the whole Heartbleed OpenSSL bug/issue it might be necessary to change those passwords so who else than APG to the rescue.

Installing it pretty easy.

$sudo apt-get install apg

running it is also easy in the default mode but I would suggest people to use it in something like this :-

$ apg -n10 -m14 -M SNCL
vi^frakHyThem2
lovDoar0Drycs;
anAryazHun=Oc2
-ernyotNofsUk1
Che7quidchulk~
Forck-WrentOd1
Gihynuf9ofGes@
-glehinWacBid0
(Oruvjac9fleug
4ojhockRaphuk%

What I am doing here is as follows :-

-n10 – number of passwords in a pass. I wanted to generate 10 passwords, the default is 6, you can have as many as needed, just put the numbers therein.

-m14 – number of characters in the password. I wanted 14 characters. This is again up to the user.

-M SNCL – Making sure the base password is strong which all sorts of Cap letters, foreign symbols, number etc. The idea is brute-force attacks would have a hard time.

That’s all for now.

Single Post Navigation

One thought on “Faster DHCP, network-test and APG.

  1. Pingback: The Git way – II | Experiences in the community

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: