Skip to content

How to directly attach an IPv4 or IPv6 address to my instance

Estimated time to read: 4 minutes

Introduction

Fuga Cloud offers floating IPs and direct-attached IP addresses so your instances are remotely available for public networks (internet). You can choose between IPv4 and IPv6 addresses or use both at the same time. IPv4 is available as a direct-attached IP or as a floating IP and IPv6 is only available as direct-attached IP.

In this tutorial, we will show you how to add a direct-attached IPv4 or IPv6 address to your instance. The easiest way to do this is during the launch of your instance. You can add network interfaces after you launched your instance, but then you have to manually configure your network interface on your instance. Although that is possible it is not a road I do not recommend for most people.

When using IPv6 you can only connect (ping/ssh etc…) to that address if the host that you are connecting from also has an IPv6 address. The command ping6 ipv6_address will not work on most computers/laptops. This is because most internet providers do not support IPv6 yet and therefore do not give you an IPv6 address.

Prerequisites:

  1. Fuga Cloud account
  2. OpenStack CLI tools installed (optional)

There are several ways of launching an instance with an IPv4 or IPv6 address on Fuga Cloud. You can either use the dashboard, the RESTful API or the OpenStack CLI tools.

We will describe how you can attach your IPv4 or IPv6 address using the Fuga Cloud dashboard and the OpenStack CLI tools.

Pre step using the CLI tools

For launching an instance with the OpenStack CLI tools you’ll need to provide the following values: Instance flavor, image, network, security group, key, and an instance name.

To view all the flavors available use the following command:

openstack flavor list

To view all the networks available use the following command:

openstack network list

For a direct-attached IPv4 address choose public and for an IPv6 address choose public6

To view the images available use the following command:

openstack image list

To view the security groups available use the following command:

openstack security group list

To view the key available use the following command:

openstack keypair list

If there are no available key pairs in your list please view our tutorial How to add a key pair using the CLI tools.

Step 1: Launching an instance

  • Log in to the dashboard.
  • Click on the Compute tab and select instances.
  • To create a new instance click on the Launch Instance button.
  • Fill in all the required fields such as your instance name, the flavor you want, etc.
    • For a complete description on how to launch an instance check out our getting started tutorials.
  • Click on the Networks tab and select public for an IPv4 address and public6 for an IPv6 address.
    • You can also choose both networks if you like.
  • Launch your instance.

Your new instance should now be visible including your direct-attached IP address(es) on your instance tab

To launch a new instance with a direct attached IP use the following command: In this example, both IPv4 and IPv6 will be attached.

$ openstack server create --flavor <flavor> --network public --network public6 --security-group <name_of_sc> --image <snapshot_name> --key-name <keypair_name> <name_your_instance>

You can see your newly created instance using the following command:

openstack server list

Step 2: Adding a rule for SSH

By default, all inbound traffic originating from the public internet is blocked. To allow inbound traffic we need to add additional ingress rules to your chosen security group if you haven’t added extra rules already.

Adding a rule for SSH (port 22)

  • Click on the Networking tab and select Security Groups
  • Click on the Manage rules button of the security group you would like to add the rule to
    • You can also create a new security group if you like
  • Click on the + Add Rule button
  • By Rule select SSH from the dropdown menu
  • By Remote select CIDR from the dropdown menu
  • By CIDR type 0.0.0.0/0 for IPv4 or type ::/0 for IPv6
  • Click on the Add button

Adding a rule for ICMP (ping)

  • Click on the Networking tab and select Security Groups
  • Click on the Manage rules button of the security group you would like to add the rule to
    • You can also create a new security group if you like
  • Click on the + Add Rule button
  • By Rule select All ICMP from the dropdown menu
  • By Remote select CIDR from the dropdown menu
  • By CIDR type 0.0.0.0/0 for IPv4 or type ::/0 for IPv6
  • Click on the Add button

By default, all inbound traffic originating from the public internet is blocked. To allow inbound traffic we need to add additional ingress rules to your chosen security group if you haven’t added extra rules already.

To add a rule to a specific security group for SSH you can use one of the following commands

For IPv4

openstack security group rule create <security_group_name> --protocol tcp --dst-port 22:22 --remote-ip 0.0.0.0/0

For IPv6

openstack security group rule create <security_group_name> --protocol tcp --dst-port 22:22 --remote-ip ::/0 --ethertype IPv6

For adding a security rule for ICMP (ping) you can use one of the following commands:

For IPv4

openstack security group rule create <security_group_name> --protocol icmp --remote-ip 0.0.0.0/0

For IPv6

openstack security group rule create <security_group_name> --protocol icmp --remote-ip ::/0 --ethertype IPv6

Conclusion

In this tutorial, you have learned how you can directly attach an IPv4 or IPv6 address to your instance during launch. We also showed you how you can add a security rule so that your instance can be reached from public networks (internet)