My current ISP offers internet connectivity via WiMax, finally delivered
through Ethernet, requiring me to use DHCP.  Something in the path
through my ISP's network has an MTU of 1480.  All IP packets larger than
1480 I send just vanish.  Incoming IP traffic larger than 1480 gets
correctly fragmented or results in an ICMP_FRAG_NEEDED.  Typical
customers won't notice this because my ISP also changes all TCP MSS
options larger than 1400 down to 1400, thus TCP usually uses packets
smaller than 1480.

To get reasonable behavior for large non-TCP traffic I would like the
MTU of my egress interface to be automatically set to 1480.  Because I
have to use dhclient anyway, DHCP option 26 (interface-mtu) seems to be
the logical solution.  Here is a suitable patch for dhclient-script:

--- dhclient-script     3 Jun 2009 05:12:51 -0000       1.15
+++ dhclient-script     6 Jan 2010 23:50:12 -0000
@@ -35,6 +35,12 @@
                broadcast $new_broadcast_address \
                $medium
 
+       # Try setting the MTU if specified, but ignore failures,
+       # as currently not all interfaces support setting the MTU.
+       if [ "$new_interface_mtu" -ge 68 ]; then
+               ifconfig $interface mtu $new_interface_mtu 2>/dev/null
+       fi
+
        # XXX Original TIMEOUT code did not do this unless $new_routers was set?
        route add $new_ip_address 127.0.0.1 >/dev/null 2>&1
 }


I don't like calling ifconfig twice, but the ifconfig(8) man-mage warns:
"Currently, not all devices support setting the MTU."
Granted, dhclient is usually used on devices which support setting the
MTU and the client-mtu option is rarely used, but figuring out what's
wrong if dhclient-script fails to configure the interface because it
can't set the MTU due to a client-mtu option being received for an
interface which does not support setting the MTU is a task which I don't
wish to impose on anybody.  --  If this is too defensive, maybe use:


--- dhclient-script     3 Jun 2009 05:12:51 -0000       1.15
+++ dhclient-script     7 Jan 2010 02:05:01 -0000
@@ -29,11 +29,15 @@
 }
 
 add_new_address() {
+       if [ "$new_interface_mtu" -ge 68 ]; then
+               mtu_arg="mtu $new_interface_mtu"
+       fi
+
        ifconfig $interface \
                inet $new_ip_address \
                netmask $new_subnet_mask \
                broadcast $new_broadcast_address \
-               $medium
+               $mtu_arg $medium
 
        # XXX Original TIMEOUT code did not do this unless $new_routers was set?
        route add $new_ip_address 127.0.0.1 >/dev/null 2>&1



        Christian.

Reply via email to