Connecting two computers without a hub/switch/router?
Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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!
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.
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.
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?
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.
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.
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.