TurnKey Linux Virtual Appliance Library

How to leverage confconsole?

Jeremy's picture

This question is particularly for Liraz and/or Alon, but if anyone else knows (or can work it out for me) I'd be happy to hear. :)

I am currently doing a bit of work on my FOG TKLPatch and ideally it needs a static IP. Also by default my patch will include a DHCP server. My rationale for this is that it is easier for newbs to disable their current DHCP (probably provided by their router) than to configure it to use the FOG PXE boot. The plan is to make this configurable so advanced users (and/or users in corporate networks) can disable this and adjust their current DHCP. As a consequence of this the FOG server needs to know the nameserver (DNS), the default NIC and the gateway IP (also known as 'route' in Linux speak).

Anyway... I have sort of already worked out how to make a (hopefully reasonable) guess of these (which ironically would be supplied by the current DHCP) but then it just occured to me that I could perhaps just leverage TKL confconsole to discover them and/or set them!? Also I could also set the static IP via confconsole (and also make confconsole default to static IP).

Does this all seem like a reasonable idea? If so how would I go about it? I have had a little dig and found the confconsole.conf file but that only seems to define the default NIC. Looking at confconsole GitHub repo it doesn't seem like there are any other config files? Having a cusory glance it looks like I could leverage ifutil.py and/or ipaddr.py but I have had a browse through them and TBH its doing my head in! o_0

So for now I'm just going to persevere with what I'm up to and if I get no response I'll have another look at it later...

Liraz Siri's picture

Confconsole just configures /etc/network/interfaces

Hi Jeremy,

Happy new year and sorry for the late reply. The confconsole doesn't actually configure the network directly. What it does is tweak the /etc/network/interfaces file and then run the following commands:

ifdown eth0
ifup eth0

I propose you take a look at the manual page for the /etc/network/interfaces file to figure out how to set the parameters you want:

man interfaces
Jeremy's picture

Cool, thanks Liraz

As it turns out I ended up just copying confconsole.py into the first boot inithook folder and adjusting and reusing some it's functions to read and set the networking options.

As you'd know by now I'm not much of a programer and I don't really know what I'm doing, but I'm persistent and not scared to get my hands dirty. It still doesn't work exactly how I'd like and in some respects it's perhaps overkill, but it looks nice and it's a good start I reckon.

Liraz Siri's picture

Let me share a little secret.

Let me share a little secret. Even the most experienced programmers can't get by without a bit of trial and error. It's rare to get anything non-trivial to work out exactly right the first time around because nobody has a perfect mental model that includes every little tiny detail of the systems that they are trying to cajole into doing something useful.

Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account, used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <p> <span> <div> <h1> <h2> <h3> <h4> <h5> <h6> <img> <map> <area> <hr> <br> <br /> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <em> <b> <u> <i> <strong> <font> <del> <ins> <sub> <sup> <quote> <blockquote> <pre> <address> <code> <cite> <strike> <caption>

More information about formatting options

Leave this field empty. It's part of a security mechanism.
(Dear spammers: moderators are notified of all new posts. Spam is deleted immediately)