Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Force Ethernet duplex settings on Startup Network
After much taking, I'm happy to be able to give something to the community! This relates to a previous hint, where some Macintoshes do not auto-negotiate properly with the networking hardware. The current solution is to run a terminal command, sudo ifconfig en0 media 100basetX mediaopt full-duplex, which then correctly sets the media type and speed (in my case, 100basetX and full-duplex). Unfortunately for some of us, these settings don't 'stick' after a restart (the adapter goes back to autoselect), and must be re-set manually each time.

What is needed here is a process that does this type of thing for us on startup, even before reaching the login screen. This is accomplished by creating a StartupItem, and putting it in /Library -> StartupItems. StartupItem is really a folder containing two parts: A shell script of the same name as the folder, and an XML file called StartupParameters.plist.

Create a folder called setDuplex in /Library -> StartupItems, and create a file inside with the same name. The file should contain the following text:
#!/bin/sh
# forces 100baseTX and full-duplex
. /etc/rc.common
ifconfig en0 media 100basetX mediaopt full-duplex
Make it executable by typing chmod a+x setDuplex. Note that you do not need a sudo command in the script, because it is already being run as root.

Next, create another file called StartupParameters.plist, containing the following text:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
  <dict>
    <key>Description</key>
    <string>My Force-Duplex</string>
    <key>Messages</key>
    <dict>
      <key>start</key>
      <string>Forcing Full-Duplex</string>
    </dict>
    <key>OrderPreference</key>
    <string>Early</string>
    <key>Provides</key>
    <array>
      <string>Proper Duplexing</string>
    </array>
  </dict>
</plist>
Restart, then type ifconfig -a in the Terminal, and your en0 interface should no longer say autoselect, and should have the correct settings.

Forgive me if there are any errors, etc - this is my first shell script, and first XML file! I believe everything should be ok, though! It works well on my server.
    •    
  • Currently 3.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (2 votes cast)
 
[16,102 views]  

Force Ethernet duplex settings on Startup | 10 comments | Create New Account
Click here to return to the 'Force Ethernet duplex settings on Startup' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Check out kbase article
Authored by: tetsuotheironman on Mar 28, '03 11:18:00AM
This may also be of some use.. Apple's Solution

[ Reply to This | # ]
Check out kbase article
Authored by: craigsheppard on Mar 28, '03 12:45:34PM

Lol - that would have been a HUGE benefit to me when I was trying to set this up. I even called AppleCare support, and they said they didn't know, but I might want to try a cron job or something!!! Thanks for the info!

Craig



[ Reply to This | # ]
Does not work on beige G3
Authored by: kopf on Mar 28, '03 10:48:01PM

I've tried the command from this article as well as the full Startup Item script from Apple's KB article and it doesn't work on my beige G3 (with the built-in 10BT Ethernet port).

> sudo ifconfig en0 media 10baseT/UTP mediaopt full-duplex

SIOCSIFMEDIA: Operation not supported

Anyone know a solution?

(Mac OS X 10.2.4, G4 upgrade)

Thanks.



[ Reply to This | # ]
Does not work on beige G3
Authored by: Anonymous on Mar 31, '03 04:54:23PM

Seems pretty clear that a Beige G3 must not support full-duplex Ethernet.



[ Reply to This | # ]
Does not work on beige G3
Authored by: max_blaze on Jun 15, '03 12:53:13AM

ummm, actually, it has to do with the autoselect feature... I'm getting the same error :
root# sudo ifconfig en0 media 10baset/UTP mediaopt half-duplex
ifconfig: SIOCSIFMEDIA: Operation not supported

When I connect directly to my dsl modem(10T), my NIC switches to 10baseT/UTP (half-duplex), but when I connect to my netgear router(which is then connected to the dsl modem of course), it switches to 100baseT, this causes an extreme bottleneck (1.2k/s!!) when users try and access my ftp server on port 21.. I'm on a 333b imac... so the nic is capable of both duplex modes, and many more... but the force commands in the terminal will not take, and I get that error.. I tried the apple tech doc way of doing it, but alas it's not working. I'm wondering if I should put a 10T hub between my puter and router to force the 10T connection. Or perhaps a CAT-3 cable to force the issue.??



[ Reply to This | # ]
Take care whether the network is up or not!
Authored by: Thomas Kaiser on Mar 28, '03 11:42:09AM
You should take care whether the network is up or not.
So it might be a better idea to use something like
#!/bin/sh

##
# Configure network interfaces and host name
##

. /etc/rc.common

StartService ()
{
    ConsoleMessage "Setting en0 to 100BaseT"

    # See if the network is up now
    CheckForNetwork

    ##
    # Configure global network settings
    ##

    if [ "${NETWORKUP:=-NO-}" = "-YES-" ]; then
    
        /sbin/ifconfig en0 media 100baseTX mediaopt full-duplex

    fi
}

StopService ()
{
    return 0
}

RestartService ()
{
    return 0
}

RunService "$1"

In addition your StartupParameters.plist can be written much
shorter.
You should also use a "Requires" statement because this has
precedence regarding the start order.
{
  Description     = "sets the interface to 100BaseT full duplex";
  Provides        = ("FullDuplex");
  Requires        = ("Network");
  OrderPreference = "First";
}
Regards,

Thomas

[ Reply to This | # ]
Take care whether the network is up or not!
Authored by: tedkaz on Apr 08, '06 05:03:18AM

Thanks a bunch, this is great help to an OS X newb coming from the Linux world.



[ Reply to This | # ]
Force Ethernet duplex settings on Startup
Authored by: jreasthope on Jun 13, '03 05:37:40PM

If "sudo ifconfig en0 media 100basetX mediaopt full-duplex"
corrupts your ethernet settings, how do you fix this?



[ Reply to This | # ]
Force Ethernet duplex settings on Startup
Authored by: iwiring on Mar 23, '06 03:16:55PM

You shouldn't be using ifconfig to change the NI options as this does not notify the system of the change. This is why it won't persist after a reboot. Additionally any network transition could also reset the NI options to what the system believes them to be.

On OS X NIs are managed by configd.

This is what networksetup, scutil and scselect is for, configuring changes and notifying configd. Use it instead of ifconfig to make NI changes. They will also make the proper changes to files like /System/Library/SystemConfiguration/NetworkInterfaces.plist and notify configd. Changes will persist after a reboot or network transition and eliminates the misguided need for a startup item.

It's one of those "OS X is not Linux" things.

# networksetup -setMedia <hardwareport or device name> <subtype> [option1] [option2] [...]

---
-dhan
---------------------
Dan Shoop
Systems & Networks Architect
iWiring / US Technical Services
shoop@iwiring.net



[ Reply to This | # ]
Force Ethernet duplex settings on Startup
Authored by: iwiring on Mar 23, '06 03:18:59PM

networksetup may be found at

/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Support/networksetup



---
-dhan
---------------------
Dan Shoop
Systems & Networks Architect
iWiring / US Technical Services
shoop@iwiring.net



[ Reply to This | # ]