Comments (1)
This is my iptables ruleset. Is this about the code or iptables ruleset?
I cannot see the change of the packet mark. Can you help me to fix it.
#!/bin/bash
echo 1 >| /proc/sys/net/ipv4/ip_forward
#echo 2 >| /proc/sys/net/ipv4/conf/all/rp_filter
iptables -F
iptables -t mangle -F
iptables -t mangle -X
iptables -t nat -F
iptables -t nat -X
# MARK 1 for WAN1
iptables -t mangle -N CONNMARK1
iptables -t mangle -A CONNMARK1 -j MARK --set-mark 1
iptables -t mangle -A CONNMARK1 -j CONNMARK --save-mark
# MARK 2 for WAN2
iptables -t mangle -N CONNMARK2
iptables -t mangle -A CONNMARK2 -j MARK --set-mark 2
iptables -t mangle -A CONNMARK2 -j CONNMARK --save-mark
#
iptables -t mangle -A PREROUTING -p tcp -s 192.168.0.0/16 ! -d 192.168.0.0/16 -m conntrack --ctstate ESTABLISHED,RELATED -j CONNMARK --restore-mark
# TCP LOADBALANCE
iptables -t mangle -A PREROUTING -p tcp -s 192.168.0.0/16 ! -d 192.168.0.0/16 -m conntrack --ctstate NEW -m statistic --mode random --probability 0.5 -j CONNMARK1
iptables -t mangle -A PREROUTING -p tcp -s 192.168.0.0/16 ! -d 192.168.0.0/16 -m conntrack --ctstate NEW -m mark --mark 0x0 -j CONNMARK2
# NON TCP LOADBALANCE
iptables -t mangle -A PREROUTING ! -p tcp -s 192.168.0.0/16 ! -d 192.168.0.0/16 -m statistic --mode random --probability 0.5 -j CONNMARK1
iptables -t mangle -A PREROUTING ! -p tcp -s 192.168.0.0/16 ! -d 192.168.0.0/16 -m mark --mark 0x0 -j CONNMARK2
# NFQUEUE
iptables -A FORWARD -i enp3s0 -o enp2s0 -j NFQUEUE --queue-balance 0:3
iptables -A FORWARD -i enp2s0 -o enp3s0 -j NFQUEUE --queue-balance 0:3
iptables -A FORWARD -i enp3s0 -o enp4s0 -j NFQUEUE --queue-balance 0:3
iptables -A FORWARD -i enp4s0 -o enp3s0 -j NFQUEUE --queue-balance 0:3
# NAT
iptables -t nat -A POSTROUTING -o enp2s0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o enp4s0 -j MASQUERADE
#
if ! cat /etc/iproute2/rt_tables | grep -q '^251'
then
echo '251 WAN1' >> /etc/iproute2/rt_tables
fi
if ! cat /etc/iproute2/rt_tables | grep -q '^252'
then
echo '252 WAN2' >> /etc/iproute2/rt_tables
fi
# ROUTING TABLE FOR WAN1
ip route flush table WAN1 2>/dev/null
ip route add table WAN1 default via 10.10.12.1 dev enp2s0
# ROUTING TABLE FOR WAN2
ip route flush table WAN2 2>/dev/null
ip route add table WAN2 default via 192.168.1.1 dev enp4s0
# FwMark Tables
ip rule del from all fwmark 0x1 lookup WAN1 2>/dev/null
ip rule del from all fwmark 0x2 lookup WAN2 2>/dev/null
ip rule del from all fwmark 0x2 2>/dev/null
ip rule del from all fwmark 0x1 2>/dev/null
ip rule add fwmark 1 table WAN1
ip rule add fwmark 2 table WAN2
#
ip route flush cache
#
from go-netfilter-queue.
Related Issues (10)
- Error when trying to compile HOT 2
- why not just use queueId as nfq.idx in function NewNFQueue HOT 1
- help me please HOT 7
- Dropping packets too often when measuring speed with iperf3
- call SetVerdictwithPacket the system hangup and cpu usage 100% HOT 1
- nfq.packets should have buffer
- redirect package to a different IP HOT 1
- unbuntu22.04 No package 'libnetfilter_queue' found
- There is no metadata in packet. packet.Packet.Metadata() is coming always like "&{{0001-01-01 00:00:00 +0000 UTC 0 0 0 []} false}"?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-netfilter-queue.