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.

How to check if eth address is taken from DHCP or set manually (static) using Python?

share|improve this question
1  
This similar question (near duplicate) may help: askubuntu.com/questions/47873/… –  mwalsh Jan 17 '12 at 20:40
add comment

1 Answer

I think it's going to depend on how the network is configured. Network connections in Ubuntu are either configured for the computer, or by the individual user through Network Manager (that little network icon in your notification area). Servers are generally configured system-wide from /etc, while desktops are configured by Network Manager.

If it's a system-wide configuration, you can parse /etc/network/interfaces.

If the network was configured by Network Manager on the desktop, you can interface with it. You can find an example Python script that prints connections from the Network Manager examples.

There might be a lower-level way of finding out whether any particular interface is dhcp, but I don't know of it.

share|improve this answer
add comment

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.