I have a following mangle
table rule in a lab server which marks UDP traffic with 1
if the destination address is 6.6.6.6
:
$ sudo iptables -t mangle -L PREROUTING 2 -v -n --line-numbers
2 17 884 MARK udp -- ge-0.0.0-Iosv6 * 0.0.0.0/0 6.6.6.6 MARK set 0x1
$
6.6.6.6/32
is configured on lo
in that server. Each time I execute the traceroute
towards 6.6.6.6
, the rule counter above increases which is expected. In other words, the packets seem to get marked. My routing policy database looks like this:
$ ip rule show
0: from all lookup local
32764: from all fwmark 0x2 lookup twohundred
32765: from all fwmark 0x1 lookup threehundred
32766: from all lookup main
32767: from all lookup default
$
.. and the table threehundred
looks like this:
$ ip r sh table threehundred
default via 192.168.100.2 dev ge-0.0.0-Iosv6
$
However, the marked packets are not routed based on the entry in table threehundred
, but rather based on the entry in table main
. I can confirm with the tcpdump
, that the UDP packets ingress the server via ge-0.0.0-Iosv6
, but ICMP port unreachable
reply is sent out via eth0
which is associated with the default route in the main
table. As I mentioned earlier, the mangle
table PREROUTING
rule #2 is incremented during this.
What might cause such behavior? I'm running Ubuntu 16.04.6 LTS.