I'm trying to write a script that sets the local IP address. This is what I have so far:

echo -n \
"# interfaces(5) file used by ifup(8) and ifdown(8)\n"\
"auto lo\n"\
"iface lo inet loopback\n"\
"auto eth0\n"\
"iface eth0 inet static\n"\
"  address\n"\
"  netmask\n"\
"  gateway\n"\
"  dns-nameservers\n"\
> /etc/network/interfaces
/sbin/ifup eth0

The file /etc/network/interfaces looks reasonably formatted, but the ifup command results in the following error:

RTNETLINK answers: File exists
Failed to bring up eth0.

How can I fix this?


I think this is caused by eth0 being already connected.

You might want to run /sbin/ifdown eth0 first.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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