# [SOLVED] Gentoo PC <-> WinXP Laptop

## peka

How to connect a Gentoo Desktop PC with WinXP Laptop using ethernet controllers on both? Internet connection is from Gentoo but this is not an issue.

What the TODO list?

----------

## NeddySeagoon

peka,

The easy way is to connect the two network interfaces with a crossover cable, because network cards do not normally autosense.

Then allocate both ends static IPs in the same subnet, but in a different subnet to the internet conncetion

The 192.168.x.x range is good, or the 10.x.x.x range

The two PCs should now talk together but XP will not be able to get to the internet.

----------

## peka

Thanks

I will try this

----------

## StifflerStealth

Is there any way you can plug both computers into a switch and get internet for both? Or is it that your Gentoo machine is hooked up to the internet and you have a second network card in it?

The way I have mine is that I have a firewire connection for the two. Firewire was designed to be networkable so you do not need a crossover connection or anything, just a regular Firewire cable. You need to make sure that Ethernet over Firewire is in kernel, which is in the Firewire section. The advantage to this is that firewire is capable of 400 mps instead of the 100 mps of regular ethernet. Then you can run IP Chains to allow Windows onto the inernet and an extremely fast connection between the computers. I do this with Windows XP Pro laptop and a Gentoo Desktop. The connection is really stable and fast. You just need to have the IP and netmask set and that's it, on Windows since it's your gateway to the internet, I think you need the gateway and DNS filled in as well. My network is slightly different in the fact that I have a wireless router and my Windows machine goes through wireless to internet and firewire to the Linux machine. I like firewire ethernet, though both machines need firewire ports. My laptop has that really small plug and my desktop has the standard large one, but they make a cable that goes from small to large.  :Wink: 

Cheers.

----------

## peka

Unfortunately, my laptop does not have firewire plug.

My Gentoo machine is hooked up to Internet using USB modem, but it's second priority for my laptop to access the Internet. First I would like these two to talk to each other.

I have two RJ45 plugs available on my Gentoo PC (two onboard ethernet cards) and one RJ45 on WinXP Home laptop.

----------

## NeddySeagoon

peka,

Use an ethernet cross over cable as I suggested.

You can identify a cross over cable by putting the connectors together in you hands and looking at the wires through the clear plastic plug. A crossover cable has both ends wired differently. The orange wire is easy to spot.

A normal, or straight through cable, intended to connect a PC to a switch or hub, has both ends wired the same.

If you don't have a crossover cable, you will need two normal cables and a switch/hub to perform the cross.

Longer term, this may be the best solution, especially if your modem has a RJ45 connector, you can connect everything with a 4 port switch and three normal RJ45 cables.

----------

## peka

I have a cross-over cable.

I have identified my ethernet card as Ethernet controller: Broadcom Corporation NetXtreme BCM5751 Gigabit Ethernet PCI Express (rev 01), but there's only one Droadcon driver in kernel: NetXtremeII.

So I should put the 192.168.0.1 in /etc/hosts and 192.168.0.2 on WinXp machine?

Should I run net.eth0 or something?

----------

## diogot

Have you tried the Home Router Guide?

----------

## peka

WinXP says it.s connected.

I have my Gentoo PC on 

config_eth0=( "192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0" )

and WinXP Laptop on 192.168.0.2

How do I make the to exchange data/browse folders etc.?

----------

## NeddySeagoon

peka,

Now it gets complicated.

You need samba to share things between Windows and Linux the way you want to.

There will ne a samba howto somewhere. emerge samba will be a good start.

----------

## peka

I thought so...  :Sad: 

General opinion is Samba is nothing but trouble when it comes to sharing between Winows and Linux and that's because Bill G. does not always stick to NetBios specification  :Sad: 

What if I forwarded internet to WinXP laptop, set up an FTP server on Gentoo to use LAN only so that WinXP Laptop user could access Gentoo PC shares?

----------

## NeddySeagoon

peka,

That would work for things the FTP server can serve.

----------

## peka

 *diogot wrote:*   

> Have you tried the Home Router Guide?

 

I have managed to get eth0 on.

I've put this line in /etc/conf.d/net

```
config_eth0=( "192.168.0.1 broadcast 192.168.0.255 netmask 255.255.255.0" )
```

I used these iptables rules:

```
#!/bin/bash 

export IPT=/sbin/iptables

export LAN=eth0

export WAN=ppp0

## First we flush our current rules

${IPT} -F

${IPT} -t nat -F

#Setup default policies to handle unmatched traffic

${IPT} -P INPUT     ACCEPT

${IPT} -P OUTPUT  ACCEPT

${IPT} -P FORWARD DROP

## Then we lock our services so they only work from the LAN

${IPT} -I INPUT 1                     -i   ${LAN} -j ACCEPT

${IPT} -I INPUT 1                     -i   lo     -j ACCEPT

${IPT} -A INPUT -p UDP --dport bootps -i ! ${LAN} -j REJECT

${IPT} -A INPUT -p UDP --dport domain -i ! ${LAN} -j REJECT

## Drop TCP / UDP packets to privileged ports

${IPT} -A INPUT -p TCP                 -i ! ${LAN} -d 0/0 --dport 0:1023 -j DROP

${IPT} -A INPUT -p UDP                 -i ! ${LAN} -d 0/0 --dport 0:1023 -j DROP

## Finally we add the rules for NAT

${IPT} -I FORWARD -i ${LAN} -d 192.168.0.0/255.255.0.0 -j DROP

${IPT} -A FORWARD -i ${LAN} -s 192.168.0.0/255.255.0.0 -j ACCEPT

${IPT} -A FORWARD -i ${WAN} -d 192.168.0.0/255.255.0.0 -j ACCEPT

${IPT} -t nat -A POSTROUTING -o ${WAN} -j MASQUERADE

## Tell the kernel that ip forwarding is OK

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

for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done
```

The WinXP Laptop has 192.168.0.2 IP assigned.

They don't ping each other. They ping themselves.

I have tried this simpler set of rules as well:

```

#!/bin/bash

IPT='/sbin/iptables'

# Set interface values

WAN='ppp0'

LAN='eth0'

# enable ip forwarding in the kernel

/bin/echo 1 > /proc/sys/net/ipv4/ip_forward

#for f in /proc/sys/net/ipv4/conf/*/rp_filter ; do echo 1 > $f ; done

# flush rules and delete chains

$IPT -F

#${IPT} -t nat -F

$IPT -X

# enable masquerading to allow LAN internet access

$IPT -t nat -A POSTROUTING -o $WAN -j MASQUERADE

# forward LAN traffic from $INTIF1 to Internet interface $EXTIF

$IPT -A FORWARD -i $LAN -o $WAN -m state --state NEW,ESTABLISHED -j ACCEPT

# allowing acces to Azureus listening port

$IPT -I INPUT 1 -i $WAN -p tcp --tcp-flags SYN,RST,ACK SYN --dport 33333 -m state --state NEW -j ACCEPT

$IPT -I INPUT 1 -i $WAN -p udp --dport 33333 -m state --state NEW -j ACCEPT

# block the rest

$IPT -A INPUT   -i $WAN -m state --state NEW,INVALID -j DROP

$IPT -A FORWARD -i $WAN -m state --state NEW,INVALID -j DROP
```

----------

## peka

.... even if I stop and/or flush all iptables rules I can;t get them to ping.

WinXp Laptop does not ping Gentoo PC (timeouts).

When I ping from gentoo to Laptop I get:

```
# ping 192.168.0.2

PING 192.168.0.2 (192.168.0.2) 56(84) bytes of data.

From 192.168.0.1 icmp_seq=2 Destination Host Unreachable

From 192.168.0.1 icmp_seq=3 Destination Host Unreachable

```

----------

## NeddySeagoon

peka,

At te linux end, run route and post the output.

At the windows end, run cmd.exe and in the black box, run netstat /route and post the output.

Both ends need to be right.

I can't check that Windows command, since I don't have Windows, but whats we need to see is the routing table from both ends.

----------

## peka

Here's from Gentoo

```
# route

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

war-ru10.neo.tp *               255.255.255.255 UH    0      0        0 ppp0

192.168.0.0     *               255.255.255.0   U     0      0        0 eth0

loopback        *               255.0.0.0       U     0      0        0 lo

default         war-ru10.neo.tp 0.0.0.0         UG    0      0        0 ppp0

```

Windows :

```
===========================================================================

Lista interfejs¢w

0x1 ........................... MS TCP Loopback interface

0x10004 ...00 16 cf 06 31 52 ...... Broadcom 802.11g sieciowy adapter - Sterownik miniport Harmonogramu pakietów

0x40002 ...00 16 36 59 53 da ...... Generic Marvell Yukon Chipset based Gigabit Ethernet Controller - Sterownik miniport Harmonogramu pakietów

===========================================================================

===========================================================================

Active Routes:

Destination               Mask       Gateway      Interface      Metryka

          0.0.0.0          0.0.0.0      192.168.0.1     192.168.0.2     20

        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1     1

      192.168.0.0    255.255.255.0      192.168.0.2     192.168.0.2     20

      192.168.0.2  255.255.255.255        127.0.0.1       127.0.0.1     20

    192.168.0.255  255.255.255.255      192.168.0.2     192.168.0.2     20

        224.0.0.0        240.0.0.0      192.168.0.2     192.168.0.2     20

  255.255.255.255  255.255.255.255      192.168.0.2     192.168.0.2     1

  255.255.255.255  255.255.255.255      192.168.0.2           10004     1

Default Gateway:      192.168.0.1.

===========================================================================

Trasy trwaˆe:

  Brak

Tabela tras
```

The win command is netstat -r.

I don't know Windows too well. I use Gentoo only, too. Laptop belongs to my little sister.

Should have mentioned... but it's clear now: I'm total n00b when it comes to networking.

----------

## peka

Whe I remove default gateway on Win I get this:

```
Destination               Mask       Gateway      Interface      Metryka

        127.0.0.0        255.0.0.0        127.0.0.1       127.0.0.1     1

      192.168.0.0    255.255.255.0      192.168.0.2     192.168.0.2     20

      192.168.0.2  255.255.255.255        127.0.0.1       127.0.0.1     20

    192.168.0.255  255.255.255.255      192.168.0.2     192.168.0.2     20

        224.0.0.0        240.0.0.0      192.168.0.2     192.168.0.2     20

  255.255.255.255  255.255.255.255      192.168.0.2     192.168.0.2     1

  255.255.255.255  255.255.255.255      192.168.0.2           10004     1 
```

----------

## peka

 *diogot wrote:*   

> Have you tried the Home Router Guide?

 

So I followed this.

I'm stuck after emerging and configuring netmasq.

Windows say it can't connect to DHCP server to obtain IP

----------

## NeddySeagoon

peka,

The network settings look OK.

Can each PC ping its own 192.168.0.x  IP address ?

Are you sure you have a crossover cable ?

Put the ends together and check both ends are wired differently.

Is there a firewall on the windows system dropping ping requests ?

What about on the gentoo box ?

----------

## peka

 *NeddySeagoon wrote:*   

> Can each PC ping its own 192.168.0.x  IP address ?

 Yes.

 *Quote:*   

> Are you sure you have a crossover cable ?
> 
> Put the ends together and check both ends are wired differently.

 Yes. They are wired differently.

It is a retail  cable (not custom made) labeled "cross-over" on both ends.

 *Quote:*   

> Is there a firewall on the windows system dropping ping requests ?

 Windows Firewall is disabled and I ticked on (enables) all check boxes for ICMP protocol.

Only green LED flashes on NIC.

 *Quote:*   

> What about on the gentoo box ?

 Both (green and orange) LEDs flash on NIC.

I have flushed all iptables rules.

```
# iptables --list

Chain INPUT (policy ACCEPT)

target     prot opt source               destination

Chain FORWARD (policy DROP)

target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)

target     prot opt source               destination
```

----------

## peka

It works!

I have plugged the cable to the other NIC on Gentoo box and it works.

It uses dnsmasq and WinXP get it's own IP.

Port forwarding works and I can access Internet from Laptop.

I just can't understand why it didn't work on the other NIC. Both are enabled in BIOS. Both LEDs have been flashing. net.eth0 has been staring automatically on boot without any set up by me other than in /etc/conf.d/net for eth0. I have used the top NIC plug and then changed to the bottom one.

----------

## peka

NeddySeagoon,

Thank You for all your patience and willingness to help... and for your help of course.

You are The Man   :Very Happy: 

----------

## NeddySeagoon

peka,

The logical names are not bound to the hardware.

The first network port initalised is called eth0. Which one that is can vary from kernel build to kernel build and even from boot to boot.

----------

