← Back to team overview

sslug-teknik team mailing list archive

Re: iptables, hvordan undlades flere subnets ved nat ?

 

> Det er bare ikke muligt med masqaerade :(
>
> Når der først er lavet én regel der tillader noget kan du ikke 'pille
> noget ud af den igen'
>
> Det er netop mit problem :(

OK, jeg kan se hvad du mener.

Der er kommet et andet forslag med "return" som ser godt ud, men jeg vil
lige nævne at du kan mærke pakkerne. Dvs du kan bruge regler til at mærke
pakkerne, og så derefter reagere på mærket. Jeg kan desværre ikke huske
syntaksen, men har et link til dig. nedenstående er taget fra lartc.org

God fornøjelse

/kallenberg

http://lartc.org/howto/lartc.netfilter.html

As an example, this command marks all packets destined for port 25,
outgoing mail:

# iptables -A PREROUTING -i eth0 -t mangle -p tcp --dport 25 \
 -j MARK --set-mark 1

Let's say that we have multiple connections, one that is fast (and
expensive, per megabyte) and one that is slower, but flat fee. We would
most certainly like outgoing mail to go via the cheap route.

We've already marked the packets with a '1', we now instruct the routing
policy database to act on this:

# echo 201 mail.out >> /etc/iproute2/rt_tables
# ip rule add fwmark 1 table mail.out
# ip rule ls
0:	from all lookup local
32764:	from all fwmark        1 lookup mail.out
32766:	from all lookup main
32767:	from all lookup default

Now we generate a route to the slow but cheap link in the mail.out table:

# /sbin/ip route add default via 195.96.98.253 dev ppp0 table mail.out




References