שימוש בקישוריות של כתובת IP פרטית של המקור עם שרת proxy הפוך

בדף הזה מוסבר איך להגדיר שרת proxy הפוך במכונה וירטואלית (VM) של Compute Engine, כדי לאפשר קישוריות פרטית למקור לצורך העברות הטרוגניות של Oracle.

צריך מכונה וירטואלית של שרת proxy הפוך כשרוצים להשתמש ב קישוריות דרך IP פרטי עם מקור שנמצא ברשת VPC שונה מזו שבה יוצרים הגדרת קישוריות פרטית לקישור בין רשתות VPC שכנות (peering).

הגדרת שרת proxy הפוך

כדי ליצור מכונה וירטואלית ב-Compute Engine לאירוח שרת ה-proxy:

  1. יצירת מכונה וירטואלית של Linux ב-Compute Engine.
  2. אחרי שמתחברים למכונה, יוצרים את הניתוב הנדרש של iptables כדי להעביר את התנועה. אתם יכולים להשתמש בסקריפט הבא.

    לפני שתשתמשו בנתוני הפקודה, חשוב להחליף את המשתנים הבאים בערכים:

    • ‫SOURCE_PRIVATE_IP בכתובת ה-IP הפרטית של מכונת המקור.
    • ‫PORT במספר היציאה שבה מכונת המקור של Oracle מאזינה לחיבורים.
    #! /bin/bash
    
    export DB_ADDR=SOURCE_PRIVATE_IP
    export DB_PORT=PORT
    
    # Enable the VM to receive packets whose destinations do
    # not match any running process local to the VM
    echo 1 > /proc/sys/net/ipv4/ip_forward
    
    # Ask the Metadata server for the IP address of the VM nic0
    # network interface:
    md_url_prefix="http://169.254.169.254/computeMetadata/v1/instance"
    vm_nic_ip="$(curl -H "Metadata-Flavor: Google" ${md_url_prefix}/network-interfaces/0/ip)"
    
    # Clear any existing iptables NAT table entries (all chains):
    iptables -t nat -F
    
    # Create a NAT table entry in the prerouting chain, matching
    # any packets with destination database port, changing the destination
    # IP address of the packet to your source instance IP address:
    iptables -t nat -A PREROUTING \
         -p tcp --dport $DB_PORT \
         -j DNAT \
         --to-destination $DB_ADDR
    
    # Create a NAT table entry in the postrouting chain, matching
    # any packets with destination database port, changing the source IP
    # address of the packet to the NAT VM's primary internal IPv4 address:
    iptables -t nat -A POSTROUTING \
         -p tcp --dport $DB_PORT \
         -j SNAT \
         --to-source $vm_nic_ip
    
    # Save iptables configuration:
    iptables-save

    ה-VM של שרת ה-proxy פועל עכשיו. ממשיכים בשאר השלבים הנדרשים לקישוריות המקור.

המאמרים הבאים