# [SOLVED] Changing MTU using iwconfig or wpa_supplicant?

## Devcon

I will begin by explaing my setup as best I can.

Distribution: Gentoo kernel 2.6.27

Wireless Management: wireless-tools & wpa_supplicant (just trying it out) and ndiswrapper 1.53

Hardware:

Target Machine: Inspiron 8200 with a Marvell 8335 Wireless PCMCIA adapter

Network: Netgear MRV814 Router, Speedtouch 330 ADSL modem

ICS Host Machine: Running XP SP3 with Internet Connection Sharing enabled. Obviously, the modem is connected directly to the host computer and the router is just acting as bridge to the ICS gateway.

As a preface, ICS works perfectly fine. I can connect to the internet through my wireless router with no problems. The problem, is that I can not access any MSN services or websites I believe as a result of the MTU setting. So now we continue with some terminal output...

#lspci

```

03:00.0 Ethernet controller: Marvell Technology Group Ltd. 88w8335 [Libertas] 802.11b/g Wireless (rev 03)

```

#ndiswrapper -l

```

mrv8335 : driver installed

   device (11AB:1FAA) present

```

#ifconfig

```

wlan0     Link encap:Ethernet  HWaddr 08:10:17:02:0d:39  

          inet addr:192.168.0.194  Bcast:192.168.0.255 Mask:255.255.255.0

          inet6 addr: fe80::a10:17ff:fe02:d39/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:264 errors:0 dropped:0 overruns:0 frame:0

          TX packets:267 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:252933 (247.0 KiB)  TX bytes:19569 (19.1 KiB)

          Interrupt:11 Memory:f4010000-f4020000

```

#iwconfig

```

lo        no wireless extensions.

sit0      no wireless extensions.

wlan0     IEEE 802.11b  ESSID:"NDAWHOUSE"  

          Mode:Managed  Frequency:2.462 GHz  Access Point: 00:09:5B:52:89:42   

          Bit Rate=11 Mb/s   Sensitivity=-200 dBm  

          RTS thr=2346 B   Fragment thr=2346 B   

          Encryption key:off

          Power Management:off

          Link Quality:50/100  Signal level:-64 dBm  Noise level:-96 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

```

As you can see, the MTU is currently set to 1500. The optimal MTU for PPOE ADSL connections is 1492. I believe that the host ICS computer is set to 1492; however, I will need to get back to you guys on that one. The current symptoms on the target I8200 machine are as stated, no access to msn services, and a seemingly slower connection over time. I have been googling for some time on changing the MTU with little success.

My current config files that are applicable:

/etc/conf.d/net

-I know this is not set up right at the moment. I'm learning.

```

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

##################

#Ethernet Config

##################

config_eth0=( "null" )

##################

#Wireless Config

##################

config_wlan0=( "192.168.0.2/24" )

routes_wlan0=( "default via 192.168.0.1" )

essid_wlan0="NDAWHOUSE"

config_NDAWHOUSE=( "192.168.0.1/24 brd 192.168.0.255" )

routes_NDAWHOUSE=( "default via 192.168.0.1" )

dns_servers_NDAWHOUSE=( "192.168.0.1" )

##################

#WPA Supplicant

##################

modules=( "wpa_supplicant" )

wpa_supplicant_wlan0="-Dndiswrapper"

# It's important that we tell wpa_supplicant which driver we should

# be using as it's not very good at guessing yet

```

/etc/wpa_supplicant/wpa_supplicant.conf

```

# This is a network block that connects to any unsecured access point.

# We give it a low priority so any defined blocks are preferred.

# The below line not be changed otherwise we refuse to work

ctrl_interface=/var/run/wpa_supplicant

# Ensure that only root can read the WPA configuration

ctrl_interface_group=0

# Let wpa_supplicant take care of scanning and AP selection

ap_scan=1

# Simple case: WPA-PSK, PSK as an ASCII passphrase, allow all valid ciphers

network={

  ssid="NDAWHOUSE"

  scan_ssid=1

  #proto=WPA

  #pairwise=TKIP

  #key_mgmt=WPA-PSK

  #psk="pw"

  # The higher the priority the sooner we are matched

  priority=5

}

```

These are the only applicable config files I know of for a wireless connection. I orginally thought it may be my Marvell driver as the chipset has a bad reputation, but I have installed Ubuntu on this machine with the same exact ICS setup without problems. All msn websites and messenger worked fine. I cannot verify the MTU setting on my Ubuntu install, as Gentoo has since replaced it. Thus, I am convinced the problem lies in this configuration, as the rest of the network has not changed. 

I have probably forgotten something, so let me know and I'll post more information. I wrote this in a hurry. Anyway, does anyone know how to change the MTU setting on a Gentoo install as outlined above?

Thanks in advanceLast edited by Devcon on Sun Nov 16, 2008 8:13 pm; edited 1 time in total

----------

## BradN

ifconfig wlan0 mtu 1492

I believe this is what you want - look for how to specify ifconfig parameters in conf.d/net  :Smile: 

----------

## Devcon

I have been down that road.  

```

#ifconfig wlan0 mtu 1492

SIOCSIFMTU: Invalid argument

```

I wish it were that easy.  I can't seem to find the proper syntax anywhere to input this setting into conf.d/net.  Does anybody have a specific example of a complete wireless adaptor entry in conf.d/net with a static IP and some more detailed settings such as MTU?

Thanks guys

----------

## Devcon

I'm a bit closer, but I still cannot find where to change the mtu setting.  Is it even possible from within /conf.d/net?  An update...

```

  GNU nano 2.1.5            File: /etc/conf.d/net                               

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

##################

#Ethernet Config

##################

config_eth0=( "null" )

##################

#Wireless Config

##################

modules=( "iwconfig" )

essid_wlan0="NDAWHOUSE"

config_wlan0=( "192.168.0.2/24 mtu 1496" )

routes_wlan0=( "default gw 192.168.0.1" )

dns_servers_wlan0=( "192.168.0.1" )

```

Restarting the interface:

```

/etc/init.d/net.wlan0 restart

 * Caching service dependencies ...                                       [ ok ]

 * Stopping wlan0

 *   Bringing down wlan0

 *     Shutting down wlan0 ...                                            [ ok ]

 * Starting wlan0

 *   Configuring wireless network for wlan0

 *     wlan0 connected to ESSID "NDAWHOUSE" at 00:09:5B:52:89:42

 *     in managed mode on channel 11 (WEP disabled)

 *   Bringing up wlan0

 *     192.168.0.2/24                                                     [ ok ]

 *   Adding routes

 *     default gw 192.168.0.1 ...                                         [ ok ]

SIOCSIFMTU: Invalid argument                                              [ !! ]

```

My ifconfig output:

```

ifconfig (without the attempted "mtu 1496" above...)

lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:8 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:480 (480.0 B)  TX bytes:480 (480.0 B)

wlan0     Link encap:Ethernet  HWaddr 08:10:17:02:0d:39  

          inet addr:192.168.0.2  Bcast:192.168.0.255  Mask:255.255.255.0

          inet6 addr: fe80::a10:17ff:fe02:d39/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:568 errors:0 dropped:0 overruns:0 frame:0

          TX packets:598 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:283618 (276.9 KiB)  TX bytes:114224 (111.5 KiB)

          Interrupt:11 Memory:f4010000-f4020000 

```

It connect to my ICS network fine, but I still cannot connect to certain sites such as microsoft ones.  I know I need to change the MTU.  I thought the /init.d/net.wlan0 script might have an option.  It refers to mtu in one section:

```

# Calculates the best metric for the interface

# We use this when we add routes so we can prefer interfaces over each other

calculate_metric() {

   local iface="$1" metric="$2"

   # Have we already got a metric?

   local m=$(awk '$1=="'${iface}'" && $2=="00000000" { print $7 }' \

      /proc/net/route)

   if [[ -n ${m} ]] ; then

      echo "${m}"

      return 0

   fi

   local i= dest= gw= flags= ref= u= m= mtu= metrics=

   while read i dest gw flags ref u m mtu ; do

      # Ignore lo

      is_loopback "${i}" && continue

      # We work out metrics from default routes only

      [[ ${dest} != "00000000" || ${gw} == "00000000" ]] && continue

      metrics="${metrics}\n${m}"

   done < /proc/net/route

   # Now, sort our metrics

   metrics=$(echo -e "${metrics}" | sort -n)

   # Now, find the lowest we can use

   local gotbase=false

   for m in ${metrics} ; do

      [[ ${m} -lt ${metric} ]] && continue

      [[ ${m} == ${metric} ]] && ((metric++))

      [[ ${m} -gt ${metric} ]] && break

   done

   

   echo "${metric}"

}

```

If changing that script can in fact change the mtu, I am not sure how to edit it.  Any advice?

----------

## Devcon

This appears to be the area where ifconfig is failing.

```

# bool ifconfig_pre_start(char *interface)

#

# Runs any pre_start stuff on our interface - just the MTU atm

# We set MTU twice as it may be needed for DHCP - a dhcp client could

# change it in error, so we set MTU in post start too

ifconfig_pre_start() {

   local iface="$1"

   interface_exists "${iface}" || return 0

   local ifvar=$(bash_variable "$1") mtu=

   # MTU support

   mtu="mtu_${ifvar}"

   [[ -n ${!mtu} ]] && ifconfig "${iface}" mtu "${!mtu}"

   return 0

}

```

Is there a bug in this part of the script?  Or, does this only work with wired  interfaces or ones which do not use ndiswrapper?

----------

## Devcon

For the benefit of any folks that may google it in the future, I'm going to mark this solved, although I wish I had a more detailed evaluation of the specific setting in question.

I was using kernel 2.6.27 vanilla that I had compiled myself. Downloading the new kernel 2.6.27.6 and recompiling has fixed the problem. I did not make any significant changes to the networking config portion of menuconfig.

I'll try to do a more in depth analysis of the difference between my previous kernel config and the present one.

----------

## UberLord

 *Devcon wrote:*   

> I have been down that road.  
> 
> ```
> 
> #ifconfig wlan0 mtu 1492
> ...

 

If that fails then you can't do it and you need to contact the ndiswrapper devs.

BTW, this command does the same thing in conf.d/net

mtu_wlan0="1492"

----------

