Difference between revisions of "Network/Bridge"

From LunaSys
Jump to navigation Jump to search
Line 1: Line 1:
 +
= Host configuration =
  
 
== Debian ==
 
== Debian ==
Line 43: Line 44:
 
# build br0
 
# build br0
 
grep -v -E '(HWADDR|UUID)' $REFCFGPATH/ifcfg-eth0.ref | sed 's/eth0/br0/g' | sed 's/BOOTPROTO=["]*none["]*/BOOTPROTO=static/g' | sed 's/TYPE=["]*Ethernet["]*/TYPE="Bridge"/g' | sed 's/NM_CONTROLLED=["a-z]*/NM_CONTROLLED="no"/g' > $CFGPATH/ifcfg-br0
 
grep -v -E '(HWADDR|UUID)' $REFCFGPATH/ifcfg-eth0.ref | sed 's/eth0/br0/g' | sed 's/BOOTPROTO=["]*none["]*/BOOTPROTO=static/g' | sed 's/TYPE=["]*Ethernet["]*/TYPE="Bridge"/g' | sed 's/NM_CONTROLLED=["a-z]*/NM_CONTROLLED="no"/g' > $CFGPATH/ifcfg-br0
 +
</pre>
 +
 +
= VM configuration =
 +
 +
== Online.net ==
 +
 +
<pre>
 +
# The loopback network interface
 +
auto lo
 +
iface lo inet loopback
 +
 +
# The primary network interface
 +
auto eth0
 +
iface eth0 inet dhcp
 +
 +
auto eth1
 +
iface eth1 inet static
 +
  hwaddress ether 52:54:00:00:0e:af
 +
  address 212.83.131.101
 +
  netmask 255.255.255.255
 +
  broadcast 212.83.131.101
 +
  post-up route add 88.190.58.1 dev eth1
 +
  post-up route add default gw 88.190.58.1
 +
  dns-nameservers &lt;dns ip&gt;
 
</pre>
 
</pre>

Revision as of 10:43, 20 February 2014

Host configuration

Debian

apt-get install bridge-utils
# cat /etc/network/interfaces 

auto lo br0

iface lo inet loopback

iface eth0 inet manual

iface br0 inet static
	bridge_ports eth0	
	address 142.4.209.206
	netmask 255.255.255.0
	network 142.4.209.0
	broadcast 142.4.209.255
	gateway 142.4.209.254

CentOS

br0.sh

#!/bin/bash

CFGPATH=/etc/sysconfig/network-scripts
REFCFGPATH=/root

# keep the original
if [ ! -f "$REFCFGPATH/ifcfg-eth0.ref" ]; then
  cp $CFGPATH/ifcfg-eth0 $REFCFGPATH/ifcfg-eth0.ref
fi

# build new eth0
grep -E '(DEVICE|HWADDR|ONBOOT)' $REFCFGPATH/ifcfg-eth0.ref > $CFGPATH/ifcfg-eth0
echo "BRIDGE=br0" >> $CFGPATH/ifcfg-eth0

# build br0
grep -v -E '(HWADDR|UUID)' $REFCFGPATH/ifcfg-eth0.ref | sed 's/eth0/br0/g' | sed 's/BOOTPROTO=["]*none["]*/BOOTPROTO=static/g' | sed 's/TYPE=["]*Ethernet["]*/TYPE="Bridge"/g' | sed 's/NM_CONTROLLED=["a-z]*/NM_CONTROLLED="no"/g' > $CFGPATH/ifcfg-br0

VM configuration

Online.net

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet static
  hwaddress ether 52:54:00:00:0e:af
  address 212.83.131.101
  netmask 255.255.255.255
  broadcast 212.83.131.101
  post-up route add 88.190.58.1 dev eth1
  post-up route add default gw 88.190.58.1
  dns-nameservers <dns ip>