# Bridge:Cannot connect across subnets.

## dE_logics

I got 2 networks, X on subnet 192.168.1.0 and Y on 192.168.1.0

The bridge has IP 192.168.1.9, and output of route -n says 192.168.1.0 has no gateway and goes through the bridge. I add the same for 192.168.2.0.

The result -- I cannot access the network Y from the box which runs as the bridge.

Nodes on X and Y can communicate to each other but only if they lie on the same subnet, i.e network Y should lie on the subnet 192.168.1.0 in order to communicate to network X. If I set the IP of one node on Y to 192.168.2.0 and add routes with no gateway, then Y cannot communicate to X and opposite.

----------

## NeddySeagoon

dE_logics,

You need a static route in both directions or change the netmask on both subnets to be /22, rather than /24 but then 192.168.1.x and 192.168.2.x are in the same subnet as are 192.168.0.x and 192.168.3.x

Both ways work.

Oh there is a third way - run NAT between the two subnets but you probably don't want that.

----------

## dE_logics

Hi Neddy!

I added route on both ends (nodes on network Y and the box which's the bridge) as follows -- 

Gentoo box which works as a bridge -- 

```
0.0.0.0         192.168.1.1     0.0.0.0         UG    217    0        0 eth1_veth

127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo

192.168.1.0     0.0.0.0         255.255.255.0   U     217    0        0 eth1_veth

192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1_veth
```

Routes on network Y -- 

```
192.168.1.0     0.0.0.0         255.255.255.0   U     0    0        0 eth0

192.168.2.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0
```

However it still doesn't work.

Changing network bits to 22 is not the point here -- I'm trying to bridge 2 separate networks.

----------

## Carnildo

 *dE_logics wrote:*   

> Changing network bits to 22 is not the point here -- I'm trying to bridge 2 separate networks.

 

The first thing to do is get your terminology correct.  A "bridge" connects two pieces of the same subnet.  A "router" connects two subnets.

The second thing to do is to activate routing on your system:

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

To make that change survive across reboots, add the line

```
net.ipv4.ip_forward = 1
```

to your /etc/sysctl.conf file.

----------

## dE_logics

 *Carnildo wrote:*   

>  *dE_logics wrote:*   Changing network bits to 22 is not the point here -- I'm trying to bridge 2 separate networks. 
> 
> The first thing to do is get your terminology correct.  A "bridge" connects two pieces of the same subnet.  A "router" connects two subnets.

 

No, a router's task is to route packets across multiple (or single) route(s) which includes connecting networks, like subnets. However connecting subnets is the primary task of a bridge. Besides there's no reason why there should not be internetwork communication, or why subnets should not be able to communicate to each other.

The problem on my end, as Neddy pointed out, was that the node (on X) to which I was sending packets to did not have routes added for subnet 192.168.2.0/24, so it could not respond to network Y.

----------

