• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing IP address of an interface without rebooting Ubuntu  RSS feed

 
Rahul Dayal Sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can I change the IP address of my NIC's eth0 and get the changes effected without restarting Ubuntu?

I have tried the following commands after changing IP:
sudo ifdown -a
sudo ifup -a

But they dont work.
Running "sudo ifdown eth0" gives an error : "eth0 not configured"

I have also tried "sudo service network-manager restart"

Can someone suggest a method for this?




 
Tim Holloway
Saloon Keeper
Posts: 18797
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check your /etc/network/interfaces file. That's where Ubuntu/Debian define the IP addresses (or address leasing) for the NICs.

Normally you can just change that file and use ifdown/ifup on eth0. Or do it brute-force via the ifconfig or "ip" commands.
 
Rahul Dayal Sharma
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed the /etc/network/interfaces file with policies for interface eth0 (dynamic followed by static)

Then interface was brought up using 'ifup eth0'. (I wanted the dynamic IP to be assigned and it worked)
The interface was brought down and up again. (Now I wanted the static IP to be assigned and it worked)


It worked fine for once, then I started getting the same error : 'interface eth0 not configured"

But during both attempts, when we tried bringing the inteface down using 'ifdown', we were getting the same error: 'interface eth0 not configured"

Any help is appreciated.
Thanks in anticipation,
 
Tim Holloway
Saloon Keeper
Posts: 18797
74
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really know at this point. The closest I can come is pretty wild. Check dmesg and the system logs. These days the hotplug mechanisms can rename the eth devices. You see this especially when working with VM host machines. When that happens, the normal configuration won't work because the device is "no longer there" - under its original name, anyway. But there should be a log message in that case.

Fixes may include statements in the /etc/modules config and/or udev, but don't ask for details. I get confused enough on my own systems!
 
Andrew Polansky
Ranch Hand
Posts: 310
18
Linux MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Simply use ifconfig eth0 1.2.3.4.

I am running on Linux Mint, which is based on Ubuntu. Take a look at the effects of running this command (I used wlan1 in my case instead of eth0).


Remember just that the effects of that command will be lost after reboot.

If you want to switch your IP to other network, remember also about changing other parameters like mask and gateway.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!