How to set mtu automatically at startup?

3mors

HampCake Studios
I've to set my network card mtu to 1454 in order to navigate on my PowerBook G4, as it's plugged to a LAN with internet in sharing.

Where do I have to put ifconfig en0 mtu 1454 in order to be setted automatically at startup without having to type it on terminal every time?

Thank you.
 
Sure, thanks.
But this apps doesn't change mtu value, so I can't navigate and check for software updates in prefpane.

I read that I can modify BroadbandOptimizer config, but I don't know where and how to put ifconfig en0 mtu 1454.

Could u help me?
 
I've also tried to add this line to /etc/iftab file:

en0 mtu 1454

but it doesn't work after reboot.
 
Try adding this line to "/Library/StartupItems/BroadbandOptimizer/BroadbandOptimizer"
(using pico or BBEdit Lite so as to preserve the plain text file format and UNIX line endings):
/sbin/ifconfig alias 'en0 mtu 1454'

If that doesn't work, add this line instead:
echo 'en0 mtu 1454' >> /etc/iftab

Sorry I can't test it more thoroughly for you (since my configuration is different than yours). This should give you a good lead on how to implement it, however.
 
To run the command manually in the Terminal, you have to do so as root:
sudo ifconfig en0 mtu 1454
If this works, you know that you can add it to the StartupItem to have it run at every boot.

Did you try to edit /etc/iftab manually with pico?
sudo pico /etc/iftab?
If that doesn't stick after a reboot, then move on to the StartupItem method.

The StartupItem should run as an administrative user (and therefore automatically be ran with sudo) so to add it to the file, you just add this line:
ifconfig en0 mtu 1454
to
"/Library/StartupItems/BroadbandOptimizer/BroadbandOptimizer"

Sorry if my previous post was confusing.
 
Originally posted by gatorparrots
To run the command manually in the Terminal, you have to do so as root:
sudo ifconfig en0 mtu 1454

The terminal "SUDO" way works perfectly, in fact I do in this way to set mtu value.

Did you try to edit /etc/iftab manually with pico?
sudo pico /etc/iftab?

I used BBEDIT to edit the file and I'm sure it's not a problem, as I use this app to edit all the other config files.

The StartupItem should run as an administrative user (and therefore automatically be ran with sudo) so to add it to the file, you just add this line:
ifconfig en0 mtu 1454
to
"/Library/StartupItems/BroadbandOptimizer/BroadbandOptimizer"

Already done. Doesn't work. :( :( :(
 
To edit a root-owned file such as /etc/iftab, you have to open BBEdit as root, otherwise you cannot save the file (it will open as read-only).

sudo -b /System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/Applications/BBEdit Lite 6.1/BBEdit Lite 6.1 for OS X'
 
No.
U can open the file directly on BBedit and when u edit the file, the app asks if u want to do it.
When u save, it asks for root password.

I use it everytime, especially for long config file such as httpd.conf.
 
You must have a special configuration, because my root-owned files open as read-only (the little pencil icon in the upper left corner has a slash through it). If you try to edit the file, BBEdit gives a warning dialog box: The document "httpd.conf" couldn't be unlocked because it is owned by "root".

Are you using BBEdit 6 or 7 (the full version)? I am using the Lite version of 6.1 (as you may have guessed by my previous post) and cannot edit root-owned files without the previous command to open BBEdit Lite with root privileges.
 
Okay, here is the definitive answer:
Manually add the setting now:
sudo ifconfig en0 mtu 1454 up

To get it to stick after rebooting, add these two lines to the /Library/StartupItems/BroadbandOptimize/BroadbandOptimizer startup script:
#change from default 1500
/sbin/ifconfig en0 mtu 1454 up > /dev/null


The finished script should looks like this:
Code:
#!/bin/sh

##
# Broadband Optimizer
# optimize networking for broadband connection
##

. /etc/rc.common

CheckForNetwork

#if [ "${NETWORKUP:=-NO-}" = "-YES-" ]; then

/usr/sbin/sysctl -w net.inet.tcp.sendspace=65536 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.recvspace=65536 > /dev/null
/usr/sbin/sysctl -w kern.ipc.maxsockbuf=524288 > /dev/null
/usr/sbin/sysctl -w net.inet.tcp.delayed_ack=0 > /dev/null
/usr/sbin/sysctl -w net.inet.udp.recvspace=73728 > /dev/null
#change from default 1500
/sbin/ifconfig en0 mtu 1454 up > /dev/null
echo "Network settings optimized for Broadband Connection"

#fi

Note: you could also accomplish the same task by adding your setting to /System/Library/StartupItems/Network/Network, but I wouldn't recommend editing a system file like that, especially since it may be blown away by a future system update from Apple. Editing the third-party startup item would be the preferred method, as it should survive system updates.

Also, it appears that /etc/iftab is not the place for such configurations.This article should shed some light on the subject:
http://www.opensource.apple.com/projects/documentation/howto/html/network_config.html#N2732
It seems like the Network startup script provides this type of ifconfig information.


Thanks for sticking it out with me!
 
Back
Top