LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-16-2004, 01:45 PM   #1
pilot1
Member
 
Registered: Jun 2002
Location: USA
Distribution: Gentoo, Fedora Core
Posts: 408

Rep: Reputation: 30
Question 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!
 
Old 02-16-2004, 02:01 PM   #2
ugenn
Member
 
Registered: Apr 2002
Posts: 549

Rep: Reputation: 30
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.
 
Old 02-16-2004, 02:02 PM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,814

Rep: Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959
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.
 
Old 02-16-2004, 02:15 PM   #4
pilot1
Member
 
Registered: Jun 2002
Location: USA
Distribution: Gentoo, Fedora Core
Posts: 408

Original Poster
Rep: Reputation: 30
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?
 
Old 02-16-2004, 03:40 PM   #5
pilot1
Member
 
Registered: Jun 2002
Location: USA
Distribution: Gentoo, Fedora Core
Posts: 408

Original Poster
Rep: Reputation: 30
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.
 
Old 02-16-2004, 07:15 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,814

Rep: Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959
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.
 
Old 02-16-2004, 07:17 PM   #7
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,814

Rep: Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959Reputation: 5959
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
 
Old 02-16-2004, 08:25 PM   #8
pilot1
Member
 
Registered: Jun 2002
Location: USA
Distribution: Gentoo, Fedora Core
Posts: 408

Original Poster
Rep: Reputation: 30
I bought a crossover cable, and it works perfectly. Thanks everyone.
 
Old 07-15-2008, 04:31 AM   #9
khadija
LQ Newbie
 
Registered: Jul 2008
Posts: 8

Rep: Reputation: 0
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect whether a hub or switch is used ? antonypaul Linux - Networking 1 12-02-2005 08:47 AM
connect switch to hub? ody1 Linux - Networking 3 04-12-2004 08:42 AM
Connecting one modem-router for two computers over a network dushkinup General 1 03-06-2004 10:28 AM
two computers networked through hub penguin_warrior Debian 2 02-13-2004 11:05 PM
Connecting two computers via a Netgear router. SILVERPENGUIN Linux - Networking 7 01-19-2004 07:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:48 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration