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

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

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

קישוריות של ממשקי Private Service Connect.

הגדרת שרת 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

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

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