Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to write script in Python to read/write /etc/network/interfaces file. It is not parse-able with builtin module ConfigParser because there are no sections.

Is there any parser for such files? Or maybe Python module to manage network configuration?

Or maybe there are other ways to read/change network interfaces settings?!

share|improve this question
If I look at the file on my pc, it looks like a simple text file with all data on a seperate line. what keeps you from writing your own parser/writer? – Timo Jan 10 '12 at 16:10
Yes. I had to write my own parser. But it was not easy task, because it's structure may be complex... – marcinpz Feb 13 '12 at 10:43
You should open source it! – Brian Cline Apr 19 '13 at 7:15

Here you can find a Awk script that can parse and modify /etc/network/interface, good starting point.

share|improve this answer

The Debinterface library might be what you're looking for.

share|improve this answer
This answer is incomplete. Include instructions on how to use this Debinterface library. – Parto Jul 19 '14 at 6:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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