Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I always like to test new config files before deploying them--with tools like apachectl configtest and named-checkconf.

It's rare that mistakes crop up, but catching them before deployment eliminates any impact. The one that has bit me in the backside several times is /etc/network/interfaces; I can't seem to find a tool to test it, and restarting the network on a remote machine only to discover it's no longer reachable is quite annoying--especially when we use a lot of bonding and bridging.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

To expand upon @jdthood's answer...

If the interface is already up, you can still use this method to validate the /etc/network/interfaces file. For example, assuming you have an error, you may see something like this:

$ sudo ifup --no-act eth0
/etc/network/interfaces:11: unknown method
ifup: couldn't read interfaces file "/etc/network/interfaces"

Apparently there's an error on line 11. Great. Thank heavens I didn't bounce the networking only to lose SSH access!

If all is fine, you will see:

$ sudo ifup --no-act eth0
ifup: interface eth0 already configured
share|improve this answer

If you don't have a eth0 this will not work, eg:

Ignoring unknown interface eth0=eth0.

But if you do like this:

ifup -a --no-act ; echo "status: $?"

With ok config:

ifup -a --no-act ; echo "status: $?"
run-parts  /etc/network/if-pre-up.d
run-parts  /etc/network/if-up.d
status: 0

With non-ok config:

ifup -a --no-act ; echo "status: $?"
/etc/network/interfaces:12: option with empty value
ifup: couldn't read interfaces file "/etc/network/interfaces"
status: 1
share|improve this answer

The following may do part of what you want.

ifup --no-act eth0
share|improve this answer

Your Answer

 
discard

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.