Fix IPv6 to IPv6 and IPv4 to IPv6 transparent proxying #370
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Currently, when the client is IPv4 and the destination is IPv4, transparent proxying works.
When the client is IPv6 and the destination is IPv6, it does not, because the wrong type of socket is created.
When the client is IPv4 and the destination is IPv6, no mapping is done and an address family error is thrown.
The address family error is thrown because when using ::ffff:192.0.2.1 as source address, the socket will create an IPv4 packet, not an IPv6 packet.
This patch fixes the socket type for IPv6 to IPv6, and also changes the source address from ::ffff:192.0.2.1 to ::192.0.2.1 for IPv4 to IPv6.
In the server logs on the destinations the IPv4-address is as human readable as possible, and replies go to ::0.0.0.0/96.
These replies can be captured using:
ip6tables -t mangle -A PREROUTING -m socket --transparent -j MARK --set-mark 1
ip -6 rule add fwmark 0x1 lookup 100
ip -6 route add local ::/96 dev lo table 100
With nftables in the table ip6 mangle chain PREROUTING: socket transparent 1 mark set 0x1 accept