bridge network between two linux servers

I need to set up following network architecture :

                       Internet
                        ^   
+-----------------+     |          +------------------+
|  Centos6-1      |     |          |      Centos6-2   |
|      +---- eth0 + ----+          |                  |
| (br0)|          |                |                  |
|      +---- eth1 +----------------+ eth0             |
+-----------------+                +------------------+
                     ( cable connection )

Two public IP's are to be configured like follows :

  • eth0 and eth1 of **Centos6-1 are to be configured as a bridge with IP1
  • Centos6-1 can be accessed with IP1
  • eth0 of Centos6-2 is configured with IP2
  • any request destined to IP2 will flow through Centos6-1

How can i accomplish this feat?

There is a service running in the second server. This service will bind to IP2. what will happen

Edit:

If i do the following in box1:

brctl addbr br0
ifdown eth0
ifdown eth1
ifconfig eth0 0.0.0.0 up
ifconfig eth1 0.0.0.0 up
ifconfig br0 IP1 ****

would it do what i want?


According to this blog, you can setup bridge under CentOS in this way:

You have to add /etc/sysconfig/network-scripts/ifcfg-br0:

DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
DNS1=192.168.0.1
GATEWAY=192.168.0.1
IPADDR=192.168.0.100
NETMASK=255.255.255.0
ONBOOT=yes
SEARCH=”example.com”

And in the ifcfg-eth0:

DEVICE=eth0
HWADDR=00:1e:90:f3:f0:02
ONBOOT=yes
TYPE=Ethernet
IPV6INIT=no
USERCTL=no
BRIDGE=br0

ifcfg-eth1 will be similar.

HWADDR you have to have MAC address of eth0, resp. eth1...

Between two servers you have to have crossover Ethernet cable...


That's not bridging, what you want is simple NAT forwarding.

iptables -t nat -A PREROUTING -i eth0 -d IP2 --to-destination internal_IP2 -j DNAT

And let the boxes communicate using a private internal_IP pair (internal_IP1, internal_IP2)