How to assign multiple outgoing IPs addresses to a single instance on GCE?

后端 未结 1 1795
别跟我提以往
别跟我提以往 2020-12-21 17:19

How does one assign multiple ephemeral external IP addresses to the same machine on Google Compute Engine? The web interface only discusses the primary IP addresses, but I s

相关标签:
1条回答
  • 2020-12-21 18:23

    Yes it's possible, with some steps:

    1. Create the same number of VPC (Network) as you need interfaces
    2. Create a subnet inside each VPC and make sure the are not overlapping
    3. Add a firewall rule in the first VPC to allow SSH from your location
    4. Create an instance with multiple interfaces (one in each VPC) and assign external address to each one
    5. SSH to your instance via the address located on the first VPC
    6. Configure a separate routing table for each network interface

    Things you have to know:

    • You can add interfaces only on instance creation
    • I've got an error on configuration of routing table, but it worked (RTNETLINK answers: File exists)
    • Routing table of secondary interfaces are not persisted, you have to manage how to do this

    Results

    yann@test-multiple-ip:~$ ip a
    [...]
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 42:01:c0:a8:00:02 brd ff:ff:ff:ff:ff:ff
        inet 192.168.0.2/32 brd 192.168.0.2 scope global eth0
           valid_lft forever preferred_lft forever
        inet6 fe80::4001:c0ff:fea8:2/64 scope link 
           valid_lft forever preferred_lft forever
    3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc pfifo_fast state UP group default qlen 1000
        link/ether 42:01:c0:a8:01:02 brd ff:ff:ff:ff:ff:ff
        inet 192.168.1.2/32 brd 192.168.1.2 scope global eth1
           valid_lft forever preferred_lft forever
        inet6 fe80::4001:c0ff:fea8:102/64 scope link 
           valid_lft forever preferred_lft forever
    
    yann@test-multiple-ip:~$ curl --interface eth0 ifconfig.co
    35.241.195.172
    yann@test-multiple-ip:~$ curl --interface eth1 ifconfig.co
    35.241.253.41
    
    0 讨论(0)
提交回复
热议问题