I use static IP adresses.
When changing the IP of a network interface (eth0 or wlan0) the settings are saved to the network connections but when running ifconfig
or looking at Network Settings, either connections retain the old IP address.
I have tried restarting the networking service, the computers (yes, this occurs on more than one) and even reinstalling the OS.
PLEASE can somebody help me. I'm losing out on so much work this past week just trying to get Ubuntu 12.04 working like a normal OS.
Using the command sudo ip addr add 192.168.0.1/24 dev eth0
SOMETIMES works... the command switches the interface off, then when re-enabling it the IP reverts again. AAARGH!
I`m not a geek! I just want to share my experience. try stopping some services like network-manager! like: sudo service network-manager stop I could not change my mac... but after stopping network-manager I could change my mac permanently. remember not to restart it, but to change settings during the stopped services!!!
In general, your process will be:
/etc/network/interfaces
:service network-manager force-reload
/etc/network/interfaces
:service network-manager start
Of course, network-manager is capable of assigning static routes too. Just define your static route in network-manager GUI and then
service network-manager force-reload
at terminal. Done.Or switch back to DHCP-assigned dynamically by removing the static route definition from network-manager GUI, then
service network-manager force-reload
at terminal. Done.Or you can do it...
The harder way
Which also happens to be the logically flawless, sure-fire way.
These instructions assume your interface is "eth0". If it's not, you'll need to change all commands and areas entered to reflect your interface.
First, check if network-manager is running:
If it is running, right-click on Network-Manager and click "Edit connections...". Select the [interface] you're having trouble with, and click "Edit...". Click on the "IPv4 Settings" tab. If you see any entries under "Addresses", delete them. "Save" the settings, and close Network-Manager out.
Then, at a terminal, these four command strings, replace brackets and inner bounds area with value:
You should see that your interface now has the address you want, but we're not done. To make the settings persistent (i.e., across reboots), you'll need to edit (as root)
/etc/network/interfaces
, and either find the section related to your [interface], or you'll add a new section, separating each section (each "section" defines one interface) by a blank line:Example (If already exists in file, looks like or similar to):
Example (Change to this, or add if doesn't exist):
Of particular note is that you don't want
dhcp
-assigned IP, you wantstatic
-IP. Note the difference in structure between the above two examples.Save it.
Now if this interface will be meant for internet or external routing (i.e., communication on the interface needs to be able to access IPs outside of the network of the interface, which is defined by your netmask ultimately), then:
At terminal:
Verify your settings are correct with:
Now:
...to restart network-manager. At this point you should be good to go.
In the future:
If you need to change your static IP to another static IP after this, it's as simple as
sudo service network-manager stop
as exampled above,sudo ifconfig eth0 down
, edit/etc/network/interfaces
as exampled above and changing the IP address to taste,sudo ifconfig eth0 [ip address] netmask [netmask] up
as exampled above, and thensudo network-manager start
as exampled above, in that order.If instead you want DHCP to assign IP addresses automatically to the interface, it's as simple as
sudo service network-manager stop
as exampled above,sudo ifconfig eth0 down
, edit/etc/network/interfaces
as exampled above and remove the lines address, netmask, broadcast, gateway, and change the part that saysstatic
todhcp
,sudo ifconfig eth0 0.0.0.0 netmask 255.255.255.0 up
,sudo service network-manager start
. Done.In my case, just disconnecting and reconnecting to the network after changing the static IP worked fine! It might be worth a try.