A data forwarding method, wherein the method comprises: obtaining (S201, S301, S601, S801), by a head node, to-be-forwarded data; obtaining (S202, S302, S602, S803), by the head node, a first segment identifier SID list corresponding to the to-be-forwarded data, wherein the first SID list is generated based on SIDs of a part of nodes in a target forwarding path; encapsulating (S203, S303, S603, S805), by the head node in front of the to-be-forwarded data, a packet header comprising the first SID list, to obtain a to-be-forwarded packet; and sending (S204, S304, S604, S807), by the head node, the to-be-forwarded packet based on the first SID list; wherein the target forwarding path comprises M nodes, the first SID list is generated based on SIDs of first N nodes in the M nodes, the first SID list comprises a SID of an intermediate node, the SID of the intermediate node comprise a function field and a parameter argument field in the SID, where the function field is used to indicate to replace the first SID list with a second SID list, and the argument field is used to indicate the second SID list, and the second SID list is generated based on SIDs of an X th node to a Y th node in the M nodes, wherein M is greater than N, N is greater than or equal to 1, X is greater than or equal to N, and Y is less than or equal to M. obtaining (S201, S301, S601, S801), by a head node, to-be-forwarded data; obtaining (S202, S302, S602, S803), by the head node, a first segment identifier SID list corresponding to the to-be-forwarded data, wherein the first SID list is generated based on SIDs of a part of nodes in a target forwarding path; encapsulating (S203, S303, S603, S805), by the head node in front of the to-be-forwarded data, a packet header comprising the first SID list, to obtain a to-be-forwarded packet; and sending (S204, S304, S604, S807), by the head node, the to-be-forwarded packet based on the first SID list; wherein the target forwarding path comprises M nodes, the first SID list is generated based on SIDs of first N nodes in the M nodes, the first SID list comprises a SID of an intermediate node, the SID of the intermediate node comprise a function field and a parameter argument field in the SID, where the function field is used to indicate to replace the first SID list with a second SID list, and the argument field is used to indicate the second SID list, and the second SID list is generated based on SIDs of an X th node to a Y th node in the M nodes, wherein M is greater than N, N is greater than or equal to 1, X is greater than or equal to N, and Y is less than or equal to M. the target forwarding path comprises M nodes, the first SID list is generated based on SIDs of first N nodes in the M nodes, the first SID list comprises a SID of an intermediate node, the SID of the intermediate node comprise a function field and a parameter argument field in the SID, where the function field is used to indicate to replace the first SID list with a second SID list, and the argument field is used to indicate the second SID list, and the second SID list is generated based on SIDs of an X th node to a Y th node in the M nodes, wherein M is greater than N, N is greater than or equal to 1, X is greater than or equal to N, and Y is less than or equal to M.