This episode connects instances to the outside world: virtual routers with SNAT and DNAT, floating IPs that can be assigned and unassigned dynamically, and security groups as stateful firewalls with a default deny-all-inbound policy.

In episode 6, you created virtual networks that were still isolated. Episode 7 answers the most fundamental question after that: how do instances inside that network reach the internet, and how does the outside world reach those instances? The answer lies in three Neutron mechanisms: virtual routers, floating IPs, and security groups.
These three topics work in sequence in real scenarios. The router opens the outbound path via SNAT. The floating IP opens the inbound path via DNAT. And the security group guards the door — making sure only the traffic you allow passes through. This episode covers all three with hands-on practice.
A virtual router in Neutron is an object that connects two networks: the internal side (tenant/self-service) and the external side (provider/public). This router is implemented by the L3 Agent — in DevStack, a network namespace on the network node.
openstack router create router-utama
openstack router set --external-gateway public router-utama
openstack router add subnet router-utama subnet-aplikasiThe openstack router add subnet router-utama subnet-aplikasi command attaches the internal subnet to the router. After this, instances on subnet-aplikasi have a path to the router as their gateway.
SNAT (Source NAT) lets instances with private IPs reach the internet. The router rewrites the packet's source address to an IP from the external network, then forwards the responses back. This means instances can apt-get update, curl, and access the internet even without a public IP.
openstack network agent list --type l3The output of openstack network agent list --type l3 shows the running router agents and their status. If an agent is dead, all internal-external routing stops — this is one of the failure points we'll discuss in episode 19.
The opposite of SNAT, DNAT (Destination NAT) directs traffic from outside to a specific instance. The most common application of DNAT is the floating IP — a public IP routed to an instance's private IP.
A floating IP is an IP from an external pool that can be assigned to and unassigned from instances dynamically. Unlike a fixed IP (the private IP on an instance's port), a floating IP is essentially borrowed — an instance can switch floating IPs, or one floating IP can move to another instance during maintenance.
openstack floating ip create public
openstack floating ip listopenstack floating ip create public takes one IP from the external pool. Note the floating_ip_address column in the output — that's the IP you'll connect to the instance.
openstack server add floating ip ubuntu-nginx 172.24.4.10
openstack server show ubuntu-nginx -c addressesAfter openstack server add floating ip, the instance can be accessed from outside using the floating IP. Verify SSH connectivity from your machine:
ssh -i mykey.pem ubuntu@172.24.4.10To detach and move it to another instance, use openstack server remove floating ip then add it to the target instance. This concept is widely used in production: floating IPs are moved between instances during failover.
A security group is a collection of stateful firewall rules — meaning the responses to already-allowed traffic are automatically permitted without a separate rule. The default policy of every security group:
openstack security group list
openstack security group show defaultThe output of openstack security group show default shows the default rules that only allow SSH from within the same network and all outbound traffic.
Create a dedicated security group for the web server and add its rules:
openstack security group create sg-web
openstack security group rule create --proto tcp --dst-port 22 sg-web
openstack security group rule create --proto tcp --dst-port 80 --remote-ip 0.0.0.0/0 sg-web
openstack security group rule create --proto icmp --remote-ip 0.0.0.0/0 sg-web| Rule | Function |
|---|---|
tcp/22 | Opens SSH for administration |
tcp/80 | Opens HTTP for the public |
icmp | Opens ping for monitoring |
The openstack security group rule create --proto tcp --dst-port 80 --remote-ip 0.0.0.0/0 command allows HTTP from all IPs. To restrict it to specific IPs only, replace 0.0.0.0/0 with your office CIDR.
openstack server create --image ubuntu-jammy --flavor m1.small \
--network net-aplikasi --key-name mykey \
--security-group sg-web ubuntu-webopenstack server create --security-group sg-web attaches the firewall the moment the instance is born. Security groups can also be added to or removed from already-running instances:
openstack server add security group ubuntu-web sg-web
openstack server remove security group ubuntu-web defaultEpisode 7 makes your network truly alive: the virtual router opens the outbound path via SNAT and the inbound path via DNAT, floating IPs provide public addresses that can be moved around dynamically, and security groups keep things secure with a default-deny-all-inbound policy.
Key takeaways:
In episode 8, we'll cover Cinder (Block Storage Service) and Persistent Volumes — understanding volumes as persistent virtual hard disks, creating and attaching volumes to instances, snapshots and backups for recovery, and choosing backend drivers from LVM to Ceph RBD for production.