# Peer to peer file sharing on crossover ethernet (SOLVED)

## marrowhk

I'm a complete novice with networks. I've managed to share my internet connection between two gentoo workstations using a D-Link DRI-100. Okay, so i have the intenet on both pcs - no problem. Each PC has two Ethernet cards, so i'd like to use a crossover ethernet to share files between these two gentoo workstations, is this possible?

I have a crossover cable, and each PC has a spare giga Ethernet connection (net.eth1 on each PC). Can i somehow use this configuration to simply share files both ways between the PCS   :Question:   Would it be safe given that the internet connection is on net.eth0 and the crossover is on net.eth1   :Question:  

I have googled this and looked at a number of complex solutions, but i don't seem to be getting anywhere   :Embarassed:   I just need the simplest solution possible if anyone could suggest a good howto or provide me with a kick-start.

Here's my setup so far:

PC-1 : net.eth0=dhcp from D-Link router, net.eth1=manual set to 10.0.0.1 in /etc/conf.d/net ( config_eth1="10.0.0.1/24" )

PC-2 : net.eth0=dhcp from D-Link router, net.eth1=manual set to 10.0.0.2  in /etc/conf.d/net ( config_eth1="10.0.0.2/24" )

Everything seems to be up, but as you can see i have no idea what i'm doing   :Embarassed:  (using /etc/conf.d/net.example as a guide)

----------

## jstead1

With the computers hooked up to the same router, you should be able to share files already.

Just hooking up a cable between the two computers won't make it any easier to share files.  You will still need client and server software.

You will need to do a little networking, but it really isn't that bad.

If both machines run linux (or unix or bsd), you should use NFS.  I am sure thee

If you google NFS gentoo wiki, or NFS share directories, you should find lots of links and wiki's on how to do it.

If one is a windows machine, you could still use NFS, but would need a windows NFS client / server.  I am sure there are some out there, but I never looked into one.

Usually with a mixed windows / linux environment, people use samba.  There are several guides on the gentoo documentation page.

----------

## marrowhk

Thanks jstead1. In my post i clearly mentioned that both machines are running gentoo. 

Yes, NFS client-server seems the best solution. Here is where I get confused though:

|| D-LINK DIR-100 broadband router || 4 ports. 2 ports taken up with connections from each machine: net.eth0 (internet access)

Are you saying i could plug in the second nics on each machine to this same router and be able to share safely? If so, a pointer would be nice. I know how to use google, unfortunately most of the howtos and such stop short of detailing how to do this stuff.

Just to be clear:

Is it not possible to do peer to peer in Linux with a crossover Ethernet cable like you can with windozs?

----------

## Black

I haven't done this, but my understanding is that yes, it is possible, PC to PC on the eth1, using a crossover cable - no router or switch needed.

From what I can get from your post, you're already set up hardware-wise. Try pinging the other computer's IP from one of them. Assuming you don't have an iptables rule preventing it, it should work.

Now for the software part, you have to configure your server software (NFS?) to share only through the 10.0.0.x IP, not the other one (linked to the D-Link, presumably 192.168.1.x). How to do this depends on the software in question.

Sorry, I don't have any link.

----------

## marrowhk

Yes Black, i'm kinda sorted out hardware wise. I'm just muddling through. I'll use NFS on just the gigalinks 10.0.0.1/2 connections. I'll write this up as a howto assoon as i'm done just in case anyone else wants a simple solution to share two pcs via a crossover. I'm astonished that no HOWTO exists on this in gentoo. Oh well, here goes. Will report back if i'm able to finish.   :Confused: 

----------

## DarKRaveR

I think it depends on your explicit usage needs.

NFS is okay, if you want to access the files directly, as long as one machine is mostly the server and the other one mostly the client and if you need direct file-io on cosole level, NFS (and it's bad performance) is your choice.

As an alternative you could still use ftp/http or the liek and gvfs if this is sufficient in your scenario ...

P.S.: I am sure there has to be a NFS Howto   :Cool:  .

----------

## marrowhk

That's interesting DarKRaveR. 

Do you have any pointers on doing this with gvfs - this would be much better i think in terms of ease of use in gnome with nautilus.

All i need to do is share files occasionally. My wife and i both have gentoo with similar setups. I have a scanner and printer and keep certain records on my PC in encrypted format. I just want my wife to be able to send and receive files to my machine - nothing heavy. At the moment we use a pen-usb, but as our study rooms are separate this is getting pretty tiring.

HARDWARE SO FAR: (I'm still a little lost!)

PC1: net.eth1 (10.0.0.1)

/etc/conf.d/net

```
config_eth1="10.0.0.1/24"
```

/etc/hosts

```
10.0.0.1        pc1.home pc1

10.0.0.2        pc2.home pc2
```

PC2: net.eth1 (10.0.0.2)

/etc/conf.d/net

```
config_eth1="10.0.0.2/24"
```

/etc/hosts

```
10.0.0.2        pc2.home pc2

10.0.0.1        pc1.home pc1
```

ethtool eth1 on both machines shows a connection present using autoneg (identical lan cards used), but i still can't ping from one machine across to the other. Do i need to do routing? Perhaps i need a gateway? Any help appreciated.

Output of route and route -n on pc1 (my D-Link router for internet sharing is on 192.168.0.1 - no probs here)

```
10.0.0.0        *               255.255.255.0   U     0      0        0 eth1

192.168.0.0     *               255.255.255.0   U     3      0        0 eth0

link-local      *               255.255.0.0     U     3      0        0 eth0

loopback        gccr.home       255.0.0.0       UG    0      0        0 lo

default         192.168.0.1     0.0.0.0         UG    3      0        0 eth0
```

```
10.0.0.0        0.0.0.0         255.255.255.0   U     0      0        0 eth1

192.168.0.0     0.0.0.0         255.255.255.0   U     3      0        0 eth0

169.254.0.0     0.0.0.0         255.255.0.0     U     3      0        0 eth0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo

0.0.0.0         192.168.0.1     0.0.0.0         UG    3      0        0 eth0
```

I guess i need a better understanding of /etc/conf.d/net settings. I've read the help but i'm still a bit lost on the hardware even before i get to the software side!

----------

## DarKRaveR

Okay, what you would do, setup anf ftp server.

Then all you would have to do is access the server through gnome (I am currently not on my Linux Box), but if your Menu is an item like go to location or network servers, something like that.

You can then select the protocol etc. - After Connection usually a shortcut is created ...

http://library.gnome.org/users/user-guide/stable/gosnautilus-515.html.en

This shows what I am talking about...

It does support nfs if you want to stay with nfs, but should work with most protocols, all gnome-vfs (or gvfs for that matter) support.

sftp (via ssh) works, as well as scp ....

Since gnome-vfs kinda makes remote resources locally available, it works with all apps, no matter if it's gedit, abiword or whatever.

What you would have to try though are the writing capabilities, for other protocols than nfs.

Anf if you have a bulk of data you are best off with ftp-server + plain ftp client of course ...

I am merely showing different approaches. What would be really cool: if gvfs would have a sync folder ability, such that two desktops define a common resource and the folder is kept in sync between both at all times ...

Oh, and of course there's the folder sharing thing in gnome, but I did not look further into it (I don't know how it technically works).

EDIT:

It seems the shared folders use smb (or cifs) ... this makes it similiar to the nfs version, tough it is integrated directly into the gui on both ends ...

And note:

GVFS itself, a new package containing backends for various file system types and protocols such as SFTP, FTP, DAV, SMB and ObexFTP.

(gvfs superseeds gnome-vfs and will replace it in the future) - I couldn'T find a list though with all supported backends for both of them yet)Last edited by DarKRaveR on Sun Apr 06, 2008 3:30 am; edited 1 time in total

----------

## marrowhk

DarKRaveR, yes that would be cool! Could you check back at my previous post and check my /etc/conf.d/net settings (i edited the post). Do you know if i'm doing the hardware right? Still can't ping from one machine into the other!

----------

## DarKRaveR

As far as I can see the routing tables look okay, same for net config and hosts files.

Did you start net.eth1 on both machines (stupid question I know) ....

Does ifconfig eth1 report the expected results?

Then, do you have iptables rules blocking icmp requests by any chance?

----------

## marrowhk

 *DarKRaveR wrote:*   

> As far as I can see the routing tables look okay, same for net config and hosts files.
> 
> Did you start net.eth1 on both machines (stupid question I know) ....
> 
> Does ifconfig eth1 report the expected results?
> ...

 

net.eth1 up on both machines as reported by ifconfig

shorewall off on both machines (but in interfaces i only have the firewall applying to my net.eth0 intenet connection)

Both machines report as below

#ifconfig eth1

```
eth1      Link encap:Ethernet  HWaddr 00:1C:F0:D1:A2:94  

          inet addr:10.0.0.1  Bcast:10.0.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:1 errors:0 dropped:0 overruns:0 frame:0

          TX packets:27 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:64 (64.0 b)  TX bytes:2488 (2.4 Kb)

          Interrupt:16 
```

#ethtool eth1

```
Settings for eth1:

   Supported ports: [ TP ]

   Supported link modes:   10baseT/Half 10baseT/Full 

                           100baseT/Half 100baseT/Full 

                           1000baseT/Half 1000baseT/Full 

   Supports auto-negotiation: Yes

   Advertised link modes:  10baseT/Half 10baseT/Full 

                           100baseT/Half 100baseT/Full 

                           1000baseT/Half 1000baseT/Full 

   Advertised auto-negotiation: Yes

   Speed: 1000Mb/s

   Duplex: Full

   Port: Twisted Pair

   PHYAD: 0

   Transceiver: internal

   Auto-negotiation: on

   Supports Wake-on: pg

   Wake-on: g

   Current message level: 0x00000037 (55)

   Link detected: yes
```

On the software side I've located a good NFS howto so once i can communicate between the machines i think i'll be okay. Now, though i think something else is needed in /etc/conf.d/net to enable me to ping from one machine to the next.

----------

## DarKRaveR

Humm, sunrise, I should go to bed soon.

Okay, what you could try, emerge tcpdump on both machines.

Open a terminal on each machine and run tcpdump -ieth1

Now try to ping.

Now let's see if the ping leaves through the right interface on machine 1, see if it reaches 2 etc.

Depending on what happens you know if you have a transmission problem, or if the request is refused etc.

Oh, and please do a 'cat /proc/sys/net/ipv4/icmp_echo_ignore_all' ... just in case.

----------

## marrowhk

 *DarKRaveR wrote:*   

> Humm, sunrise, I should go to bed soon.
> 
> Okay, what you could try, emerge tcpdump on both machines.
> 
> Open a terminal on each machine and run tcpdump -ieth1
> ...

 

Many thanks DarKRaveR. Will do this and report back. Get some shuteye in the meantime.

----------

## jstead1

 *marrowhk wrote:*   

> Thanks jstead1. In my post i clearly mentioned that both machines are running gentoo. 
> 
> Yes, NFS client-server seems the best solution. Here is where I get confused though:
> 
> || D-LINK DIR-100 broadband router || 4 ports. 2 ports taken up with connections from each machine: net.eth0 (internet access)
> ...

 

Yes, you can connect the second NICs on the same machines to the router and run NFS across that line and configure the router so that there is no internet access for those IP addresses (you would need to assign the addresses based on MAC address so that all the NICs got the same address each time.

You really don't need the second set of NICs, though it does add a layer of security.  That way, even if you set up the NFS in an insecure manner, it won't really matter since the IP addresses for the second NICs are blocked from the internet altogether.

It is possible to share files in the same manner that windows does.  I am not real familiar with how windows manages that crossover direct connection, but I would guess it is running some sort of client and server operation.  Peer to peer is just where the two peers run the client and server functions.

----------

## DarKRaveR

I assume aside from the security part, the good thing is having gigabit (most home routers embedded NICs only have fast ether).

Especially if he stays with nfs, the high speed and lower latency can be of some advantage. Another positive effect, if he hooks up all 4 cards to the router, the broadcast and collision domains won't get separated.

----------

## marrowhk

Thanks jstead1. If plugging the second nics into the router can be done (abandon the crossover wire) as you said, it would be a very good way to continue. Then i could use NFS to share stuff. My problem would be how to set up /etc/conf.d/net to accomplish this. I've read gentoo's home router howto and the /etc/conf.d/net.example, but i'm not shure i know how to set the hardware up!

Here's what i'll try, first

PC1 (localhost=gccr.home)

```

# ETHERNET CONFIG

config_eth0="192.168.0.100/24"

config_eth1="192.168.0.102/24""

# ROUTING

routes_eth0="default via 192.168.0.1"

# SYSTEM

dns_domain_eth0="gccr.home"

dns_servers_eth0="208.67.222.222 208.67.220.220"

dns_search_eth0="opendns.com"
```

PC2 (localhost=gcnl.home)

```

# ETHERNET CONFIG

config_eth0="192.168.0.101/24"

config_eth1="192.168.0.103/24"

# ROUTING

routes_eth0="default via 192.168.0.1"

# SYSTEM

dns_domain_eth0="gcnl.home"

dns_servers_eth0="208.67.222.222 208.67.220.220"

dns_search_eth0="opendns.com"
```

Now, I go to my router and disallow internet access on 192.168.0.2 & 192.168.0.3. Is this the basic idea?

----------

## DarKRaveR

Yes and no, if you do this and put the second interface into the same subnet, you won't win a bit, because both can reach the same subnet, thus the first interface matching the desired destination would be used. Basicly you could forget about the secondary interface on both.

You could of course set up an explicit neighbour route for the the neighbouring PC - IMHO crosslinking is still the best IDEA ....

----------

## marrowhk

 *DarKRaveR wrote:*   

> Yes and no, if you do this and put the second interface into the same subnet, you won't win a bit, because both can reach the same subnet, thus the first interface matching the desired destination would be used. Basicly you could forget about the secondary interface on both.
> 
> You could of course set up an explicit neighbour route for the the neighbouring PC - IMHO crosslinking is still the best IDEA ....

 

Okay, going back to the crossover setup. Just completed your suggestions so here is the output:

/etc/hosts

```
127.0.0.1       gccr.home       gccr localhost

10.0.0.1        gccr-share.home gccr-share

10.0.0.2        gcnl-share.home gcnl-share
```

/etc/conf.d/net

```

# ETHERNET CONFIG

config_eth0="dhcp"

config_eth1="10.0.0.1/24"

# ROUTING

# SYSTEM

dns_domain_eth0="gccr.home"

dns_servers_eth0="208.67.222.222 208.67.220.220"

dns_search_eth0="opendns.com"

dhcp_eth0="nodns nontp nonis"
```

Using tcpdump on eth1 on both pcs gives the following results when a ping is attempted

gccr clarke # cat /proc/sys/net/ipv4/icmp_echo_ignore_all

```
0
```

gccr clarke # tcpdump -i eth1

```
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes

14:19:41.881517 arp who-has gcnl-share.home tell gccr-share.home

14:19:41.881595 arp reply gcnl-share.home is-at 00:1c:f0:d1:a3:a7 (oui Unknown)

14:19:41.881601 IP gccr-share.home > gcnl-share.home: ICMP echo request, id 4621, seq 1, length 64

14:19:42.880540 IP gccr-share.home > gcnl-share.home: ICMP echo request, id 4621, seq 2, length 64

14:19:43.880535 IP gccr-share.home > gcnl-share.home: ICMP echo request, id 4621, seq 3, length 64

14:19:44.880533 IP gccr-share.home > gcnl-share.home: ICMP echo request, id 4621, seq 4, length 64

14:19:45.880528 IP gccr-share.home > gcnl-share.home: ICMP echo request, id 4621, seq 5, length 64

14:19:46.880528 IP gccr-share.home > gcnl-share.home: ICMP echo request, id 4621, seq 6, length 64

14:19:47.880543 IP gccr-share.home > gcnl-share.home: ICMP echo request, id 4621, seq 7, length 64
```

gccr clarke # ping gcnl-share

```
PING gcnl-share.home (10.0.0.2) 56(84) bytes of data.

--- gcnl-share.home ping statistics ---

7 packets transmitted, 0 received, 100% packet loss, time 5999ms
```

But, as you can see the ping command shows no completion!   :Confused: 

----------

## DarKRaveR

 *Quote:*   

> 
> 
> 14:19:41.881517 arp who-has gcnl-share.home tell gccr-share.home
> 
> 14:19:41.881595 arp reply gcnl-share.home is-at 00:1c:f0:d1:a3:a7 (oui Unknown)
> ...

 

Looks like the arp request is answered, so the communication is working.

You checked icmp_echo_ignore_all on gccr ... but since you ping from gcrr to gcnl, gncl must not ignore ecmp echo reqwuests, so this is where you should check.

Secondly, if you, at the same time (as I advised) run a tcpdump on gcnl (the one supposed to answer the ping) you could see if the icmp packages reach at the interface level ....

on gccr: ping 10.0.0.2 (let's keep it simple first, numeric ip) in a different terminal run: tcpdump -n -ieth1 (as you did) ...

ping -> IP 10.0.0.1 > 10.0.02: ICMP echo request, id 4621, seq 1, length 64

on gcnl: tcpdump -n -ieth1 should show: ping -> IP 10.0.0.1 > 10.0.02: ICMP echo request, id 4621, seq 1, length 64

This tells us: ping -> packet left gccr and entered the network card on gcnl.

on gcnl tcdump should now say something similiar:

ping -> IP 10.0.0.1 > 10.0.02: ICMP echo rePLY, id 4621, seq 1, length 64

Meaning gcnl did sent the answer to the wire .... is this does not happen, then gcnl most certainly ignores the icmp packets

Have a look at the icmp_echo_ignor_all on gcnl...

The whole thing can be done symmetric, by exchanging both ends roles ....

Till now I can tell you gccr put the ping on the wire, and before that it sends an arp and gets a proper answer, so the hardware and ip config + routes are all in place ... as expected ...

----------

## marrowhk

DarKRaveR, thanks for the info. I can see how this works now. I followed the instructions and can now clearly see the ping going from pc2 to pc1. The ping is now successful.

EDITED:

ping 10.0.0.1 from gcnl = OKAY

ping 10.0.0.2 from gccr = OKAY

Now that I have both machines able to see each other i have to use NFS to share (is that right?). Because if there's an easier way i'd much rather take it. Like you say, gvfs rather than NFS?

----------

## DarKRaveR

Well, I don't know if you have gnome2.22 already (which is in unstable).

There you can share folders (via smb) and the other computer can browser via network to those (which is internally handles by the gvfs smb backend) ... I think they decided to use smb for shared folders, because windows machines could access them too. I didn't really try this yet, since the folder sharing is rather new (and I didn't need it so far).

gvfs+sftp might be a choice, since all it needs is running sshd on both machines and you can acces whatever you can when you ssh to the box (of course you would bind sshd only to the 10.x.x.x addresses, which you should do to, if you would be using nfs.

I really cannot tell you what to go for, since it's personal taste, but setting up nfs might not be straight forward ... if you have huge chunks of data I'd use plain ftp and an ftp daemon (again not easy to set up) ... I use ftp, when several GB of data are involved, database images, stuff like that, because it is pretty much zero overhead.

Maybe for starters you can try the following:

openssh is installed on both machines I assume, let's say we stick with gcnl (10.0.0.2) ... on gcnl (as root) edit /etc/ssh/sshd_config ... At the top there is a Listen statement like #Listen 0.0.0.0 .... Uncomment it and put in 10.0.0.2.

After that do: /etc/init.d/sshd start

now at gccr (10.0.0.1) try to ssh to user@10.0.0.2 (you cann fiddle around with the proper name resolving later on) where user is an existing username (not root for now, since root logins might be disabled for security reasons).

If that works, you can point to locations, connecto to server, select sftp, use 10.0.0.2 as ip, you will be asked for the login credentials (or there might be boxes, I can't remeber) ... if the connection is established, you should have a volume in your nautilus behaving similiar to a removable drive ... try if you can edit a file etc.

You actually don't need sftp nor ssh nor encryption on this internal link, but it's certainly the easiest daemon to set up, in case the folder sharing does not work.

Even when sftp works, you can still try the shared folders, see what works better, or, when you got time, try to use nfs, ftp .. whatever you like best in handling. (It's kinda like testdriving a car   :Cool:   ).

----------

## marrowhk

Following along, thanks for ur patience! My gnome is at 2.22.0.

Okay, never ssh'd before. I have sshd running on gcnl and 10.0.0.2 setup as suggested in /etc/sshd/...

Sorry, but how to I ssh to gcnl from gccr?

```
gccr clarke # ssh user@10.0.0.2

ssh: connect to host 10.0.0.2 port 22: Connection refused
```

----------

## DarKRaveR

Okay, you need to be a little patient now, I need a nap afterall.

gncl is 10.0.0.2 ? and you setup ssh to listen on gncl on 10.0.0.2 ?

after starting sshd, you can use netstat (nestat -a for the beginning) and see if ssh is really properly buond to the right IP (which should be the same that ifconfig eth1 reports - naturally) ....

If taht looks okay you can first try (on the same maschine, gncl) to ssh to whateveruser@10.0.0.2) to see if it works locally with the ip you want to be using in the future ... If all that works, but it doesn't work remotely, there'S something interfering (netfilter, maybe, hard to diagnose remotely) ....

Anyway, I'll leave you alone with this for a while, and always look closely, 10.0.0.1 and 10.0.0.2 are very similiar, and always remember roles are exchangeable ... 

A: ip .1 setup ssh for .1, try ssh to .1 (locally) first then from B: ip .2, try ssh to .1

B: ip .2 setup ssh for .2, try ssh to .2 (locally) first then from A: ip .1, try ssh to .2

Let's hope it'll work out ...

----------

## marrowhk

Okay, all done. I now have a crossover ethernet between two gentoo pcs which enables me to share files over NFS. Will write this up as a quick howto next week for newbies like me! Thanks again for help.

----------

