How to disable cloud init networking?

Kintarō picture Kintarō · Mar 13, 2018 · Viewed 10.8k times · Source

I am trying to disable cloud init network configuration. From the cloud init doc, I have to set network-config={config: disabled} in the kernel command line entry.

When I set it in /etc/default/grub:

GRUB_CMDLINE_LINUX="network-config={config: disabled}"

and run update-grub but it gives me the following error:

generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.4.0-116-generic
Found initrd image: /boot/initrd.img-4.4.0-116-generic
Found linux image: /boot/vmlinuz-4.4.0-104-generic
Found initrd image: /boot/initrd.img-4.4.0-104-generic
Found linux image: /boot/vmlinuz-4.4.0-97-generic
Found initrd image: /boot/initrd.img-4.4.0-97-generic
error: syntax error.
error: Incorrect command.
error: syntax error.
error: Incorrect command.
error: syntax error.
Syntax error at line 128
Syntax errors are detected in generated GRUB config file.
Ensure that there are no errors in /etc/default/grub
and /etc/grub.d/* files or please file a bug report with
/boot/grub/grub.cfg.new file attached.
done

Looks like it doesn't take a yaml string.

Am I configuring in the right place?

Thanks

Answer

Thanat Noo. picture Thanat Noo. · Jun 1, 2018

Create a file at /etc/cloud/cloud.cfg.d/99-custom-networking.cfg which contains :

network: {config: disabled}