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?!

  • 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
  • 2
    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.


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

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

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.