Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

In Ubuntu desktop 13.04 changing /etc/network/interfaces file don't change ip address or convert DHCP to static network interface configuration. after changing the file I tried

sudo service networking restart

----------EDIT----------

I have connected to system with ssh.

share|improve this question
    
How are you changing the IP when editing the` /etc/network/interfaces` file? –  Mitch Aug 21 '13 at 11:46
    
@Mitch link –  neckTwi Aug 21 '13 at 11:50
1  
You mean to say you edited that file but it doesn't have any effect? It doesn't change the IP address? –  Alaa Ali Aug 21 '13 at 11:52
    
@Alaa i did sudo service networking restart –  neckTwi Aug 21 '13 at 11:53

4 Answers 4

By default, Ubuntu (or Network Manager to be specific) ignores the /etc/network/interfaces file. To make the changes you made take effect, execute the following commands:

sudo ifdown wlan0
sudo ifup wlan0

Assuming that wlan0 is the interface you are editing. Once you do that, wlan0 will come up with the settings you have under its stanza in /etc/network/interfaces.


Edit: since you're connected through SSH. You can try the following:

Edit /etc/NetworkManager/NetworkManager.conf and change ifdown managed to false:

[ifupdown]
managed=false

Then, try:

share|improve this answer
    
if i use ifdown i will loose connection to the system. If it dont work there is no way to connect again. –  neckTwi Aug 21 '13 at 12:10
    
i can try restarting the system but if static ip is not set i cant know its dynamic new ip –  neckTwi Aug 21 '13 at 12:14
    
@neckTwi try my updated answer. Also, are you sure it's going to have a different IP? Usually, there's a lease period where, even if you restart the machine, it'll still get the same IP until the pre-defined lease period expires. But that depends of course, I'm just saying what's on my mind. –  Alaa Ali Aug 21 '13 at 12:17
    
what does [ifupdown] managed=false mean? –  neckTwi Aug 21 '13 at 12:20
    
If it is set to true, NetworkManager "manages" the interfaces mentioned in /etc/network/interfaces. If it's set to false, NetworkManager does not manage the interfaces mentioned there. –  Alaa Ali Aug 21 '13 at 12:27

Try this. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo -i
gedit /etc/network/interfaces

This is done with the help of guntbert

Once done save and exit

add this line DHCP mode

auto eth0
iface eth0 inet dhcp

Static mode

auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx

Once done save the file, and:

sudo service resolvconf restart
share|improve this answer
    
These aren't permanent changes. They'll be overridden when the computer restarts. –  Alaa Ali Aug 21 '13 at 11:52
    
that dont survive system restart –  neckTwi Aug 21 '13 at 11:52
    
Do you have a static or dynamic IP? –  Mitch Aug 21 '13 at 11:57
    
@guntbert Is this better? Thanks :) –  Mitch Aug 21 '13 at 16:49

I am posting this answer to give another dimension to the question and existing answers, not as a direct answer to the original question. Your IP will be lost at reboot. However, I think it's worth you understanding these commands, iproute2 package is the currently method of on-the-fly interface management via the CLI. Lots of people are still writing scripts using ifconfig for example.

I think it's worth noting the use of the iproute2 packages;

Show current IPs on all interface (ip addr)

n2:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:e0:4c:6d:0a:49 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 74:ea:3a:ad:2e:00 brd ff:ff:ff:ff:ff:ff
    inet 172.22.0.221/24 brd 172.22.0.255 scope global wlan0
    inet6 fe80::76ea:3aff:fead:2e00/64 scope link 
       valid_lft forever preferred_lft forever

Add an IP address to my wireless interface (ip addr add)

n2:~$ sudo ip a a 10.0.0.56/24 dev wlan0
[sudo] password for bensley: 

Show my IP addresses again, note the additional IP on wlan0 (ip addr)

n2:~$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:e0:4c:6d:0a:49 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 74:ea:3a:ad:2e:00 brd ff:ff:ff:ff:ff:ff
    inet 172.22.0.221/24 brd 172.22.0.255 scope global wlan0
    inet 10.0.0.56/24 scope global wlan0
    inet6 fe80::76ea:3aff:fead:2e00/64 scope link 
       valid_lft forever preferred_lft forever

Show the link state of my interfaces (ip link)

n2:~$ ip l
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:e0:4c:6d:0a:49 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 74:ea:3a:ad:2e:00 brd ff:ff:ff:ff:ff:ff

Delete this 2nd IP address from my wireless interface (ip addr delete)

n2:~$ sudo ip a del 10.0.0.56/24 dev wlan0

Show IP addresses just for wlan0 to check (ip addr show wlan0)

n2:~$ ip a s wlan0
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 74:ea:3a:ad:2e:00 brd ff:ff:ff:ff:ff:ff
    inet 172.22.0.221/24 brd 172.22.0.255 scope global wlan0
    inet6 fe80::76ea:3aff:fead:2e00/64 scope link 
       valid_lft forever preferred_lft forever

The same commands could have been used to remove my current IP, 172.22.0.221 then add another, but I would have lost connectivity, which I can't right now. Below are those commands though, after which I would also need to add a new default route route;

n2:~$ ip r s
default via 172.22.0.1 dev wlan0  proto static 
169.254.0.0/16 dev wlan0  scope link  metric 1000 
172.22.0.0/24 dev wlan0  proto kernel  scope link  src 172.22.0.221  metric 2 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1

ip a del 172.22.0.221/24 dev wlan0

ip a a 172.22.0.10/24 dev wlan

ip r a default via 172.22.0.1

# Re-add the same default route ^ via the same default gateway
share|improve this answer

You can change your ip address by using the following script:

Open terminal with Ctrl + Alt + t and type the following command:

sudo vi /etc/network/interfaces

OR

gksudo gedit /etc/network/interfaces

Find eth0 section and setup IP address as follows:

auto eth0
iface eth0 inet static
address 192.168.2.1
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255

Save and close the file. Once done, restart network:

$ sudo /etc/init.d/networking restart

Verify new IP address by using the following command :

$ ifconfig eth0
$ ifconfig
share|improve this answer
    
This is just a vehicle for your own websites; please disclose your affiliation to ip-details.com and Whoisxy.com, or don't link to these sites from all your posts. See the help center. –  Martijn Pieters Jun 19 at 11:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.