1

I need to set the IP address of a ubuntu device() to be read from an EEPROM. The user has he option to change the IP address as well.

I know the commands to read and write to the EEPROM. But how do I edit the /etc/network/interfaces file so that it automatically fetches the IP address from the EEPROM on network start/restart?

Btw..I am aware of the methods to configure static IP address the normal way. But in that method, I could only hardcode the IP address in the interfaces file. Is there any way I can make this a variable, which I can populate from EEPROM and use in the interfaces file?

Also, I know that I can do the whole thing using a shell script by calling the EEPROM command and ifconfig. But I would like to do this using the standard init scripts. Also I need DHCP configuration to happen in the standard way.

4
  • Could you post the output of the command you're using that reads the IP address from the EEPROM? (No NVRAM?)
    – Fabby
    Aug 31, 2015 at 19:11
  • @Fabby I am planning to use something like this : dd if=sys/bus/i2c/drivers/at24/0-0050/eeprom count=1 bs=1 skip=48 But I can warp this in a script and return whatever I want. I am more concerned about how this string can be used in the configuration file.
    – kiran_g
    Sep 1, 2015 at 4:17
  • Can you edit your question so that all important information is in there? (the above comment!) Then add the of=/tmp/eeprom.txt parameters to ´dd´ and post the contents of the file eeprom.txt to paste.ubuntu.com and provide a link back (also in your question)
    – Fabby
    Sep 1, 2015 at 7:16

1 Answer 1

0

I got the answer from superuser site. The debian manual says that it is possible to configure an interface without an IP address like this:

   iface eth0 inet manual
      pre-up /path/to/script/which_changes_your_ip.sh
      post-down /path/to/script/which_removes_your_ip.sh

I am not sure how I can give credit to the person who gave me the solution. So I will just accept my answer itself.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .