CentOS script for mac address change

I have in my home internet connection from Multimedia. I didn’t bought yet a WiFi router so I must share a cable between two laptops: mine and my wife 🙂 Usually when I switch cable I must also restart modem because it has to get new mac address from the device.

Because I don’t want to restart the modem all the time I want to connect my laptop to the internet (because usually my wife laptop is connected) i wroted a small script which is changing my network card mac address.

The script looks like this:

/sbin/service NetworkManager stop
/sbin/ifdown eth0
/sbin/ifconfig eth0 hw ether MAC_ADDRESS
/sbin/ifup eth0
/sbin/service NetworkManager start

You may download the script from here.

Of course you have to be root to do this.

Leave a Reply

Your email address will not be published. Required fields are marked *