0

I've been doing the programming for a start up company I know to get some experience. I've been told I'll need to relay data from my original piece of software running on one computer to 8 others using ethernet. Bear in mind I haven't really done much network stuff before.

I see that I'll need the python socket module so I've learned a bit of that. I also get that I'll need a network switch hardware-wise.

What I'm unsure about is how I set up the network in the first place. I get that I can do this via Device Manager but setting all computers to the same subnet and different IP addresses. However, the idea is that people will bring their laptops to be connected, so I don't want to have to mess around with each laptop to connect it to the network. So is there a way of doing this directly in Python so that I can just write it in the program that I'll have running on each laptop?

Thanks!

8
  • an ethernet wire only has 2 ends ... Commented Feb 17, 2016 at 20:29
  • that is what the switch is for I beleive Commented Feb 17, 2016 at 20:57
  • are you using a switch or a router? if its a router it should already have its own dhcp server? is this actually connected to the internet or just a local lan? Commented Feb 17, 2016 at 22:06
  • It'll be a local lan without internet connection. Using just a regular switch. Commented Feb 18, 2016 at 11:18
  • hadcode the ip of your device and run a socket server ... the other computers will need to know your ip ... Commented Feb 18, 2016 at 16:57

1 Answer 1

1

You need a DHCP server and people's NIC's to retrieve their network configuration automatically.

Windows:

netsh interface ip set address "Local Area Connection" dhcp

Debian (/etc/network/interfaces):

auto eth0
iface eth0 inet dhcp

Red Hat (/etc/sysconfig/network-scripts/ifcfg-eth0):

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

I suppose you could use Python or whatever language you're convenient in to fetch the relevant interface's name, as they're not guaranteed to be named "eth0" or "Local Area Connection", e.g. subprocess.Popen("cat /proc/net/dev/").

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for your answer, I feel like it's pointing me in the right direction, but I'm a bit of a noob at network stuff. So presumably I'd want to set up the DHCP server on the main computer that is distributing the data - but then how would the new computers know which subnet to be on in order to connect to the server computer?
They don't need to know the subnet. As long as their NIC's are set to DHCP, the protocol takes care of them being discovered on the network (via the broadcast address). Once they're discovered, a DHCP request is sent. In return, the client receives whatever is set in the DHCP server (IP address, default gateway address, DNS address (optional)).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.