I have a OpenVPN Server on a MultiWAN Router (Ubuntu Based). The Problem is, that incoming packages not leaving the same WAN interface where they entered. I tested already with iptables MARK rules in combination with ip rules, but could not fix the problem. I know, I can define on the openvpn configuration with local 79.1.2.3
the outgoing ip, but I want it more flexible if possible. The OpenVPN Port Protocol is UDP if it matters.
$ ip r s|grep default
default via 83.1.2.3 dev vlan254 metric 1
default via 79.1.2.3 dev ppp0 metric 2
default via 192.168.0.251 dev vlan10 metric 3 onlink
$ ip rule s
0: from all lookup local
100: from all fwmark 0x1 lookup uplink1
101: from 83.1.2.3 lookup uplink1
102: from all to 83.1.2.3 lookup uplink1
200: from all fwmark 0x2 lookup uplink2
201: from 79.1.2.3 lookup uplink2
300: from all fwmark 0x3 lookup uplink3
301: from 192.168.0.254 lookup uplink3
302: from all to 192.168.0.254 lookup uplink3
32766: from all lookup main
32767: from all lookup default
# iptables -L -vn -t mangle
Chain PREROUTING (policy ACCEPT 4785K packets, 5178M bytes)
pkts bytes target prot opt in out source destination
4785K 5178M CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 CONNMARK restore
3985K 5035M RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 mark match ! 0x0
351 46210 MARK all -- vlan254 * 0.0.0.0/0 0.0.0.0/0 MARK set 0x1
3865 242K MARK all -- ppp0 * 0.0.0.0/0 0.0.0.0/0 MARK set 0x2
351 46210 CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x1 CONNMARK save
3865 242K CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x2 CONNMARK save
Chain INPUT (policy ACCEPT 1658K packets, 1114M bytes)
pkts bytes target prot opt in out source destination
Chain FORWARD (policy ACCEPT 3127K packets, 4063M bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 1534K packets, 1241M bytes)
pkts bytes target prot opt in out source destination
1534K 1241M CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 CONNMARK restore
657K 103M RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 mark match ! 0x0
0 0 MARK udp -- * * 0.0.0.0/0 0.0.0.0/0 udp spt:55394 MARK set 0x2
0 0 CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x1 CONNMARK save
0 0 CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 mark match 0x2 CONNMARK save
Chain POSTROUTING (policy ACCEPT 4639K packets, 5303M bytes)
pkts bytes target prot opt in out source destination
4639K 5303M CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 CONNMARK restore
3743K 4164M RETURN all -- * * 0.0.0.0/0 0.0.0.0/0 mark match ! 0x0
90 7560 MARK all -- * vlan254 0.0.0.0/0 0.0.0.0/0 MARK set 0x1
57161 3664K MARK all -- * ppp0 0.0.0.0/0 0.0.0.0/0 MARK set 0x2
896K 1140M CONNMARK all -- * * 0.0.0.0/0 0.0.0.0/0 CONNMARK save
So, the incomming packets comes from uplink2, but leaves uplink1 (the default gw).
Any Idea how I can solve my problem?