LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 04-14-2004, 11:09 AM   #1
hamish
Member
 
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Rep: Reputation: 30
2 network cards in one computer


Hey

I'm trying to connect my girlfriends computer to the internet via my computer. My computer goes to the internet via a gateway on a different computer.

Here is the setup I want:

Girlfriends PC --> My computer --> Gateway --> Internet

Part 1
My computer has two network cards, so first of all, I want to get my girlfriends pc and mine talking to each other. I have a crossover adapter and a cable plugged into my second net card and into my girlfriends PC.

My ifconfig is:

root@archimedes hamish # ifconfig
eth0 Link encap:Ethernet HWaddr 00:0C:6E:04:3D:7D
inet addr:172.24.15.228 Bcast:192.168.0.255 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4917 errors:0 dropped:0 overruns:0 frame:0
TX packets:4915 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2822146 (2.6 Mb) TX bytes:842967 (823.2 Kb)
Interrupt:10 Base address:0xb000

eth1 Link encap:Ethernet HWaddr 00:C0F:0E:5A:3B
inet addr:172.24.15.229 Bcast:192.168.0.255 Mask:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:127 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:10888 (10.6 Kb) TX bytes:300 (300.0 b)
Interrupt:5 Base address:0xc000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:169 errors:0 dropped:0 overruns:0 frame:0
TX packets:169 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:13720 (13.3 Kb) TX bytes:13720 (13.3 Kb)

My girlfriends PC has the following IP stuff:
inet addr:172.24.15.230 Bcast:192.168.0.254 Mask:255.255.255.240

With this set up, I cannot ping my girlfriends pc. I have tried putting both my IPs to the same number (and then i read that that would confuse my computer).

I cannot believe that I need to do anything special to get my girlfirends and my PC talking. It should just be a case of having a crossover adapter (as far as I can see).

Question 1: What do I need to do to get my PC and my girlfiends PC talking to each other?


Part 2
Once I have my girlfriend's PC and mine talking (pinging) to each other, I wish to allow her computer to access the Internet through my compuyer (mine goes through a gateway)

The IP stuff of the gateway computer (set up by my flatmate) is:
inet addr:172.24.15.225 Bcast:172.24.255.255 Mask:255.255.255.240

I understand that I need NAT and that I should IP forward my girlfriend's IP address on my computer to send it to the gateway.

Question 2: Is there an easy to read how-to for setting up NAT?

Question 3: should I make the gateway on her computer equal to MY IP or to that of the gateway machine?

Thanks for reading this and I really hope that you can help me. I'm currently recompiling my kernel with iptables in it so that I can act on your suggestions. Thanks.

Hamish
 
Old 04-14-2004, 11:36 AM   #2
nightjar
Member
 
Registered: May 2002
Location: Argentina
Distribution: Mandrake 9.2
Posts: 177

Rep: Reputation: 30
The topology is

GF PC <----> My C
| | (both connect to Gateway)
Gateway (another PC)
|
Internet


It's Ok?

Or it's necessary that GF PC connect Internet via My computer?

Last edited by nightjar; 04-14-2004 at 11:38 AM.
 
Old 04-14-2004, 11:56 AM   #3
hamish
Member
 
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Original Poster
Rep: Reputation: 30
what should the two netcards on My PC be? SHould the IPs both be the same?

hamish
 
Old 04-14-2004, 12:28 PM   #4
hamish
Member
 
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Original Poster
Rep: Reputation: 30
OK,

I have this situation now.

The two cards in my computer are active:
eth0: inet addr:172.24.15.228 Bcast:192.168.0.255 Mask:255.255.255.240
eth1: inet addr:172.24.15.229 Bcast:192.168.0.255 Mask:255.255.255.240

currently, eth0 is the one which is talking to my girlfriends PC.

at this stage, I can ping Google, but I can't ping girlfriend.

If I put eth1 DOWN, then (and only then it seems) can I ping my girlfriends PC. obviously, at this stage, I cant ping Google though.

How can i be able to ping girlfirends PC AND Google at the same time??

if it helps, my route -n (when both eths are running, I can ping Google, but not girlfriend) is:
root@archimedes hamish # route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
172.24.15.224 0.0.0.0 255.255.255.240 U 0 0 0 eth1
172.24.15.224 0.0.0.0 255.255.255.240 U 0 0 0 eth0
127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo
0.0.0.0 172.24.15.225 0.0.0.0 UG 0 0 0 eth1


Hope some of this helps you to help me. I really want to get this working as I'm moving my girlfriend from Windows to Linux and I want it to be as easy as possibel for her...

thanks
hamish
 
Old 04-14-2004, 07:24 PM   #5
nightjar
Member
 
Registered: May 2002
Location: Argentina
Distribution: Mandrake 9.2
Posts: 177

Rep: Reputation: 30
which what is connect eth1 in My PC?
One with GF and another with Gateway (another PC) ?

You don't need 2 cards in my Pc.

You need a T

GF<--->My PC<--->Gateway

In My PC you need a T switch not 2 cards
 
Old 04-15-2004, 12:26 PM   #6
hamish
Member
 
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Original Poster
Rep: Reputation: 30
What is a T?

eth1 is the one which goes to Girlfiends PC.

Hamish
 
Old 04-17-2004, 03:29 AM   #7
nightjar
Member
 
Registered: May 2002
Location: Argentina
Distribution: Mandrake 9.2
Posts: 177

Rep: Reputation: 30
I think that u must connect the 2 Pc to a hub and then from it to internet or you must obtain a Base T ethernet card as it or similar.

The connection will be GF<--->PC<--->Internet

Obviously you'll have 1 IP in each machine of the same subnet
 
Old 04-17-2004, 03:29 AM   #8
nightjar
Member
 
Registered: May 2002
Location: Argentina
Distribution: Mandrake 9.2
Posts: 177

Rep: Reputation: 30
I think that u must connect the 2 Pc to a hub and then from it to internet or you must obtain a Base T ethernet card as it or similar.

The connection will be GF<--->PC<--->Internet

Obviously you'll have 1 IP in each machine of the same subnet
 
Old 04-17-2004, 02:00 PM   #9
hamish
Member
 
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Original Poster
Rep: Reputation: 30
Hey,

I have got them both talking to each other.
I put the two network cards with are connected to each other on a different subnet and IP to the other card (IP: 10.30.0.* ; subnet: 255.255.0.0).

They now talk to each other fine. However, I can't get my GF's PC talking to the internet. I have enable ip_forwarding.

Is there anything in the kernel I need to enable other than IP tables and ip_forwarding?

Please give me some pointers...

thanks a lot
Hamish
 
Old 04-17-2004, 04:54 PM   #10
nightjar
Member
 
Registered: May 2002
Location: Argentina
Distribution: Mandrake 9.2
Posts: 177

Rep: Reputation: 30
I don't know what is the configuration of the whole network

What about the third computer ? What is the static IP ?

Are its behind a firewall?

What is the Gateway of the GF and MyPC computer?
 
Old 04-17-2004, 05:44 PM   #11
hamish
Member
 
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Original Poster
Rep: Reputation: 30
OK, the current set up is:

Internet
|
gateway (172.24.15.225/255.255.255.240)
|
My PC (172.24.15.228/255.255.255.240 and 10.30.0.96/255.255.0.0)
|
GF PC (10.30.0.97/255.255.0.0)

The gateway for the whole network is 172.24.15.225. I have enabled IP forwarding on My PC. There is a firewall on the gateway, but that isn't very stringent. Although, I wonder if I have to ask my flatmate to enable 10.30.0.* IPs in order for my GF PC to get through the firewall. Is that a possibility?

Hamish
 
Old 04-17-2004, 11:44 PM   #12
nightjar
Member
 
Registered: May 2002
Location: Argentina
Distribution: Mandrake 9.2
Posts: 177

Rep: Reputation: 30
But why 2 cards in My PC?

How can GF connect to Gateway if the connection is btw gateway and MyPC?



I insist : you must do

Internet<--->GW<--->MyPC<--->GF

and I'm thinking that the gateway of GF must be MyPC

I'm not sure but probe it

NB: reboot the system after setup the new configuration
 
Old 04-18-2004, 03:08 AM   #13
hamish
Member
 
Registered: Aug 2003
Location: Edinburgh
Distribution: Server: Gentoo2004; Desktop: Ubuntu
Posts: 720

Original Poster
Rep: Reputation: 30
OK,

the gateway for GF PC is MY PC.

In IP tables, I have set:
iptables -A FORWARD -i eth1 -j ACCEPT
which I believe will forward everything through eth1. Although, I was wondering if the "eth1" should be "eth0" (ie, the device which goes to the gateway and to the internet).

There are 2 cards in MY PC because I don't have a Base T. I have been lead to believe that two net cards in one PC is perfectly fine.

Thanks for being so helpful. Sorry that I'm not catching quickly.

Hamish
 
Old 04-18-2004, 04:00 AM   #14
ldp
Member
 
Registered: Apr 2004
Location: Belgium Antwerpen
Distribution: slackware - knoppix
Posts: 141

Rep: Reputation: 18
First something I'm curious about but it doesn't seem to be a problem.
You have two nic in your pc, one to gw and one to gfpc which seems ok to me. A switch/hub would be an easier solution but I think that it must be able to work like this. But the IP's from your nics seem a little bit strange to me, more specially the broadcast:
eth0: inet addr:172.24.15.228 Bcast:192.168.0.255 Mask:255.255.255.240 = to gfpc
eth1: inet addr:172.24.15.229 Bcast:192.168.0.255 Mask:255.255.255.240 = to gw
I would suggest a bcast in the same network? the network is 172.24.15.224, the broadcast will be 172.24.15.238 I think. Because you have the netmask 255.255.255.240

Anyway, the gw is running nat because you seem to only have one official registred ip from your isp. the gw internal ip (to your pc) is something in the same network as your pc (nic to gw), probably: 172.24.15.225 being the first free ip address in your network. (mostly that ip is used for the gw in a network)
the nat on the gw translates all your requests to the internet from your pc.

In the beginning, your gf pc was in the same network as yours. But now you put it in another network: 10.30.0.97/16 (btw: why don't you use any easier networks? :-) And your pc nic to gf pc has ip: 10.30.0.96 so you should put that as the default gw on your gf's pc.
Then you should set up nat on your pc by using some script to translate all requests from your gf's pc. Altough I'm not really sure if this will work, I never had nat after nat but it seems logical to me. I don't know if it can work with your gf's pc in the same network.

rgds,
Lieven
 
Old 04-18-2004, 04:07 AM   #15
ldp
Member
 
Registered: Apr 2004
Location: Belgium Antwerpen
Distribution: slackware - knoppix
Posts: 141

Rep: Reputation: 18
This is the script fw/rtr that I installed on my linux gw. (which has only one box behind it => a winxp)

I have this from: http://www.ibiblio.org/pub/Linux/doc...ade-HOWTO.html => all thanks to the author.

Maybe this howto page can help you further? There's lots of explanations.
rgds.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Computer now has two sound cards... daacosta Linux - Newbie 5 10-01-2005 03:45 AM
2 network cards, single network, load balancing? tormentum Linux - Networking 1 02-13-2005 02:37 PM
two network cards - one for local network, one for http/vsftpd server scottster Linux - Networking 1 01-20-2005 08:52 PM
Ping from a computer with 2 network cards joseph_k Linux - Networking 3 05-27-2004 11:07 AM
2 network cards on the same computer zovres Linux - Networking 4 08-02-2003 10:19 PM

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

All times are GMT -5. The time now is 04:20 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