By default, traffic from your Nebius AI Cloud resources to public IP addresses is routed to the internet through the default egress gateway. You can set up a Compute virtual machine (VM) as a custom gateway for traffic from specific subnets to the internet. The gateway is called a NAT gateway because it uses network address translation (NAT) to change the egress traffic’s source IP address. This change causes the traffic to appear as if it were sent from the public IP address of the gateway VM rather than the private IP address of the originating resource.Documentation Index
Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites
- Install and configure the Nebius AI Cloud CLI.
- Make sure you are in a group that has at least the
editorrole within your tenant; for example, the defaulteditorsgroup. You can check this in the Administration → IAM section of the web console.
Steps
Create a gateway virtual machine
-
Get the ID of the network that contains the subnets for which you want to set up routing:
Save the network’s ID from the
.metadata.idfield. -
Create a subnet for the gateway virtual machine (VM):
Save the subnet’s ID from the
.metadata.idfield. -
Create a private allocation for the gateway VM:
Save the allocation’s ID from the
.metadata.idfield. -
Create the gateway VM. It must have a network interface that is located in the created subnet, has the allocated private IP address and a public IP address:
For more details about VM parameters, see How to create a virtual machine in Nebius AI Cloud.
Full example
Set up the gateway VM
-
Connect to the gateway VM by using SSH:
For more details, see How to connect to virtual machines in Nebius AI Cloud.
-
Enable IPv4 routing and make this change persistent:
-
Enable egress NAT and make this change persistent:
The latter command asks you whether to save your current
iptablesIPv4 and IPv6 rules to files. Answer “yes” to both. -
Disconnect from the gateway VM:
Set up routing
-
Create a routing table in the network:
Save the routing table’s ID from the
.metadata.idfield. -
Create a route in the routing table to send egress traffic to the gateway private allocation:
-
Assign the routing table to the subnets that should use the NAT gateway:
Repeat for each subnet as needed. Do not assign the routing table to the subnet of the gateway VM (
gateway-subnet).
Test routing
To test that the routing table works, send traffic from a VM in a subnet to which you assigned the routing table (a test VM) and check its source IP address:-
Connect to the test VM by using the gateway VM as the jump host:
-
Verify that egress traffic from the test VM to the internet is routed through the gateway VM, by using a public service that looks up the traffic’s source IP address:
The command should return the public IP address of the gateway VM. If it returns the private address of the test VM instead:
- Check that you assigned the routing table to the subnet: run
nebius vpc route-table get <routing_table_ID>and then find the subnet in the.status.assignment.subnetsfield. - Check that the test VM belongs to this subnet: run
nebius compute instance get <VM_ID>and then find the subnet in the.spec.network_interfaces[0].subnet_idfield. - Check that you specified the gateway VM’s private allocation as the next hop in the route: run
nebius vpc route list --parent-id <routing_table_ID>and then find the allocation in the.spec.next_hop.allocation.idfield.
- Check that you assigned the routing table to the subnet: run