You are not logged in.

#1 2009-03-03 21:52:09

Nevturi
Member
From: Netherlands
Registered: 2009-01-13
Posts: 6
Website

Sharing internet from eth0 via eth1 to another computer.

I've got an EEE box serving as a NAS in my room, there's only one LAN cable which I'd like to share to my computer as well. So I figured using an USB LAN adapter (eth1) on it would allow me to share the internal connection (eth0). Only I'm not sure on how to do it, I've only used ICS from Win XP in the past lol.

I've tried creating a bridge with eth0 and eth1, but only the eee box seems to have internet access not the computer connected to eth1. (Btw, do I need a straight through or cross-over between the EEE and my computer? I've tried both..).

I've also searched around a bit more but I couldn't find anything. Iptables seemed a bit too complicated. Also I'm not running a GUI on it so it would be nice if I knew how to configure it with cli only.

Anyway, I was hoping someone could give me a few pointers or just knows a quick & easy guide? Thanks in advance! smile

Last edited by Nevturi (2009-03-03 21:52:39)

Offline

#2 2009-03-03 22:33:59

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,223
Website

Re: Sharing internet from eth0 via eth1 to another computer.

This may help you:
http://www.ducea.com/2006/08/01/how-to- … -in-linux/

Just make sure that each interface has it's own address space such as:
eth0 = 192.168.1.x
eth1 = 192.168.2.x

Offline

#3 2009-03-03 22:52:05

TheBodziO
Member
From: Dukla, Poland
Registered: 2006-07-28
Posts: 230
Website

Re: Sharing internet from eth0 via eth1 to another computer.

First… I've got a suggestion. If your internet connection is configured via DHCP and not restricted to only one host (either by coupling it to specific MAC or by additional payment) then you could buy a simple switch and get rid of idea of dedicated router.

If you want to "share" your internet connection, you can find HOWTO on ArchWiki: http://wiki.archlinux.org/index.php/Sim … AT_gateway. If it won't suit you, general search term is "NAT gateway" (that's what windows ICS really does). Don't let yourself to be intimidated by iptables—setting-up _simple_ NAT _is_ easy.

Now to setting up your "client" machine(s). You have two choices:
• give IP's manually,
• set up DHCP server on your NAT box.
From what you've said I understand that the first scenario is sufficient, so give a computer connected to NAT's eth1 arbitrary IP in the same network that NAT's eth1 interface is bound to.

And the last thing: crossed. If you want to connect two computers via their ethernet interfaces directly (interface-to-interface) then you've got to use crossed cable (this way sending and receiving pairs are exchanged).

Hope this helps! Good luck!


It's not the best thing when they call you a "member" you know… wink

Offline

#4 2009-03-04 18:15:04

mcover
Member
From: Germany
Registered: 2007-01-25
Posts: 134

Re: Sharing internet from eth0 via eth1 to another computer.

What the others said. (IP-Forward + iptables NAT).

But if you are connected to your own private LAN, you could use bridge-utils to to hook two networks together. Then both machines would appear to be connected directly to your LAN, and any other user in the LAN could connect do your NAS and PC directly and vice-versa (if thats what you want) without having to setup port-forwarding and whatnot which is generally the case for when using a NAT.

Here is a quick script that would enable you to create a bridge.

#!/bin/bash
# By marcoe
# Dependencies: bridge-utils

if [ "$(id -u)" != 0 ];then
    echo "This program must be run as root."
    exit 1
fi

if [ $# -eq 0 ];then
    echo `basename $0`" initial-ifdev brdev tobridge-ifdev"
    echo "Specify TEARDOWN=something to tear bridge down."
    exit 1
fi

if [ "$TEARDOWN" != "" ];then
    ifconfig $3 -promisc down
    ifconfig $2 down
    brctl delbr $2
    ifconfig $1 -promisc down

    
    exit 0
fi

echo 1 > /proc/sys/net/ipv4/ip_forward
echo "Assuming interface $1 is down and bridge $2 does not exist yet..."

echo "Setting up bridge ..."
ifconfig $1 0.0.0.0 promisc up
brctl addbr $2
brctl stp $2 off
brctl setfd $2 1
brctl sethello $2 1
brctl addif $2 $1
echo "don't forget to bring interface $2 up before use."

echo "adding $3 to $2"
ifconfig $3 0.0.0.0 promisc up
brctl addif $2 $3

sleep 1s

exit 0

Run as: scriptname your-eth-dev br0 your-other-eth-dev
To tear bridge down: TEARDOWN=x scriptname your-eth-dev br0 your-other-eth-dev

Its based on another script I wrote, so if something is still in there that shouldn't be there, delete it (I think i took out all the unnecessary stuff).

Then when the bridge is up, run: dhcpcd br0 to connect your bridge-machine to the network. And you should also be able to run dhcpcd on the machine that you bridged to your LAN.

m.

Offline

Board footer

Powered by FluxBB