How to Use an Elastic IP as a Public Network Egress IP
Elastic IPs can be used as stable and reliable public egress IP addresses to realize scenarios requiring continuous availability and accessibility.
To use an elastic IP as a public network egress IP, we will perform the following steps:
Step 1 - Purchase and Associate Elastic IP
You can create an elastic IP and assign it to your desired instance on zenConsole. View Create an Elastic IP for specified details.
If you already have an elastic IP, you can go to the instance details page, and assign the elastic IP to your desired instance.
Note
Only elastic IPs in the same zone of the instance can be assigned.
Step 2 - Set Elastic IP as Public Internet Egress IP
You can use the ip
command on your instance to set the priority of the elastic IP address. Here's an example of CentOS 7.6 operating system instance about how to set the elastic IP address priority using the ip
command:
default-gateway
: the default gateway address;source-IP
: the elastic IP address you want to use;network-interface
: the network interface associated with the elastic IP address.
Note
The settings are temporary and will be invalid after a system reboot. If you want to permanently set the elastic IP, you can add the relevant command to your system's startup script.
The settings may vary depending on your operating system's version. You're recommended to refer to the official documentation of your system to learn more about related configurations.
Example
For CentOS 7.6 operating system instance, you have assigned
193.118.53.186
and193.118.53.180
to your instance. You want to set193.118.53.186
as the public egress IP. You can see the gateway193.118.55.117
.
Use the
ip a
command to get the network interface.
In this case,
default-gateway
:193.118.55.117
;source-IP
:193.118.53.186
;network-interface
:wan0
.
Execute the following command:
Result
Now all your egress traffic will go through the elastic IP address you have set.
Last updated