3

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

#!/bin/sh
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 192.168.2.130\n"\
"  netmask 255.255.255.0\n"\
"  gateway 192.168.2.1\n"\
"  dns-nameservers 8.8.8.8\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?

6

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.