I can set the mark for a packet in iptables mangle table by doing
iptables -t mangle -I PREROUTING -s 10.0.0.1 -j MARK --set-xmark 0x10/0xffffffff
This way I can mark the packets with source IP 10.0.0.1 only with 0x10, or any other random value.
But I want to mark the packets with source IP as 10.0.0.1 with different marks based on some dynamic variable on which I will mark.
Say at one point while sending the packet mark with 100, and when the variable value changes then the packet sent from that point will be marked with 200 and so on.
Since the dynamic variable is not a network parameter I can not use it in iptables to mark accordingly. Hence is there a way within my application while checking the dynamic variable, can I set a mark for that packet? My application is in golang. I am fine with other languages if there is a way.
User contributions licensed under CC BY-SA 3.0