# connect to internet via lan?

## dilandau

i have a little lan:

one windows xp machine that connects directly to the internet

one gentoo linux machine that wants to share that internetconnection over ethernet.

how to set this up on the linux side?

----------

## kiksen

Your windows machine has two nic's I suppose? Good  :Smile: 

Setup your gentoo box to use the windows box as default gateway. (AFAIK windows connection sharing sets the internal nic addess to 192.168.0.1).

HTH

/kiksen

----------

## dilandau

ok, how do i do that? what file in /etc to edit?

----------

## kiksen

/etc/conf.d/net

If it's a standard Windows setup, you can just set up the interface to use dhcp, then you'll get the correct setup from the Windows box automatically.

/kiksen

----------

## dilandau

how do i set up the interface to use dhcp? it seems like it is not enough to have a line like this:

```
iface_eth1="dhcp"
```

there must be something else to do.

btw, how can i apply the changes on the linux side without restarting the whole machine?

----------

## kiksen

If you have used eth1 before, it's actually enough  :Smile:  You'll get both the IP address, nameservers and gateway from the dhcp server (your windows box)

Edit: If you have manually set a gateway (one of the last lines in /etc/conf.d/net then comment it out....)

you can:

#/etc/init.d/net.eth1 restart

to bring up the interface. If you want it to start automatically at boot, then

#rc-update add net.eth1 default

If you haven't used eth1 before, copy /etc/init.d/net.eth0 to /etc/init.d/net.eth1.

/kiksen

----------

## dilandau

what if i have annother windows-box connected to the linux client? i want that second windows box to have access to the internet as well but there is the linux box in between.

(( windows box A has direct internet connection ))--(( linux box ))--(( windows box B ))

the windows box B should have access to the internet and to shares on the windows box A.

thank you.

----------

## daywalkerNT

Hello,  so the setup is something like this:

<DSL/Cable>

     |  

     |

   XP host (a)

     |

   Linux host (a)

     |

   XP host (b)

for this scenario:

XP(a) must have 2 NIC's

Linux(a) must have 2 NIC's

XP(b) 1 NIC

- so the Linux box would have one eth connection to xp(a) and one to xp(b).

- the eth connection to xp(a) would have to be setup with dhcp so it would get

  the ip and etc..

now, say you have the two nics' in the linux box, eth0 (the first) and eth1 (the second)

you can configure both in /etc/conf.d/net

config_eth0=( "dhcp" )

config_eth1=( "dhcp" )

in the previous post, `rc-update add net.eth1 default`    that would add the *second* nic

 to the default runlevel, as nic_counting starts from 0

lets look at the second xp(b) box, for it to connect to the internet, the linux box would have to 

be it's gateway since it wouldn't be able to see the xp(a) , since the linux box has two nics, that 

can be 2 diff. subnets and there's gotta be a way for xp(b) to find a way to xp(a).

so for that, linux box would have to it's default gateway set to the xp(a) ....

for xp(b) to get the ip automatically, the linux box would have to have dhcp running

----------

## dilandau

i understood to set both interfaces on the linux box to wait for dhcp. i didnt understand the rest. how to set up the (b) windowsxp box? why do i have to set up dhcp on linux side, too?

----------

## daywalkerNT

Ok, right , for the connection between the Linux box and XP (b), if say i drew a little diagram a bit more detailed:

  <DSL/Cable>[ethernet_connection]

                              |

                              |

  XP (a)[eth0_connection] 

                              |

           [eth1_connection]

                       |

                       |

  Linux(a)[eth0_connection]

                               |

              [eth1_connection]

                      |

                      |

    XP (b) [eth0_connection ]

so it's eth1 on the linux ---> eth0 on the XP (b)

Does it sound feasible to set a static ip on the Linux box(ie. 192.168.1.100) and a static on the XP(b) (ie. 192.168.1.101)

and so setting the default gateway on your linux box to the XP(a) would seem to work...

----------

## VStrider

 *daywalkerNT wrote:*   

> 
> 
> for this scenario:
> 
> XP(a) must have 2 NIC's
> ...

 

wtf? why?

he's got his xp machine directly to his internet connection so he wants this machine as a gateway.

The gateway needs one NIC to connect to the LAN and one for the internet connection. But some modems can use usb for the internet connection, so you can use one NIC only for your LAN.

Any other machine would need one NIC only.

----------

## daywalkerNT

Ok, right, many modems can use a usb connection, i did forget about that  :Sad: 

question though, if the linux machine is inbetween xp(a) and xp(b) wouldn't it need

two nic's ?   or, let me rephrase that, wouldn't the linux machine need two connections, one 

to xp(a) and one to xp(b) ?

Thanks

----------

## VStrider

 *daywalkerNT wrote:*   

> question though, if the linux machine is inbetween xp(a) and xp(b) wouldn't it need
> 
> two nic's ?   or, let me rephrase that, wouldn't the linux machine need two connections, one 
> 
> to xp(a) and one to xp(b) ?

 

No.  :Smile:  Only the gateway needs 2 NICs. All the other machines would connect to the gateway through a hub or a switch. So they only need 1 NIC.

Ok, I made a diagram with Dia but I cann't find a way to attach it on this post. If you want it, pm me your email and I'll email it to you.

----------

## daywalkerNT

ohh ok, i was going on the original post where they said this:

(( windows box A has direct internet connection ))--(( linux box ))--(( windows box B )) 

if they had a switch then yah it'd be a nic per pc, thats why i was getting confused cause

i was thinking of the above setup  :Smile: 

Thanks

----------

## dilandau

the xp (a) box has two nics, one to connect to the dsl modem and one (eth1) to connect to the lan (linux box). currently only the xp-(b)-box is unconnected and has one nic. i want to connect it to the linux box and therefore the linuxbox has two nics, where eth0 is the one that should connect to the xp-(b) box.

----------

## VStrider

 *dilandau wrote:*   

> the xp (a) box has two nics, one to connect to the dsl modem and one (eth1) to connect to the lan (linux box). currently only the xp-(b)-box is unconnected and has one nic. i want to connect it to the linux box and therefore the linuxbox has two nics, where eth0 is the one that should connect to the xp-(b) box.

 

dilandau, this is wrong. Decide which machine will be your router/gateway, and plug the rest on a hub/switch. If you connect your remaining xp box to the linux box which in turn would be connected to the xp box, you'll have 2 LANs and 2 gateways. You'll be adding needless complexity to your network.

May I ask why you want it this way?

----------

## dilandau

so you recommend to plug the xp(b) box and the linux box to a switch/hub that itself is connected to the xp(a) box?

----------

## daywalkerNT

yeah...That would give you less headaches for now

----------

## dilandau

there are a lot of hubs and switches for sell out there. some for 10 and some 200 and more. which one should i buy? whats the essential difference between hub and switch?

----------

## daywalkerNT

I wouldn't go near a hub, a switch is 1000% better.

K, there is quite a difference between the two, especially performance based

if you have a home network, with 3 hosts connecting to the HUB, when one host 

transmits information to another host, the hub sends that packet/frame out all its 

ports, instead of just sender -> recipient. so it broadcasts the packet out all its ports

and all hosts see the packet, only the recipient processes it as it is destined for it (ie. destination ip)

there are passive and active hubs, a passive hub is kind of like a patch panel, when a host 

transmits something, the packet is just forwarded on to all the ports, the signal is not regenerated.

an active hub, the signal is regenerated.....

soo with a hub, there is only ONE collision domain, meaning that only one host can send at 

a time, Ethernet is a CSMA/CD technology, so in this scenario, when a host transmits a packet 

destined for another host, and at the same time, another host on the network is transmitting something,

there will be a collision.  

When a collision occurs, there's an exponential timeout value that the hosts wait, so the hosts back off.

When the time is up, they retransmit (if there is another collision, the exponential timeout value increases)

A jammer signal is sent, so all hosts on the network know there was a collision.

In the end, a HUB doesn't utilize the entire network bandwidth, and only one host can send at a time.

---------------

Switch

---------------

In as switch, a packet from host (a) sent to host (b) will only be sent to host(b), a switch learns (the MAC) of the 

host connecting on every port, when a host transmits information to another, the packet does not get broadcasted

to every other host/ports on the switch, it goes DIRECTLY to the destination host... no collision in a switch-based 

environment since packets go directly between sender -> receiver.

as well, the full bandwidth is utilized, each nic will use the 10/100 Mbps.

You can get a Linksys switch for about $50->$60

Hope that helps !

----------

## daywalkerNT

" only the recipient processes it as it is destined for it (ie. destination ip)  "

destination MAC

hubs are layer 1, switches layer 2, routers are where ip is at  :Smile: 

----------

## daywalkerNT

Ohh man, *its late*

A HUB passes all traffic to all other ports, it doesnt look for a MAC address or anything, the host that the

packet is destined for will process the packet  :Smile:  .....there 

sorry for the flood of msgs.  :Smile: 

----------

## dilandau

so i am out to buy a switch. thank you. why are there so different prices? i see switches for 22 and 222. whats the ...?

prices examples: http://www.alternate.de/html/shop/productListing4C.html?cat1=018&cat2=000&cat3=000&treeName=HARDWARE&Level1=Netzwerk&Level2=Hubs+%26+Switches&

----------

## VStrider

dilandau, it used to be that switches were very expensive. Nowdays there isn't really a reason to go with a hub. Pick up a cheap 4 port 10/100 switch.

As about which pc should be your router/gateway, I suppose choose the system you're most comfortable with. Your gateway/router needs to be a secure system, cause if it's compromised, your whole network will  follow up. I'd recommend your linux box as a gateway (cause its alot more secure than winxp), but only if you're comfortable with it and know what you're doing.

----------

## dilandau

i would enjoy to make the router linux and i tried some of these preconfigured one-disk / one-cd linux routers but had no success with them. the xp installation just does what i need (and some stuff i dont want). i can try to make the router gentoo though it is only 200mhz and there compiling will last forever...

----------

## VStrider

200Mhz ?? Isn't winxp way too heavy for this machine? Plus a default windows installation is like a swiss cheese. Trying to close all the holes, working on a slow interface of a 200Mhz windows machine would be my worst nightmare.  :Smile: 

I take it you won't be using this pc anyway, it'll be a dedicated router, yes? If so, have you looked into IPCop or Smoothwall(a fork of IPCop) ? There is extensive documentation on both projects and there are help forums as well if you get stuck somewhere. Plus, they are both easily configured through your browser.

Whatever you decide to do, good luck!  :Smile: 

----------

## dilandau

i just tried smoothwall and the first problem i have with it is that it doesnt seem to support my pppoe adsl connection but only a lot of usb-modems. if you know a place where i can get smoothwall support please tell.

----------

## VStrider

Did you try their forums or irc ?

----------

## maxpayne

Ok I do have that kind of config, but all of the boxes connected daisy-chained via cross-over cables. And no, it's not a solution to connect them via a hub/router!

<XPi(nternet) connection sharing (modem-eth0) [OK]>

~~cross-over-cable~~

<GentooLinux, 2 NICs, the one (eth0) to XPi configured via DHCP [OK], the other one (eth1) w/ static IP [OK - though if it could get to work w/ dynamic IP PLUS providing IP address via DHCP that'd be even better (I know it's strange, but I have my reasons - can't be done I don't let count  :Wink: )!], forwarding from eth1 to eth0 [NOT YET WORKING]>

~~cross-over-cable~~

<XPc(lient) connection sharing [OK]>

Just for the setup to make more sense, here's the reason for it:

The GentooLinux box is in the basement, underneath my room, cuz it's too damn loud. It exists because I want to have a GentooLinux box for testing some Linux stuff on it. Two cross-over ethernet cables go from my room down a hole in my floor into the basement - one connecting XPi(which is in my room) with eth0 of the GentooLinux box, the other one connecting the GentooLinux box eth1 with my eth0 on my main PC (XPc) I use for working, SSHing to the GentooLinux box for my Linux needs.

So perhaps someone would be kind enough to give a step-by-step "guide for noobs" how to get the GentooLinux box routing the connection, yet at the same time having access to the Internet too - MANY THANX IN ADVANCE!!!!

----------

## dilandau

i noticed all the config stuff i need for dsl is foudn via the web / html interface. solved.

----------

## maxpayne

Um that message doesn't solve my problem - does it? If so, which software to use?

----------

