A method for obtaining path information, wherein the method is applied to a forwarding device, and comprises: obtaining, when the forwarding device is an ingress device, a target service packet, wherein the target service packet is a service packet that matches a flow rule, and the flow rule is preconfigured on the forwarding device; and generating, by the ingress device, ingress interface information or/and egress interface information according to a path detection tag on an ingress interface or/and an egress interface through which the target service packet passes; forwarding, by the ingress device, an updated target service packet, wherein the update target service packet is the target service packet with the ingress interface information or/and egress interface information, generating, when the forwarding device is an intermediate device, a second ingress interface information field or/and a second egress interface information field according to a path detection tag on an ingress interface or/and an egress interface through which the updated target service packet passes; the method further comprises: obtaining by the intermediate device another updated target service packet with the second ingress interface information field or/and the second egress interface information field, wherein the another updated target service packet comprises connectivity fault management information, the connectivity fault management information comprises an Ether type field, a connectivity fault management header field, a first ingress interface information field or/and a first egress interface information field, the second ingress interface information field or/and the second egress interface information field, and an end field, and the connectivity fault management information is located at a tail of an Ethernet packet of the another updated target service packet; and forwarding by the intermediate device, the another updated target service packet. obtaining, when the forwarding device is an ingress device, a target service packet, wherein the target service packet is a service packet that matches a flow rule, and the flow rule is preconfigured on the forwarding device; and generating, by the ingress device, ingress interface information or/and egress interface information according to a path detection tag on an ingress interface or/and an egress interface through which the target service packet passes; forwarding, by the ingress device, an updated target service packet, wherein the update target service packet is the target service packet with the ingress interface information or/and egress interface information, generating, when the forwarding device is an intermediate device, a second ingress interface information field or/and a second egress interface information field according to a path detection tag on an ingress interface or/and an egress interface through which the updated target service packet passes; the method further comprises: obtaining by the intermediate device another updated target service packet with the second ingress interface information field or/and the second egress interface information field, wherein the another updated target service packet comprises connectivity fault management information, the connectivity fault management information comprises an Ether type field, a connectivity fault management header field, a first ingress interface information field or/and a first egress interface information field, the second ingress interface information field or/and the second egress interface information field, and an end field, and the connectivity fault management information is located at a tail of an Ethernet packet of the another updated target service packet; and forwarding by the intermediate device, the another updated target service packet. obtaining by the intermediate device another updated target service packet with the second ingress interface information field or/and the second egress interface information field, wherein the another updated target service packet comprises connectivity fault management information, the connectivity fault management information comprises an Ether type field, a connectivity fault management header field, a first ingress interface information field or/and a first egress interface information field, the second ingress interface information field or/and the second egress interface information field, and an end field, and the connectivity fault management information is located at a tail of an Ethernet packet of the another updated target service packet; and forwarding by the intermediate device, the another updated target service packet.