LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Connecting two computers without a hub/switch/router? (https://www.linuxquestions.org/questions/linux-networking-3/connecting-two-computers-without-a-hub-switch-router-146795/)

pilot1 02-16-2004 01:45 PM

Connecting two computers without a hub/switch/router?
 
I have two computers, each with a NIC. One is running Fedora Core 1, the other Windows 98.
Is there any way to connect them without a hub/switch/router in the middle? I don't have a crossover cable, so is it possible to do it with just a "normal" ethernet cable?

And if it is, how would I set it up so that the internet on the FC computer can be accessed by the Windows computer? I know i'd have to do IP masquerading, but I don't remember the iptables commands and everyone seems to say a different things. The NIC on the FC computer is eth0, and it gets the internet from wlan0.
Thanks!

ugenn 02-16-2004 02:01 PM

You can't with a straight eth cable. If the NICs have a BNC connector (extinct on newer NICs), you could connect them in a physical "bus" topo using coax cables. I would just spare the couple of bucks to get a x-cable and get it over with.

For masqurading, you need a similar rule in your firewall...
iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
and enable packet forwarding (use sysctl or write to proc/sys/net).

On the win98 side, set the gateway's IP to the FC box's IP.

michaelk 02-16-2004 02:02 PM

Re: Connecting two computers without a hub/switch/router?
 
Quote:

Originally posted by pilot1
I have two computers, each with a NIC. One is running Fedora Core 1, the other Windows 98.
Is there any way to connect them without a hub/switch/router in the middle? I don't have a crossover cable, so is it possible to do it with just a "normal" ethernet cable?

Nope. The only way to connect two computers (via ethernet) without a hub/switch/router is a crossover cable. You can rewire a straight to a crossover configuration but if you do not have access to the tools it would be much simpler to just go out and purchase one.

pilot1 02-16-2004 02:15 PM

Thanks, if I had a crossover cable would it act like there was a switch between the two NICs? In other words, it would act like a normal network, right?

pilot1 02-16-2004 03:40 PM

Oh, almost forgot.
So I just turn on IP forward, and add this rule to iptables: iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE ?
What is the command to forward a port from this computer to the other one? Just assume this computer is 2.2.2.2 and the other one is 3.3.3.3, and the port being forwarded is 111, so it doesn't get confusing.

And is that everything to set up NATing? I remember it being more complicated the last time I did it, but maybe I made it harder than I needed to.

michaelk 02-16-2004 07:15 PM

Quote:

Originally posted by pilot1
Thanks, if I had a crossover cable would it act like there was a switch between the two NICs? In other words, it would act like a normal network, right?
Like a normal network. But more like a hub then a switch.
A switch is a smart hub where it can direct traffic between ports. A hub will just pass traffic received to all ports.

FYI
Ethernet cable contains 8 wires 4 pairs of twisted wires. Only 2 pairs are actually used, 1 pair for transmitting and 1 pair for receiving. Network cards have a receiver and a transmitter. If you connect the straight cable between the two computers then the transmiters will be connected together as well as the receivers to receivers. In order for the PC #1 NIC transmitter to connect to PC#2 receiver and like wise PC #1 NIC receiver to connect to PC #2 transmitter you need to swap the wires at one end of the connecter. Hence the crossover cable.

michaelk 02-16-2004 07:17 PM

Quote:

Originally posted by pilot1
Oh, almost forgot.
So I just turn on IP forward, and add this rule to iptables: iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE ?

That should work.

To enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_foward
echo 1 > /proc/sys/net/ipv4/ip_dynaddr

pilot1 02-16-2004 08:25 PM

I bought a crossover cable, and it works perfectly. Thanks everyone.

khadija 07-15-2008 04:31 AM

Can u help me
 
I want to know each step for establishing a Peer to Peer connection in two Laptops having Fedora 8. Can u plz help me


All times are GMT -5. The time now is 06:26 AM.