blob: 10e1c3ff2c6def9fb1d4c9c139ea37e3bc9f365f [file] [log] [blame]
Sean Daguebc883df2016-08-12 07:21:59 -04001=====================
2 DevStack Networking
3=====================
4
5An important part of the DevStack experience is networking that works
6by default for created guests. This might not be optimal for your
Peter Stachowski0dab8d62016-11-21 20:36:31 +00007particular testing environment, so this document tries its best to
Sean Daguebc883df2016-08-12 07:21:59 -04008explain what's going on.
9
10Defaults
11========
12
13If you don't specify any configuration you will get the following:
14
15* neutron (including l3 with openvswitch)
16* private project networks for each openstack project
17* a floating ip range of 172.24.4.0/24 with the gateway of 172.24.4.1
Kevin Benton4bfbc292016-11-15 17:26:05 -080018* the demo project configured with fixed ips on a subnet allocated from
19 the 10.0.0.0/22 range
Peter Stachowski0dab8d62016-11-21 20:36:31 +000020* a ``br-ex`` interface controlled by neutron for all its networking
Sean Daguebc883df2016-08-12 07:21:59 -040021 (this is not connected to any physical interfaces).
Peter Stachowski0dab8d62016-11-21 20:36:31 +000022* DNS resolution for guests based on the resolv.conf for your host
Sean Daguebc883df2016-08-12 07:21:59 -040023* an ip masq rule that allows created guests to route out
24
25This creates an environment which is isolated to the single
26host. Guests can get to the external network for package
27updates. Tempest tests will work in this environment.
28
29.. note::
30
31 By default all OpenStack environments have security group rules
32 which block all inbound packets to guests. If you want to be able
33 to ssh / ping your created guests you should run the following.
34
35 .. code-block:: bash
36
37 openstack security group rule create --proto icmp --dst-port 0 default
38 openstack security group rule create --proto tcp --dst-port 22 default
39
40Locally Accessible Guests
41=========================
42
Jens Harbottc3b58f52020-06-08 11:58:29 +020043If you want to make your guests accessible from other machines on your
Sean Daguebc883df2016-08-12 07:21:59 -040044network, we have to connect ``br-ex`` to a physical interface.
45
46Dedicated Guest Interface
47-------------------------
48
49If you have 2 or more interfaces on your devstack server, you can
50allocate an interface to neutron to fully manage. This **should not**
51be the same interface you use to ssh into the devstack server itself.
52
53This is done by setting with the ``PUBLIC_INTERFACE`` attribute.
54
55.. code-block:: bash
56
57 [[local|localrc]]
58 PUBLIC_INTERFACE=eth1
59
60That will put all layer 2 traffic from your guests onto the main
61network. When running in this mode the ip masq rule is **not** added
62in your devstack, you are responsible for making routing work on your
63local network.
64
65Shared Guest Interface
66----------------------
67
68.. warning::
69
70 This is not a recommended configuration. Because of interactions
Stephen Finucane3362be92024-08-22 16:24:21 +010071 between OVS and bridging, if you reboot your box with active
John L. Villalovos64edfd42017-08-17 13:21:25 -070072 networking you may lose network connectivity to your system.
Sean Daguebc883df2016-08-12 07:21:59 -040073
74If you need your guests accessible on the network, but only have 1
75interface (using something like a NUC), you can share your one
76network. But in order for this to work you need to manually set a lot
77of addresses, and have them all exactly correct.
78
79.. code-block:: bash
80
81 [[local|localrc]]
82 PUBLIC_INTERFACE=eth0
83 HOST_IP=10.42.0.52
Jens Harbottc3b58f52020-06-08 11:58:29 +020084 FLOATING_RANGE=10.42.0.0/24
Sean Daguebc883df2016-08-12 07:21:59 -040085 PUBLIC_NETWORK_GATEWAY=10.42.0.1
86 Q_FLOATING_ALLOCATION_POOL=start=10.42.0.250,end=10.42.0.254
87
88In order for this scenario to work the floating ip network must match
89the default networking on your server. This breaks HOST_IP detection,
90as we exclude the floating range by default, so you have to specify
91that manually.
92
93The ``PUBLIC_NETWORK_GATEWAY`` is the gateway that server would normally
94use to get off the network. ``Q_FLOATING_ALLOCATION_POOL`` controls
95the range of floating ips that will be handed out. As we are sharing
96your existing network, you'll want to give it a slice that your local
97dhcp server is not allocating. Otherwise you could easily have
98conflicting ip addresses, and cause havoc with your local network.
Kevin Benton4bfbc292016-11-15 17:26:05 -080099
100
101Private Network Addressing
102==========================
103
104The private networks addresses are controlled by the ``IPV4_ADDRS_SAFE_TO_USE``
105and the ``IPV6_ADDRS_SAFE_TO_USE`` variables. This allows users to specify one
106single variable of safe internal IPs to use that will be referenced whether or
107not subnetpools are in use.
108
109For IPv4, ``FIXED_RANGE`` and ``SUBNETPOOL_PREFIX_V4`` will just default to
110the value of ``IPV4_ADDRS_SAFE_TO_USE`` directly.
111
Peter Stachowski0dab8d62016-11-21 20:36:31 +0000112For IPv6, ``FIXED_RANGE_V6`` will default to the first /64 of the value of
Kevin Benton4bfbc292016-11-15 17:26:05 -0800113``IPV6_ADDRS_SAFE_TO_USE``. If ``IPV6_ADDRS_SAFE_TO_USE`` is /64 or smaller,
Peter Stachowski0dab8d62016-11-21 20:36:31 +0000114``FIXED_RANGE_V6`` will just use the value of that directly.
Kevin Benton4bfbc292016-11-15 17:26:05 -0800115``SUBNETPOOL_PREFIX_V6`` will just default to the value of
116``IPV6_ADDRS_SAFE_TO_USE`` directly.
Stephen Finucane3362be92024-08-22 16:24:21 +0100117
118.. _ssh:
119
120SSH access to instances
121=======================
122
123To validate connectivity, you can create an instance using the
124``$PRIVATE_NETWORK_NAME`` network (default: ``private``), create a floating IP
125using the ``$PUBLIC_NETWORK_NAME`` network (default: ``public``), and attach
126this floating IP to the instance:
127
128.. code-block:: shell
129
130 openstack keypair create --public-key ~/.ssh/id_rsa.pub test-keypair
131 openstack server create --network private --key-name test-keypair ... test-server
132 fip_id=$(openstack floating ip create public -f value -c id)
133 openstack server add floating ip test-server ${fip_id}
134
135Once done, ensure you have enabled SSH and ICMP (ping) access for the security
136group used for the instance. You can either create a custom security group and
137specify it when creating the instance or add it after creation, or you can
138modify the ``default`` security group created by default for each project.
139Let's do the latter:
140
141.. code-block:: shell
142
143 openstack security group rule create --proto icmp --dst-port 0 default
144 openstack security group rule create --proto tcp --dst-port 22 default
145
146Finally, SSH into the instance. If you used the Cirros instance uploaded by
147default, then you can run the following:
148
149.. code-block:: shell
150
151 openstack server ssh test-server -- -l cirros
152
153This will connect using the ``cirros`` user and the keypair you configured when
154creating the instance.
Stephen Finucane14f60b92024-08-26 11:56:31 +0100155
156Remote SSH access to instances
157==============================
158
159You can also SSH to created instances on your DevStack host from other hosts.
160This can be helpful if you are e.g. deploying DevStack in a VM on an existing
Stephen Finucane49933802024-08-27 12:08:23 +0100161cloud and wish to do development on your local machine. There are a few ways to
162do this.
163
164.. rubric:: Configure instances to be locally accessible
165
166The most obvious way is to configure guests to be locally accessible, as
167described `above <Locally Accessible Guests>`__. This has the advantage of
168requiring no further effort on the client. However, it is more involved and
169requires either support from your cloud or some inadvisable workarounds.
170
171.. rubric:: Use your DevStack host as a jump host
172
173You can choose to use your DevStack host as a jump host. To SSH to a instance
174this way, pass the standard ``-J`` option to the ``openstack ssh`` / ``ssh``
175command. For example:
176
177.. code-block::
178
179 openstack server ssh test-server -- -l cirros -J username@devstack-host
180
181(where ``test-server`` is name of an existing instance, as described
182:ref:`previously <ssh>`, and ``username`` and ``devstack-host`` are the
183username and hostname of your DevStack host).
184
185This can also be configured via your ``~/.ssh/config`` file, making it rather
186effortless. However, it only allows SSH access. If you want to access e.g. a
187web application on the instance, you will need to configure an SSH tunnel and
188forward select ports using the ``-L`` option. For example, to forward HTTP
189traffic:
190
191.. code-block::
192
193 openstack server ssh test-server -- -l cirros -L 8080:username@devstack-host:80
194
195(where ``test-server`` is name of an existing instance, as described
196:ref:`previously <ssh>`, and ``username`` and ``devstack-host`` are the
197username and hostname of your DevStack host).
198
199As you can imagine, this can quickly get out of hand, particularly for more
200complex guest applications with multiple ports.
201
202.. rubric:: Use a proxy or VPN tool
203
204You can use a proxy or VPN tool to enable tunneling for the floating IP
Stephen Finucane14f60b92024-08-26 11:56:31 +0100205address range of the ``$PUBLIC_NETWORK_NAME`` network (default: ``public``)
Stephen Finucane49933802024-08-27 12:08:23 +0100206defined by ``$FLOATING_RANGE`` (default: ``172.24.4.0/24``). There are many
207such tools available to do this. For example, we could use a useful utility
208called `shuttle`__. To enable tunneling using ``shuttle``, first ensure you
209have allowed SSH and HTTP(S) traffic to your DevStack host. Allowing HTTP(S)
210traffic is necessary so you can use the OpenStack APIs remotely. How you do
211this will depend on where your DevStack host is running. Once this is done,
212install ``sshuttle`` on your localhost:
Stephen Finucane14f60b92024-08-26 11:56:31 +0100213
214.. code-block:: bash
215
Takashi Kajinamib609c802025-01-07 10:51:03 +0900216 sudo apt-get install sshuttle || dnf install sshuttle
Stephen Finucane14f60b92024-08-26 11:56:31 +0100217
Stephen Finucane49933802024-08-27 12:08:23 +0100218Finally, start ``sshuttle`` on your localhost using the floating IP address
219range. For example, assuming you are using the default value for
220``$FLOATING_RANGE``, you can do:
Stephen Finucane14f60b92024-08-26 11:56:31 +0100221
222.. code-block:: bash
223
224 sshuttle -r username@devstack-host 172.24.4.0/24
225
226(where ``username`` and ``devstack-host`` are the username and hostname of your
227DevStack host).
228
Stephen Finucane49933802024-08-27 12:08:23 +0100229You should now be able to create an instance and SSH into it:
230
231.. code-block:: bash
232
233 openstack server ssh test-server -- -l cirros
234
235(where ``test-server`` is name of an existing instance, as described
236:ref:`previously <ssh>`)
Stephen Finucane14f60b92024-08-26 11:56:31 +0100237
238.. __: https://github.com/sshuttle/sshuttle