Difference between revisions of "Network/Bridge"
Jump to navigation
Jump to search
(Created page with " == Debian == <pre> # 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....") |
|||
(5 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | = Host configuration = | ||
== Debian == | == Debian == | ||
+ | |||
+ | apt-get install bridge-utils | ||
<pre> | <pre> | ||
Line 21: | Line 24: | ||
== CentOS == | == CentOS == | ||
+ | |||
+ | '''br0.sh''' | ||
<pre> | <pre> | ||
+ | #!/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 | ||
+ | </pre> | ||
+ | |||
+ | = VM configuration = | ||
+ | |||
+ | == Online.net == | ||
+ | |||
+ | With an eth0 as a local network, and eth1 as the bridged interface: | ||
+ | |||
+ | <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 <failover mac> | ||
+ | address <failover ip> | ||
+ | netmask 255.255.255.255 | ||
+ | broadcast <failover ip> | ||
+ | post-up route add <host gateway> dev eth1 | ||
+ | post-up route add default gw <host gateway> | ||
+ | dns-nameservers <dns ip> | ||
</pre> | </pre> |
Latest revision as of 10:44, 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
With an eth0 as a local network, and eth1 as the bridged interface:
# 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 <failover mac> address <failover ip> netmask 255.255.255.255 broadcast <failover ip> post-up route add <host gateway> dev eth1 post-up route add default gw <host gateway> dns-nameservers <dns ip>