Are there any tools baked in to linux that I can use to validate the syntax in /etc/network/interfaces or /etc/network/interfaces/*.conf files akin to the way I can validate sudo using visudo before installing it.

I'm writing scripts to be deployed in the old "internet-of-things-that-aught-to-be-set-up-right-in-the-first-place-but-most-likely-aren't" methodology and want to unit test my config generators.

1 Answer 1


You can use the command ifup --no-act --interfaces=/home/user/interfaces.new eth0 to check for syntax errors in a specified interface file on an interface that is already up.

If errors exist you will get a message stating the incorrect line number and something about being unable to parse the interface file.

If there are no errors, then you will get a message stating that the interface is already configured.

You can check the return value of the command by looking at the value of the $? variable after running the command in your script.

Look at man ifup for more information.

  • 1
    ifup has to read from interfaces it can see, not an arbitrary location. So if I have to re-configure an interface, backing up the interface config, running that ifup --no-act copying in my new one and restoring it if there are shell errors is the way to go. It's a little risky, but oh well. Doing it in python so I should be able to catch exceptions easy enough. Dec 10, 2015 at 21:31
  • 1
    ifup --no-act --interfaces=/home/user/interfaces.new eth0
    – ewatt
    Dec 10, 2015 at 21:47

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.