이 페이지에서는 전달 규칙의 대상을 대상 인스턴스와 백엔드 서비스 간에 전환하는 방법을 설명합니다.
외부 프로토콜 전달
외부 전달 규칙의 대상을 대상 인스턴스에서 백엔드 서비스로 전환하거나 그 반대로 전환하려면 새 대상에서 전달 규칙을 삭제하고 다시 만들어야 합니다. 이 방법에서는 새 전달 규칙에서 동일한 주소를 사용할 수 있도록 고정 IP 주소가 필요합니다.
전달 규칙을 삭제하고 다시 만드는 것이 외부 프로토콜 전달과 백엔드 서비스 기반 외부 패스 스루 네트워크 부하 분산기 간에 전환할 수 있는 유일한 방법입니다.
내부 프로토콜 전달
내부 프로토콜 전달과 내부 패스 스루 네트워크 부하 분산기 간에 전환하는 방법에는 두 가지가 있습니다.
내부 전달 규칙의 대상 변경에 설명된 대로 gcloud compute forwarding-rules set-target 명령어를 사용하여 전달 규칙을 업데이트하여 대상 인스턴스와 백엔드 서비스 간에 전환할 수 있습니다.
내부 프로토콜 전달과 내부 패스 스루 네트워크 부하 분산기 간에 전환할 때는 전달 규칙을 삭제하고 다시 만들 필요가 없습니다. 전달 규칙은 동일한 내부 IP 주소(고정 또는 임시)를 계속 사용합니다.
전달 규칙을 삭제하고 다시 만들어 대상 인스턴스와 백엔드 서비스 간에 전환할 수도 있습니다. 그러나 이 방법은 새 전달 규칙에 동일한 주소를 사용하기 위해 고정 IPv4 주소가 필요합니다.
IPv6 주소 예약은 지원되지 않으므로 IPv6 주소에는 이 메서드를 사용할 수 없습니다.
대상 인스턴스는 프로토콜을 지정하지 않으며 전달 규칙의 프로토콜과 포트를 상속합니다. 따라서 전달 규칙을 백엔드 서비스를 참조하도록 전환할 때 전달 규칙의 IP 프로토콜(TCP 또는 UDP)이 백엔드 서비스의 프로토콜(TCP 또는 UDP)과 일치하는지 확인해야 합니다.
다음 다이어그램은 내부 프로토콜 전달을 사용하는 예시를 보여줍니다.
대상 인스턴스와 백엔드 서비스 간 전환
내부 전달 규칙의 대상 변경
전달 규칙이 대상 인스턴스를 가리키는 것에서 리전별 백엔드 서비스를 가리키는 것으로 변경하려면 다음 명령어를 사용합니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[],[],null,["# Switch between a target instance and a backend service\n\nThis page describes how to switch the target of a forwarding rule between a\ntarget instance and a backend service.\n\nExternal protocol forwarding\n----------------------------\n\nTo switch an external forwarding rule's target from a target instance to a\nbackend service (or the other way around), you need to delete and re-create\nthe forwarding rule with the new target. This method requires a static IP\naddress so that you can use the same address with the new forwarding rule.\n\nDeleting and re-creating the forwarding rule is the only way to switch between\nexternal protocol forwarding and a backend service-based external passthrough Network Load Balancer.\n\nInternal protocol forwarding\n----------------------------\n\nThere are two ways to switch between internal protocol forwarding and an\ninternal passthrough Network Load Balancer:\n\n- You can switch between a target instance and a backend service by updating the\n forwarding rule with the `gcloud compute forwarding-rules set-target` command\n as described in\n [Change the target of an internal forwarding rule](#int-change-target).\n When switching between\n internal protocol forwarding and an internal passthrough Network Load Balancer, you don't need\n to delete and re-create the forwarding rule. The forwarding rule continues to\n use the same internal IP address (whether static or ephemeral).\n\n- You can also switch between a target instance and a backend service by deleting\n and re-creating the forwarding rule. However, this method requires a static\n IPv4 address in order to use the same address with the new forwarding rule.\n You can't use this method for IPv6 addresses because reserving an IPv6 address\n is not supported.\n\nA target instance does not specify any protocol---it inherits the protocols and\nports of the forwarding rule. Therefore, when switching a forwarding rule to\nreference a backend service, you must ensure that the IP protocol of the\nforwarding rule (either TCP or UDP) matches the protocol of the backend\nservice (either TCP or UDP).\n\nThe following diagram shows an example that uses internal protocol forwarding.\n[](/static/load-balancing/images/pf-int-switch-target.svg) Switch between a target instance and a backend service.\n\n### Change the target of an internal forwarding rule\n\nTo change a forwarding rule from pointing to a target instance to pointing to a\nregional backend service, use the following command: \n\n```\ngcloud compute forwarding-rules set-target FORWARDING_RULE \\\n --backend-service=BACKEND_SERVICE \\\n --region=REGION\n```\n\nTo transition back to a target instance, use the following command: \n\n```\ngcloud compute forwarding-rules set-target FORWARDING_RULE \\\n --target-instance=TARGET_INSTANCE \\\n --target-instance-zone=ZONE\n```"]]