0

I'm doing some remastering of Lubuntu 14.04 LiveCD, and need to run the following command at startup:

/sbin/ifconfig eth0 10.10.10.1 netmask 255.255.0.0

First, I tried modifying rc.local as follows:

#!/bin/sh -e
#
# rc.local

/sbin/ifconfig eth0 10.10.10.1 netmask 255.255.0.0

exit 0

Execution bit was set via:

chmod +x /etc/rc.local

That didn't work, so I tried writing this bash script (which I set to executable) and placing it in /usr/bin/

#!/bin/bash
/sbin/ifconfig eth0 10.10.10.1 netmask 255.255.0.0

In conjunction with the above action, I modified rc.local thus:

#!/bin/sh -e
#
# rc.local

/usr/bin/myscript

exit 0

Didn't work. Keeping the bash script in /usr/bin/, I edited /etc/xdg/lxsession/Lubuntu/autostart with this line:

@/usr/bin/myscript

This, too, failed to produce the desired result. Have I made a mistake with something I've tried, or is there something else I should be doing?

EDIT:

I've been unable to figure out how to utilize the casper parameters mentioned in Elder Greek's answer. Any further help on that front would be greatly appreciated.

The comments in the link he/she posted turned out to be helpful, though. One commenter pointed out that the bash script located at /usr/share/initramfs-tools/scripts/casper-bottom/23networking can be edited to assign a static ip to eth0.

The commenter also mentions editing the /etc/network/interfaces file, which is what I did. It works, but at a price: a lengthy delay at bootup while waiting on the network to configure. Here are the relevant bits:

/etc/network/interfaces

auto eth0
iface eth0 inet static
address 10.xxx.xxx.xxx
netmask 255.255.255.0
gateway 10.xxx.xxx.xxx

~/isolinux/isolinux.cfg

default live
label live
    say Booting an Ubuntu Live session...
    kernel /casper/vmlinuz
    append file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz quiet splash ip=frommedia --

In my experience, what normally happens is that, regardless of what changes you make to the network/interfaces file, when the LiveCD boots, it's forced to a default state by the 23networking bash script I mentioned prior. The ip=frommedia edit at the end of isolinux.cfg forces the script to use whatever is present in the network/interfaces file.

As the commenter mentioned, the 23networking script can be edited to set a static ip. If anyone can help me with that (not so good with bash scripting), that would be great.

  • 1
    Welcome to askubuntu. I believe thi8s question has been asked and answered here: askubuntu.com/questions/166986/run-commands-at-startup?rq=1 – Elder Geek Oct 22 '14 at 21:43
  • I've seen that question/answer. But as my post specifies, that solution is not working. The portions of the answer pertaining to running a script on reboot or shutdown don't seem relevant to my application. It's entirely possible that I've made a mistake somewhere, and if that's the case, I'd appreciate someone pointing it out. – Brian Oct 23 '14 at 13:39
0

If I attempt to run /sbin/ifconfig eth0 10.10.10.1 netmask 255.255.0.0 manually I get SIOCSIFADDR: Operation not permitted

SIOCSIFFLAGS: Operation not permitted

SIOCSIFNETMASK: Operation not permitted

Following the logic of that, I attempted

sudo /sbin/ifconfig eth0 10.10.10.1 netmask 255.255.0.0

Which completed without error. It would seem that you need super user powers for this to succeed.

You may find this documentation useful: https://help.ubuntu.com/community/LiveCDCustomization

Further research on the link above indicates that there is a casper parameter which is in the form:

ip=IFACE,ADDRESS,NETMASK,GATEWAY[:IFACE,ADDRESS,NETMASK,GATEWAY]*

I found this by googling Ubuntu Live CD custom static ip

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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