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.

i assigned a temporary ip address to my eth0 interface using this command

sudo ifconfig eth0 169.254.1.1 netmask 255.255.0.0

as described here

it works fine, when i do ifconfig it shows the newly assigned ip address.

eth0      Link encap:Ethernet  HWaddr 5c:26:0a:4f:32:11  
          inet addr:169.254.1.1  Bcast:169.254.255.255  Mask:255.255.0.0
          inet6 addr: fe80::5e26:aff:fe4f:3211/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:774 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1160 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:170598 (170.5 KB)  TX bytes:218967 (218.9 KB)
          Interrupt:20 Memory:f6900000-f6920000 

i expected this ip address should hold until i flush it out. but soon afterwards it is reset

eth0      Link encap:Ethernet  HWaddr 5c:26:0a:4f:32:11  
          inet6 addr: fe80::5e26:aff:fe4f:3211/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:784 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1202 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:174678 (174.6 KB)  TX bytes:228013 (228.0 KB)
          Interrupt:20 Memory:f6900000-f6920000 

i only need this ip address temporarily and rather not change my /etc/network/interfaces which reads

auto lo
iface lo inet loopback

i am on 12.04, any suggestion would be helpful thanks

UPDATE

this is my motive. i want to transfer some large files over ethernet. I have laptops with Gigabit capable adapters but slow routers. When both machines are windows i can simply hook them up with a network cable and after some time when they dont find a dhcp server they revert to link-local address of range 169.254.x.x/16 and file transfers would just work. Unfortunately in Ubuntu this does not happen. I have to manually set an ip address. Then the machines can ping each other and can transfer files, but only for a short interval of time.

One thing I can do is keep issuing sudo ifconfig eth0 ... every 30 secs or so to keep things working but this is pretty annoying. I have to do this kind of transfers quite frequently so would rather not take the hassle of modifying etc/network/interfaces everytime.

share|improve this question
    
It is odd that the IP address is disappearing, but the IPv6 address is not (inet6 addr). What type of device are you connecting to? Is is possible that it is an IPv6 only network? –  superdesk Jan 6 at 17:46
    
its a laptop running windows 7 –  mzzzzb Jan 7 at 3:10
    
You are directly connecting the Ubuntu machine to another computer? No router or hub? You can not just connect two computers with an ethernet cable to network them. One can "share" an existing connection, or you could use a cross-over cable to connect them. –  superdesk Jan 7 at 3:26
    
thanks for your interest in my problem. actually modern network adapters(i guess its called autosensing or something) dont need crossover cables as such. they can detect what type of endpoint is in the other end and adjust accordingly. i regularly use this feature (on the same machines) and even here the problem is not that the machines cant communicate but something on the ubuntu side is resetting my static ip time and time again. PS see my update for my original motive to do this. –  mzzzzb Jan 7 at 9:50
    
Was the answer helpful? –  i08in Feb 13 at 20:11

2 Answers 2

You have a GUI method to do this:

Type "network" in your dash and click on "Network Connection". Click on "edit" after clicking on the present network connection in "wired connection".

In the IPv4 settings, set your method as "manual" and set the IP address, gateway and netmask address as required.

This will set the IP address manually.

To know your IP address, netmask and gateway address, type this on a terminal:

nmcli dev list iface eth1 | grep IP4
share|improve this answer
up vote 0 down vote accepted

Following @Jobin's answer I made a discovery that was easier.

In Network management under wired connection tab -> IPv4 settings, you can change method to Link Local (from Automatic DHCP). for a quick file sharing session, this is easier as you dont have to enter a manual IP address everytime.

share|improve this answer
    
If this solved your problem, please mark the answer as an accepted solution. –  i08in Feb 14 at 4:55

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.