How would I get a list of all ip addresses that are on a network using python.

Recommended Answers

All 6 Replies

You can implement ping in python. Example.

Ask your user for an ip range, ping all of the addresses and see which one's respond.

@Hiroshe is there a simpler way?

That way seems pretty simple to me. "ping all addresses and check which ones respond". In fact, I beleive the is the only practical way.

Another way might be to set it up as a packet sniffer, and see which hosts are actively sending and recieving traffic.

Unless you're talking about the implementation of ping. The answer is "not with pure python". There might be a module availible with an implementation of ping.

@Hiroshe sorry, it does seem like the best way but it's just the example seemed a bit long. Do you have any code you could share with me to do with the pinging all ip addresses on a network or a packet sniffer? Thanks anyway

Just wrap the example code I gave you in a loop, iterating through possible IP addresses. 200 LoC isn't very long at all, and I wouldn't think I can do much better anyways.

We're not going to write code for you. He help you learn how to program, and help you with specific problems you might have or point you into the right direction.

@Hiroshe ok thanks :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.