There are multiple possible answers to this. But let me start with one basic part. If you only have one NIC per computer then you need a device to connect all four to. This is called a switch. Many 'modem' and 'routers' are in fact multiple devices in one box. The four ports on the LAN side usually act the same as a regular cheap switch.
You then have this setup:
[switch]
| | | |
/ | | \
/ | | \
Computer 1 C2 C3 Computer 4
To connect an end device (the computer) to a switch you use a normal ethernet cable.
To connect two similar device (PC direct to another PC, or switch to switch) you would use a crossover cable.
Note that most modern switches include auto MDI/MDX and will auto matically compensate for the wrong cable. As do all gigabit switches.
Lacking a switch or a device which includes a switch you can do something with at least two network cards in each PC, forming a ring. Or one network card per other PC (so 3 NICs per PC in this case). This post shows a nice diagram on on how that was done with 3 PCs. (Ignore the internet part).
I mention that for completeness sake. This is not something you will need in most cases.
That answers the part about the physical connection.
Net up if the configuration. How you do that depends per OS, but assuming TCp/IP you want to give each computer a different IP address. And since you want them to communicate give them an IP in the same network range.
The easiest way for a small setup is to do that manually. E.g.
- On PC 1 set IP 10.0.0.1 with netmask 255.255.255.0
- On PC 2 set IP 10.0.0.2 with netmask 255.255.255.0
- On PC 3 set IP 10.0.0.3 with netmask 255.255.255.0
- On PC 4 set IP 10.0.0.4 with netmask 255.255.255.0
That will put all PCs in the network part 10.0.0.x. They can talk to eachother. You are done.
Alternatively you can set up a DHCP server on one of the PCs or on a 'very capable switch' (read: a SOHO router will do) and set all the PCs to DHCP. This means the PCs will ask there network to give them all the needed information. You will have to put the answers to this in the DHCP servers configuration.
The latter is more work and for a simple setup I would skip it. But it scales a lot better and when you get to dozens of PCs this is the way to go.
Lastly, read this post on our sister site serverfault. It explains a lot of the background.