4 Replies - 1959 Views - Last Post: 18 April 2011 - 07:50 PM

#1 trvr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 09-March 09

Script to change Mac OS X MAC address

Posted 12 April 2011 - 09:02 AM

Ok so at my college my IP address is constantly dropped and I lose internet connection. So far, I have only found three solutions to this problem. Either I just wait it out until the network lets me reconnect, plug into ethernet, or I change my MAC address and sign back into the network. Sometimes this can be rather tedious as I try to finish my work or surf the internet in my free time. So, I know there are ways to program scripts for Mac OS X that could possibly automate the process or at least minimize the tasks. Unfortunately, I am not skilled in bash coding or whatever language you need to write such a script. Can anyone help me with this issue or at least point me in the right direction? Thanks for your time!

Is This A Good Question/Topic? 0
  • +

Replies To: Script to change Mac OS X MAC address

#2 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Script to change Mac OS X MAC address

Posted 12 April 2011 - 10:50 AM

A few things you should know about MAC :

1.) You will need root level permissions to make any changes
2.) The changes only exist after they are made, defaults are loaded at boot time & there is no way to make a permanent change
3.) Since MacOSX is Unix, you should be able to do anything Linux can do, with even much of the same syntax

I would suggest giving this a go, & see where it gets you.
Was This Post Helpful? 0
  • +
  • -

#3 trvr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 09-March 09

Re: Script to change Mac OS X MAC address

Posted 12 April 2011 - 11:05 AM

Thanks for the link, but I already know how to change the MAC address. I am looking for something more along the lines of being able to use a script to change it rather than by hand in the terminal every time.
Was This Post Helpful? 0
  • +
  • -

#4 no2pencil   User is offline

  • Professor Snuggly Pants
  • member icon

Reputation: 6968
  • View blog
  • Posts: 31,958
  • Joined: 10-May 07

Re: Script to change Mac OS X MAC address

Posted 12 April 2011 - 12:42 PM

Take what you do everytime at the command line, put those lines of code into a file, chmod +777 the file, put the file anywhere you like, & call that file from /etc/rc.d/local, as this is the last file that runs with root privileges at startup.

I can't say for 100% if osx uses the rc.d directory structure, but FreeBSD does.
Was This Post Helpful? 0
  • +
  • -

#5 trvr   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 09-March 09

Re: Script to change Mac OS X MAC address

Posted 18 April 2011 - 07:50 PM

Ok so I did a little research and came up with the following script, but I cannot figure out how to build an if statement to test if the MAC address actually did change because for whatever reason it does not always work and I have to re-run the script from the beginning. Any suggestions would be great!

#!/bin/bash

# Disconnects client from network.
echo "Deauthenticating network..."
sudo airport -z

# Displays current MAC address
echo "Current MAC address:"
ifconfig en1 | grep ether

# Obtain desired MAC address
echo -n "Enter desired MAC address: "
read MAC

# Obtain desired interface
echo -n "Enter desired interface: "
read interface

# Change MAC address
sudo ifconfig $interface ether $MAC

# Display new MAC address
echo "New MAC address:"
ifconfig en1 | grep ether

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1