[udhcpc] Compatibility problem in default.script when the requested netmask is ""

馬克泡 macpaul at gmail.com
Sun Nov 6 03:03:41 UTC 2011

Hi all,

I'm trying to using a 4G (WiMAX) dongle (project: gctwimax) on x86 ubuntu.
However, I've found a problem when I'm doing connection with base
station and dhcp server.

The problem is that, when I used udhcpc to request the IP for wimax
interface (wimax0).
The dhcp server will assign the client IP with netmask
The default script will set the IP and the netmask to this interface "wimax0".
However, the kernel won't create a routing entry related to this
interface when we set the netmask as "255.255.255.X" to this
This behavior leads the next operation of adding default gateway to
the routing table will be failed.

After I've printed the routing control command as debug message.
I've found that when using ifconfig to set the netmask of NIC as
won't create an entry in routing table.
That's why configure the default gateway will fail.

I don't remembered set the nemask as to a NIC with ifconfig
won't create an entry in routing table. At least 3G networks works very well.
The dhclient won't have a problem on this situation.
Should we fix the udcpc/default.script to cover this kinde of situation?

The following log is the debug dump of udhcpc/default.script on ubuntu 11.11.

/home/macpaul/vmax# udhcpc -i wimax0 -q
udhcpc (v1.18.4) started
Sending discover...
Sending select for
Lease of obtained, lease time 3600
=== debug: /sbin/ifconfig wimax0  netmask ===
/usr/share/udhcpc/default.script: Resetting default routes
=== debug: while /sbin/route del default gw dev wimax0; do :; done ===
SIOCDELRT: no such process
=== debug: /sbin/route add default gw dev wimax0 metric 0 ===
SIOCADDRT: no such process
/usr/share/udhcpc/default.script: Adding DNS
/usr/share/udhcpc/default.script: Adding DNS

Compared it to dhclient, the dhclient is able to configure the
routeing table correctly.
The routing table after dhcp request by using dhclient will be as follows.

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 wimax0 UH    0      0        0 wimax0   U     0      0        0 br-lan

I have quote some part of the default.script of udhcpc with debug
message I've added as follows.

The default script on ubuntu (11.11)
I've add the debug message before the command introduce problem.

case $1 in
       [ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
       [ -n "$subnet" ] && NETMASK="netmask $subnet"

# print the command as debug message
# where $NETMASK == cannot add routing entry
# related to the interface.
       echo "/sbin/ifconfig $interface $ip $BROADCAST $NETMASK";
       /sbin/ifconfig $interface $ip $BROADCAST $NETMASK

       if [ -n "$router" ]; then
           echo "$0: Resetting default routes"
# print the command as debug message
# Adding default route will fail if the routing entry
# of this interface hasn't been added to kernel
               echo "while /sbin/route del default gw dev
$interface; do :; done"
           while /sbin/route del default gw dev $interface; do :; done

           for i in $router; do
# print the command as debug message
               echo "/sbin/route add default gw $i dev $interface
metric $metric";
               /sbin/route add default gw $i dev $interface metric $metric
               metric=$(($metric + 1))

Would you please help fixing this problem?

Best regards,
Macpaul Lin

More information about the Ubuntu-devel-discuss mailing list