Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-05-2015, 03:51 AM   #1
LQ Newbie
Registered: Apr 2015
Posts: 1

Rep: Reputation: Disabled
Post What is a good Linux script for changing an IP address statically in Ubuntu?

I have a shell script that currently changes the mac address of eth0 repeatedly. However, it does not change the public IP address, confirmed by wget -qO-


while [ 1 ]
echo "Changing mac address..."
let lastup=`date +%s`
macchanger -A eth0
let diff=`date +%s`-$lastup
if [ "$diff" -lt "$PERIOD" ]
sleep $(($PERIOD-$diff))
echo "Changed mac address successfully."
elif [ "$diff" -gt "$PERIOD" ]
echo "Command took longer than iteration period of $PERIOD seconds!"

The script needs to change the IP Address statically.

Also, ultimately, what I am trying to accomplish, for security reasons, is to frequently and automatically change a computer's public IP address and mac address. This way, my office's computers, when using the Internet, has an additional form of protection.
Old 04-05-2015, 11:21 AM   #2
Senior Member
Registered: Nov 2011
Distribution: Debian
Posts: 1,206

Rep: Reputation: 245Reputation: 245Reputation: 245
Why does changing your mac address provide security?

It will cause your local ip address to change because a new ip address will be allocated by DHCP.

Try using a firewall.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
IP address on static assigned ubuntu server keeps changing! dontworryaboutme Linux - Networking 8 03-30-2012 05:32 PM
Changing ip address on SUSE Linux pkmronger Linux - Networking 2 10-17-2008 06:03 AM
changing my mac address permanently at ubuntu jamil_2342 Linux - Newbie 2 03-16-2008 02:03 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:29 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration