Bonding multiple IP interface.

Help
2006-09-27
2013-06-06
  • Brian Johnson
    Brian Johnson
    2006-09-27

    I currently use eth0:0, eth0:1, eth0:2 and eth0:3 interfaces on a single machine. this is my relevant ifconfig output:

    eth0      Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.99  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:537111112 errors:0 dropped:0 overruns:0 frame:0
              TX packets:468259173 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:3219305926 (2.9 GiB)  TX bytes:3460208113 (3.2 GiB)
              Interrupt:169

    eth0:0    Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.60  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    eth0:1    Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.61  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    eth0:2    Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.62  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    eth0:3    Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.63  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    I want to move to a situation similar to this:

    bond0     Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.99  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:537111112 errors:0 dropped:0 overruns:0 frame:0
              TX packets:468259173 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:3219305926 (2.9 GiB)  TX bytes:3460208113 (3.2 GiB)
              Interrupt:169

    bond0:0   Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.60  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    bond0:1   Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.61  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    bond0:2   Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.62  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    bond0:3   Link encap:Ethernet  HWaddr 00:11:25:40:28:58
              inet addr:10.10.0.63  Bcast:10.10.0.255  Mask:255.255.255.0
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              Interrupt:169

    I can not seem to find an example or any specific document on accomplishing this. I currently use ifcfg-eth0:x scripts to bring up my "sub-inteerfaces".

    Any help would be appreciated.

     
    • Sam Martin
      Sam Martin
      2007-03-02

      Did you ever get any recommendations for this type of configuration?  I'm looking to do this for multiple Apache instances which need IP aliases for the same interface.

      Cheers,

      Sam

       
    • Ferrell
      Ferrell
      2008-02-25

      I too am looking to use multiple IPs with 2 NICs that are bounded together.

      Can anyone offer assistance please.

       
      • Daniel Johnson
        Daniel Johnson
        2008-02-25

        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1

        To answer the three of you as best I can, yes it appears to work.
        I run Slackware so I don't tend to use fancy scripts or
        configuration systems to manage my NICs.  Assuming you have
        "bond0" up and running, you can run
          ifconfig bond0:1 192.168.1.1 netmask 255.255.255.0
          ifconfig bond0:2 192.168.1.2 netmask 255.255.255.0
          # etc
          ifconfig bond0:1 up
          ifconfig bond0:2 up
          # etc

        You still have to deal with any routing issues you may cause, but
        that's just part of having multiple interfaces (physical or
        virtual, bonded or single) in the same subnet.

        Tomorrow I'm moving a server with a single physical NIC and one
        alias to an active/active failover pair with one alias.  I'll
        post my results.

        Daniel Johnson
        Progman2000@usa.net
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.7 (GNU/Linux)

        iD8DBQFHwxDs6vGcUBY+ge8RAt4NAKDaeico3y6ZjvmPOLqxVu15kzxVRgCg1a/H
        3Z8n64srjthnSGIo56Fzg8Y=
        =E/Se
        -----END PGP SIGNATURE-----

         
        • Jay Vosburgh
          Jay Vosburgh
          2008-02-26

          It's also possible to just add multiple IP addresses to the single bond0 interface, e.g.,

          ip addr add 10.1.1.1/16 dev bond0
          ip addr add 10.2.1.1/16 dev bond0

          and so on.  This is pretty much equivalent to

          ifconfig bond0:1 10.1.1.1 netmask 255.255.0.0
          ifconfig bond0:2 10.2.1.1 netmask 255.255.0.0

          Various distros have support for doing this automatically in the network configuration scripts, e.g., SuSE distros (of sufficiently recent vintage), or, really, any distro using sysconfig for configuration, can specify multiple IPADDRS, e.g., in ifcfg-bond0

          NAME='bond0'
          IPADDR='10.0.1.1/16'
          IPADDR2='10.2.1.1/16'
          # do IPv6 if you want...
          IPADDR3='6000::9/64'

          then the usual bonding stuff

          BONDING_MASTER='yes'
          BONDING_MODULE_OPTS='mode=active-backup miimon=50'
          BONDING_SLAVE_0='eth0'
          BONDING_SLAVE_1='eth1'

          and so on.

           
    • FabianK
      FabianK
      2008-05-08

      Thanks Jay. It was just wat I was looking for. But do I have to repeat the NETMASK, BROADCAST and GATEWAY lines too for the second IPADDR?

       
      • Jay Vosburgh
        Jay Vosburgh
        2008-05-14

        >But do I have to repeat the NETMASK, BROADCAST and GATEWAY lines too for the second IPADDR?

        Yes, on, e.g., SuSE distros, the ifcfg file would have something like:

        IPADDR=1.2.3.4
        NETMASK=255.255.255.0
        BROADCAST=1.2.3.255

        IPADDR_2=5.6.7.8
        NETMASK_2=255.255.0.0

        or

        IPADDR_2=5.6.7.8/16

        For SuSE, the routes typically go in /etc/sysconfig/network/routes, and that file is described in the routes(5) man page.  Current SuSE releases don't use GATEWAY in the ifcfg file.  The ifcfg file is also documented in the ifcfg(5) man page.