#!/bin/bash function maxmtu () { INT="${1}" MTU="${2}" MAXMTU="${3}" if test -z "${MTU}" then MTU="1500" fi if test -z "${MAXMTU}" then # find out how high we can go… if ifconfig "${INT}" mtu "${MTU}" then maxmtu "${INT}" "$(( 2 * ${MTU} ))" else maxmtu "${INT}" "$(( ${MTU} / 2 ))" "${MTU}" fi else # …then binary search to converge on the maximum ifconfig allows if test "${MAXMTU}" -gt "$(( ${MTU} + 1))" then MIDMTU="$(( ( ${MTU} + ${MAXMTU} ) / 2 ))" if ifconfig "${INT}" mtu "${MIDMTU}" then maxmtu "${INT}" "${MIDMTU}" "${MAXMTU}" else maxmtu "${INT}" "${MTU}" "${MIDMTU}" fi fi fi } >/dev/null 2>&1 maxmtu "${1}"