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?