English
Frequently Asked Questions

Configuring Routing for Auxiliary IPs on G-Series Servers

Updated Time:2024-11-04  Views:683

1.G-Series servers come with a default primary IP. If additional IPs are purchased, routing must be configured to enable external access. Each IP corresponds to a network interface: the first IP generally corresponds to interface `nic0`, the second IP to `nic1`, and so on.

2. Steps to Configure Routing for a Second IP

Note: Variables in red should be adjusted based on actual values.

Step 1: Find the Default Gateway for `nic1` Interface

Log in to the server and run:

curl http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/1/gateway -H "Metadata-Flavor: Google"

Example output for the default gateway: 10.10.220.1

Step 2: Identify the Interface Name for "nic1"

Run: ip link list

On CentOS, "nic1" typically maps to "eth1", with the altname "ens5".

Step 3: Locate the Internal IP

Assigned to "ens5"

Run: ip addr show ens5

Internal IP range: "10.10.220.2/32"

Step 4: Create a Custom Routing Table for "nic1"

Execute: echo "1 route-nic1" | sudo tee -a /etc/iproute2/rt_tables

Routing tables are usually named `route-nic0`, `route-nic1`, etc., though you may use any name.

tep 5: Add a Default Route in the Custom Table for `nic1` and Set Up Source-Specific Routing

Run:

sudo ip route add default via 10.10.220.1 dev ens5 table route-nic1

sudo ip route add 10.10.220.1 src 10.10.220.2 dev ens5 table route-nic1

"10.10.220.1" is the default gateway, "ens5" is the interface name, "route-nic1" is the routing table name, and "10.10.220.2" is the internal IP.

Step 6: Create Routing Rules to Use the Custom Table for Packets Matching `nic1`'s Primary Internal IP

Run:

sudo ip rule add from 10.10.220.2/32 table route-nic1

sudo ip rule add to 10.10.220.2/32 table route-nic1

Step 7: Flush the Routing Cache

Run: sudo ip route flush cache

Step 8: Persist the Routes and Rules After Reboot

Open or create "/etc/sysconfig/network-scripts/route-ens5" and add:

default via 10.10.220.1 dev ens5 table route-nic1 10.10.220.1 src

10.10.220.2 dev ens5 table route-nic1

Open or create "/etc/sysconfig/network-scripts/rule-ens5" and add:

from 10.10.220.2/32 table route-nic1

to 10.10.220.2/32 table route-nic1

Save the files, then apply the configuration by restarting the network service:

sudo systemctl restart NetworkManager

 

Previous Topic: DNSSEC FAQs
Next Topic: No Topic

Privacy PolicyRegistrants' Benefits And Responsibilities SpecificationRegistrant Educational Information Copyright© 2024 Global Resource Management Web GRMW.com. All rights reserved.