Current ICMP hard codes its forwarding rules, and never applies any translations. Change it to use the fwd_nat_flow() function, so that it's translated the same as TCP (excluding TCP specific port redirection). This means that gw mapping now applies to ICMP so "ping <gw address>" will now ping the host's loopback instead of the actual gw machine. This removes the surprising behaviour that the target you ping might not be the same as you connect to with TCP. Signed-off-by: David Gibson <david(a)gibson.dropbear.id.au> --- icmp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/icmp.c b/icmp.c index 6a76d05..c960abf 100644 --- a/icmp.c +++ b/icmp.c @@ -172,7 +172,7 @@ static struct icmp_ping_flow *icmp_ping_new(const struct ctx *c, return NULL; flowside_from_af(tapside, pif, af, daddr, id, saddr, id); - flowside_from_af(sockside, PIF_HOST, af, NULL, 0, daddr, 0); + fwd_nat_flow(c, flow_proto[flowtype], tapside, sockside); pingf = FLOW_START(flow, flowtype, ping, TAPSIDE); -- 2.44.0