1,105,281 Community Members

how to change ip address randomly in ubuntu through terminal

lolboy123
Newbie Poster
1 post since Jan 2013
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
Unverified Member
 
0
 

hi,
please tell me how to change ip address randomly in ubuntu through terminal.
thanx in advance

Member Avatar
CimmerianX
Practically a Master Poster
658 posts since Jul 2010
Reputation Points: 53 [?]
Q&As Helped to Solve: 83 [?]
Skill Endorsements: 13 [?]
 
0
 

What do you mean by "change IP randomnly"? You normally wouldn't do this since you need an IP in a certain Range with proper MAsk and Gateway for proper communications.

Do assign an IP via command line, you would use (for example):

ifconfig eth0 192.168.1.2 netmask 255.255.255.0
route add default gw 192.168.1.1
ifconfig eth0 down
ifconfig eth0 up

Member Avatar
mathieu67
Newbie Poster
5 posts since Aug 2006
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

There are a few sources that will show you how to change your ip address online. Google it and you will fine many

Member Avatar
rubberman
Senior Poster
3,984 posts since Mar 2010
Reputation Points: 513 [?]
Q&As Helped to Solve: 499 [?]
Skill Endorsements: 87 [?]
 
0
 

On Red Hat systems it is /etc/sysconfig/network-scripts/ifcfg-Auto_ethN (where N is the NIC you want to set - usually eth0). You would edit that file to change the static IP address (IPADDR=IPV4address, such as 192.168.1.100 - you can't do this with DHCP) and then run the "service network restart". Bingo! Your address has now been changed.

For Ubuntu, you would go to /etc/NetworkManager/system-connections. Each NIC (hardware or WiFi) will appear as the file named "* connection N" where the leading asterisk is "wired" for a hardwire connection, and the trailing N is a number for the connection #, such as 0 for eth0, 1 for eth1, etc). I'm not sure what a WiFi would appear as since I am running this in a virtual machine without WiFi... :-)

In the appropriate file you will find the section [ipv4] and an entry "addresses1=YourIPV4Address;YourGatewayAddress". Example (from my VM):

[ipv4]
method=manual
dns=68.94.156.1;
addresses1=192.168.1.50;24;192.168.1.254;
may-fail=false

So, change the IPV4 address (leave the gateway alone), and then, as mentioned above, restart the network services, except that for Ubuntu you would use "service restart network-manager" either as root, or with sudo. Oops. I mean "service network-manager restart"... :-) Danged keyboard keeps mistyping for me!

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article