Hello,
I'm working on an embedded Linux project and I'm having a little problem trying to handle user-configurable interface settings. The device is running emdebian and networking is handled by ifupdown.
The goal is to have a website where a user can chose either DCHP mode or static mode, and configure the static IP, gateway, netmask etc.
I've set up the following /etc/network/interfaces file
Code:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address $(/root/ethernet.sh address)
gateway $(/root/ethernet.sh gateway)
netmask $(/root/ethernet.sh mask)
Where /root/ethernet.sh is a script that returns the user configured parameters (EG. '/root/ethernet.sh address' returns 10.10.6.100).
This configuration works fine. However if I try to expand it to include the option for DHCP it doens't seem like I'm able to dynamically generate the 'iface eth0 inet static' line. For example if I use the following
Code:
auto eth0
$(echo "iface eth0 inet static")
ifup complains about misplaced options.
If I try
Code:
$(echo -e "auto eth0 \n iface eth0 inet static")
ifup complains about unknown interface eth0.
Anyone have any ideas? I'm also open to better ways to do this..