# Connect two hosts manually point to point?[solved]

## turtles

I have a test Gentoo router box called 'router' and a web server called 'server' <snip edited out eratta..>So now I would like to connect the two with a simple point to point connection. However I am unsuccessful with the following:

The router nic lan0 is configured as 192.168.2.1 and the server nic eth0 is 192.168.2.2

On the router I ran 

```
ifconfig lan0 192.168.2.1 netmask 255.255.255.252 up
```

and 

```
route add -net 192.168.2.0 netmask 255.255.255.252 gw 192.168.2.2 dev lan0
```

on the server I ran 

```
ifconfig eth0 192.168.2.2 netmask 255.255.255.252 up
```

```
route add -net 192.168.2.0 netmask 255.255.255.252 gw 192.168.2.1 dev eth0
```

Now on the server I can run 

```
eth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500

        inet 192.168.2.2  netmask 255.255.255.252  broadcast 192.168.2.3

        ether 00:03:47:0d:01:6e  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 0  bytes 0 (0.0 B)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

and the router reports:

```
lan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.2.1  netmask 255.255.255.252  broadcast 192.168.2.255

        inet6 fe80::20e:cff:fecf:6abc  prefixlen 64  scopeid 0x20<link>

        ether 00:0e:0c:cf:6a:bc  txqueuelen 1000  (Ethernet)

        RX packets 0  bytes 0 (0.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 27  bytes 2124 (2.0 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

```

I am unable to ping either end.

I know I am missing something obvious! Like perhaps I need a cross over cable?

Thanks in advance!

----------

## massimo

Do you have Gb ethernet otherwise you'd need crossover cabling. Apart from the you do not need to set up any additional routes.

----------

## chithanh

Unless you disabled it explicitly somewhere, both hosts will automagically get a link-local IPv6 address which should work fine for point-to-point communications.

----------

## pgu

Have you tried to change either  your netmask to 255.255.255.0 or your broadcast address to 192.168.2.3?

----------

## turtles

 *massimo wrote:*   

> Do you have Gb ethernet otherwise you'd need crossover cabling. Apart from the you do not need to set up any additional routes.

 

I think I do 

```
ethtool lan0

        Settings for lan0:

        Supported ports: [ TP ]

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

                                100baseT/Half 100baseT/Full 

                                1000baseT/Full 

        Supported pause frame use: No

        Supports auto-negotiation: Yes

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

                                100baseT/Half 100baseT/Full 

                                1000baseT/Full 

        Advertised pause frame use: No

        Advertised auto-negotiation: Yes

        Speed: 1000Mb/s

        Duplex: Full

        Port: Twisted Pair

        PHYAD: 0

        Transceiver: internal

        Auto-negotiation: on

        MDI-X: off (auto)

        Supports Wake-on: umbg

        Wake-on: g

        Current message level: 0x00000007 (7)

                               drv probe link

        Link detected: yes

```

chithanh I am not familiar with how to use ipV6. Did they both did show an IPv6 link local address in my ifconfig output above?

EDIT no it looks like I did not support ipv6 when I did the kernel for the server.

 *pgu wrote:*   

>  Have you tried to change either your netmask to 255.255.255.0 or your broadcast address to 192.168.2.3?

 

No I dont think I did will as soon as the link to the server is back up it is down currently.

----------

## NeddySeagoon

turtles,

Only the router has 

```
inet6 fe80::20e:cff:fecf:6abc  prefixlen 64  scopeid 0x20<link> 
```

which is an IPv6 link local address.

----------

## turtles

 *NeddySeagoon wrote:*   

> turtles,
> 
> Only the router has 
> 
> ```
> ...

 

Thanks Neddy I think I do remember leaving ipv6 off in the server kernel.

The WAN to the server is currently still down I can get to the router though.

I look forward to understanding the broadcast address better

I tried 192.168.2.3 on the router as that is what the server is set to.

I have installed a ipcalc

and it tells me:

```

ipcalc 192.168.2.2

Address:   192.168.2.2          11000000.10101000.00000010. 00000010

Netmask:   255.255.255.0 = 24   11111111.11111111.11111111. 00000000

Wildcard:  0.0.0.255            00000000.00000000.00000000. 11111111

=>

Network:   192.168.2.0/24       11000000.10101000.00000010. 00000000

HostMin:   192.168.2.1          11000000.10101000.00000010. 00000001

HostMax:   192.168.2.254        11000000.10101000.00000010. 11111110

Broadcast: 192.168.2.255        11000000.10101000.00000010. 11111111

Hosts/Net: 254                   Class C, Private Internet

```

So perhaps the broadcast needs to be 192.168.2.255 ?

also I probably  need to configure iptables on the router better.

----------

## turtles

Thanks everyone for your help

It turns out the interface on the server was eth2

for reference how I determined that was: 

```
cat /sys/class/net/eth2/carrier
```

eth0 on the server turned out to be a fiber link I forgot about

```
cat: /sys/class/net/eth0/carrier: Invalid argument
```

showed it was not connected.

Now to see if I can use iproute2 and iptables to forward a few ports over this link  :Smile: 

On the server I did end up using:

```
inet 192.168.2.2  netmask 255.255.255.0  broadcast 192.168.2.255
```

----------

