0

I currently have a cloud init file that setsup the DHCP via the following:

- path: /etc/systemd/system/dhclient@.service
  content: |
    [Unit]
    Description=Run dhclient on %i interface
    After=network.target
    [Service]
    Type=oneshot
    ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease
    RemainAfterExit=yes

However I want to now add bonding. I see that the following (for static anyway) would allow for CloudInit based bonding. However Im not sure how this will tie into the above.

network:
   version: 2
   renderer: networkd
   bonds:
       bond0:
           addresses: [10.10.1.1/24]
           gateway4: 10.10.1.254
           interfaces:
               - eth1                    
               - eth2                    
           parameters:
               mode: mode: active-backup
       ethernets:
           eth1:
               addresses: []
               dhcp4: false
               dhcp6: false
           eth2:
               addresses: []
               dhcp4: false
               dhcp6: false

For reference my complete CloudInit can be found at https://pastebin.com/X98KiwaU.

Thanks,

RickD
  • 155
  • 2
  • 3
  • 15

1 Answers1

0

CloudInit uses netplan to configuration of network. In your case you don't need any special services, just specify option in the configuration file. Also you don't need explicit configuration of the bonding member interfaces:

network:
  version: 2
  renderer: networkd
  bonds:
    bond0:
      dhcp4: true
      interfaces:
        - eth1                    
        - eth2                    
      parameters:
        mode: active-backup
        primary: eth1
Anton Danilov
  • 5,082
  • 2
  • 13
  • 23
  • The thing is, that Im obtaining a lease via - `ExecStart=/sbin/dhclient %i -pf /var/run/dhclient.%i.pid -lf /var/lib/dhclient/dhclient.%i.lease`. Add the above with the `content:` resulted in no IP being assigned at all. – RickD Jun 21 '19 at 11:23
  • You don't need additional service for dhcp client - the networkd is enough. – Anton Danilov Jun 21 '19 at 11:37
  • removed, but still no address is assigned and/or bond created... – RickD Jun 21 '19 at 14:32
  • Check status of the `networkd` with command `systemctl status networkd.service`. After changing of configuration apply it with command `netplan apply`. – Anton Danilov Jun 21 '19 at 15:14
  • I just get `Loaded: not-found (Reason: No such file or directory)` – RickD Jun 24 '19 at 08:50
  • I've made the typo. Service name is `systemd-networkd.service`. – Anton Danilov Jun 24 '19 at 09:42