# Sharing internet among two PCs in a row

## Lomaxx

Hello I am trying to get full internet-connection on a Gentoo-computer, which is connected to a Gentoo-computer, which is connected to a router, which is connected to Internet. Since this might sound confusing here is a more visual explanation:

```

Internet <-> Router <-> Powerline-Adapter <-> Powerline-Adapter in a different room <-> Gentoo1-PC <-> Gentoo2-PC

```

The problem is, that i am lacking a network-switch. If i would have one, then i could simply connect the 'powerline-adapter in a different room' to the switch and to that both Gentoo-PCs. However, since i do not have a switch and rarely need Internet for the 2nd-Gentoo-PC, I would like to setup the Gentoo1-PC, which has 2 NICs, in such a way, that the Gentoo2-PC get's full access to the router and to the Internet over Gentoo1-PC. 

 I already tried to set up a router-configuration on the Gentoo1-PC by using iptables, but due to lack of knowledge and this rather unusual setup, i didn't fully manage to do it (although i have been close). Now i wonder if there is a more simple solution since i do not really need to make Gentoo1-PC another router but more of a switch. Also i would like to keep both Gentoo-PCs in the same subnet. The router-HowTo i found configured an external interface and two internal ones, which used different subnets. I do not need all this.

Is there a way to simply pass the whole network-stream coming from the Powerline-Adapter into Gentoo1-PC via it's first NIC out of it's second NIC to the Gentoo2-PC? The router, which is connected to the Internet could do all the packet-managment if Gentoo2-PC would be fully visible to it.

Thanks for any help.

----------

## disi

ssh tunnel?

use a crossover cable, then configure the two NIC between PC1 and PC2 with the same network and subnet... (hope I am right here  :Smile:  )

emerge and set up tinyproxy and sshd on PC1 (if you want PC2 to connect you start the stuff)

on PC2 you run "ssh -f user@PC1 -L 81:PC1:22 -N" (81 port for localhost and 22 the ssh port for PC1)

now you have on PC2 the proxy server localhost:81 available and can access the internet via PC1...

//edit: actual I was just thinking, if you set up tinyproxy that's enough since there is no Internet netween PC1 and PC2  :Wink: 

----------

## Lomaxx

Thanks for the answer disi.

Will setting up a proxy also work for other connection than http/ssl? I would like to be able to run other internet applications/games on the second computer and thus also need UDP,TCP-connections (or what ever. i still get easily confused about all these protocols   :Very Happy:   ).

So far i will try in how far tinyproxy will help me.

Thanks again for now.

Edit: Currently i am already running http-replicator on the Gentoo1-PC. Does tinyproxy do more or different things or would it be redundant to install both?

----------

## disi

tinyproxy can handle any kind of protocol, since it is not a http proxy.

//edit: most applications support proxies, you can try with those variables to make them use the proxy:

export http_proxy="PC1:8080"

export proxy_address="PC1:8080"

export ftp_proxy="PC1:8080"

//edit: application I know work: browser + flashapps, ftp clients, torrent clients, ssh, putty

----------

## SpiroPoulos89

Lomaxx

I don't know what desktop environment you use, but I use Gnome and NetworkManager.

NetworkManager makes it really easy to do this.

If the two computers are connected through a wire then right click the NetworkManager icon from the computer already connected to the internet and select edit connections.

In the wired section click the add button.

Give a name for your connection.

Go to ipv4 settings.

Next to method click the drop down box an select Shared to other computers.

Hope this helps.

----------

## Hu

Why not just set up the Gentoo system as a router in its own right?  The Gentoo Home Router guide should get you started.  This will be more flexible than installing a proxy, since applications will not need to be configured specially.

----------

## Lomaxx

Thanks to all of you three for the answers.

Actually i really would prefer a solution without a proxy. That's why i already tried setting up a router. But somewhere i got a little lost. I managed to get a connection by following some guide, which even offered a script for setting up iptables. After that i was supposed to save the setting via /etc/init.de/iptables save. But when restarting both computers starting dnsmasq and iptables was not enough to get it working again. I again had to run the script. Then i tried to some adjustments and even after undoing them (deleting iptables-rules and rerun the original script) the whole thing did not work anymore. On top of that i was just unsure if the settings would be right or if i made my system critically vulnerable by it.

 So with a mixture of confusion, disappointment and fear i forgot about the whole thing for back then and was hoping for a far more easy solution since i already have a router in my setup who could do the packet-management.

The proxy solution didn't also work to well. Maybe i was a little impatient though due the preceding struggle. I am running Gnome (a stripped down version), but the NetworkManager was not installed. So i emerged it but after that even the Gentoo1-PC was not able to connect to the Internet. After some quick tries i just uninstalled it again.

 With tinyproxy i managed to get a connection from the 2nd PC, just as i already did with HTTP-replicator. But the test of running FlashGames (on Kongregate) brought failures (some ran, but a certain one didn't, so i was unpleased again (yes, i am a perfectionist *g*)).

I probably will try to set up the Gentoo1-PC as router again in some days although i still think that theoretically i would get along without another subnet, DNS-server, DHCP-server as long as the (stand-alone-)router would be able to connect to the Gentoo2-PC over the Gentoo1-PC and vice versa. But maybe i am wrong and this is practically not possible.

Anyway: Thanks for your help. I will think about it some longer and start another try soon.

----------

## NeddySeagoon

Lomaxx,

Set up PPP between the two PCs. Give them static IPs in the same subnet as the interface that connects to the powerline adaptor.

On the PC with the the two NICs set packet forwarding to on with 

```
echo "1" >/proc/sys/net/ipv4/ip_forward
```

I think you also need 

```
echo "1" >/proc/sys/net/ipv4/conf/eth0/proxy_arp
```

for address resolution protocol.

This is the method I use for in iPaq, to get it on the internet over USB. I can provide a script that you can tailor or the machine with the two NICs to set it up on boot.

----------

