本页面介绍提供方网络管理员如何管理使用 Private Service Connect 接口的 VPC 网络中的安全性。
由于使用方 Private Service Connect 网络中存在 Private Service Connect 接口,因此提供方组织不会控制直接应用于该接口的防火墙规则。如果提供方组织想要确保使用方工作负载无法向提供方网络中的虚拟机发起流量,或者只有所选使用方工作负载可以发起流量,则他们必须在其接口虚拟机的客机操作系统中定义安全政策。
阻止使用方到提供方的入站流量
您可以使用 iptables 配置 Private Service Connect 接口,以阻止来自使用方网络的入站流量,但仍允许来自提供方网络的出站流量。此配置如图 1 所示。
此配置阻止了使用方流量通过 Private Service Connect 接口入站,但允许提供方的出站流量(点击可放大)。
如需配置 Private Service Connect 接口以阻止来自使用方网络的入站流量,但允许来自提供方网络的出站流量,请执行以下操作:
确保防火墙规则配置为允许入站流量 SSH 连接以连接到 Private Service Connect 接口的虚拟机。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-05。"],[],[],null,["# Configure security for Private Service Connect interfaces\n=========================================================\n\nThis page describes how producer network administrators can manage\nsecurity in VPC networks that use\nPrivate Service Connect interfaces.\n\nBecause a Private Service Connect interface exists in a consumer\nPrivate Service Connect network, a producer organization does not\ncontrol firewall rules that apply directly to the interface. If a producer\norganization wants to ensure that consumer workloads cannot initiate traffic to\nVMs in the producer network, or that only selected consumer workloads can\ninitiate traffic, they must define security policies in the guest OS of their\ninterface's VM.\n\nBlock consumer-to-producer ingress\n----------------------------------\n\nYou can use `iptables` to configure a Private Service Connect\ninterface to block ingress traffic from a consumer network, but still allow\negress traffic from the producer network. This configuration is illustrated by\nfigure 1.\n[](/static/vpc/images/psc-interfaces/block-consumer-to-producer-ingress.svg) Consumer traffic is blocked from ingress through a Private Service Connect interface, but producer egress traffic is allowed (click to enlarge).\n\nTo configure a Private Service Connect interface to block ingress\ntraffic from the consumer network but allow egress traffic from the producer\nnetwork, do the following:\n\n1. Ensure that firewall rules are configured to\n [allow ingress SSH connections](/firewall/docs/using-firewalls#common-use-cases-allow-ssh)\n to your Private Service Connect interface's VM.\n\n2. [Connect](/compute/docs/connect/standard-ssh#connect_to_vms) to the VM.\n\n3. If the `iptables` command isn't available, install it.\n\n4. Allow consumer reply traffic to ingress into the\n Private Service Connect interface:\n\n ```\n sudo iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT -i OS_INTERFACE_NAME\n ```\n\n Replace \u003cvar translate=\"no\"\u003eOS_INTERFACE_NAME\u003c/var\u003e with the\n [guest OS name for your Private Service Connect interface](/vpc/docs/configure-routing-private-service-connect-interfaces#find-os-interface-name).\n5. Block consumer-initiated traffic from ingressing through the\n Private Service Connect interface:\n\n ```\n sudo iptables -A INPUT -j DROP -i OS_INTERFACE_NAME\n ```\n\nBlock Private Service Connect interface creation\n------------------------------------------------\n\nTo create Private Service Connect interfaces, users\nmust have the `compute.instances.pscInterfaceCreate` Identity and Access Management (IAM)\npermission. This permission is included in the following roles:\n\n- [Compute Admin](/compute/docs/access/iam#compute.admin) (`roles/compute.admin`)\n- [Compute Instance Admin (v1)](/iam/docs/understanding-roles#compute.instanceAdmin.v1) (`roles/compute.instanceAdmin.v1`)\n\nIf you want a user to have the permissions that are associated with these\nroles, while preventing that user from creating\nPrivate Service Connect interfaces, you can\n[Create a custom role](/iam/docs/creating-custom-roles#creating) and grant\nit to the user. Add the necessary permissions to the role. Omit the\n`compute.instances.pscInterfaceCreate` permission.\n\nWhat's next?\n------------\n\n- [Manage destination overlap](/vpc/docs/manage-destination-overlap) in a network that has a Private Service Connect interface connection."]]