Re: simple source policy routing not working

Linux Advanced Routing and Traffic Control

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, I think that these rules could be work fine with you want to do,
you have to know gateway for network eth0 and wlan0.

eth0 192.168.1.10/24            ----> Example default Gateway   192.168.1.1
eth1 172.16.1.1/12               ----> LAN
wlan0 192.168.10.190/24      ----> Example default Gateway   192.168.10.1

Hi, I think that these rules could be work fine with you want to do,
you have to know gateway for network eth0 and wlan0.

eth0 192.168.1.10/24          ----> Default Gateway   192.168.1.1
eth1 172.16.1.1/12
wlan0 192.168.10.190/24       ----> Default Gateway   192.168.10.1


Rules

echo 100 T1 >> /etc/iproute2/rt_tables
echo 200 T2 >> /etc/iproute2/rt_tables

ip route add 192.168.1.0/24  dev eth0  src 192.168.1.10   table T1
ip route add 192.168.10.0/24 dev wlan0 src 192.168.10.190 table T1
ip route add default via 192.168.1.1 table T1

ip route add 192.168.1.0/24  dev eth0  src 192.168.1.10   table T2
ip route add 192.168.10.0/24 dev wlan0 src 192.168.10.190 table T2
ip route add default via 192.168.10.1 table T2

ip rule add from 172.30.230.230/32  table T2
ip rule add from 172.16.1.1/12      table T1

iptables -t nat -A POSTROUTING -o eth0  -j SNAT --to 192.168.1.10
iptables -t nat -A POSTROUTING -o wlan0 -j SNAT --to 192.168.10.190



Regards


On 2/21/07, Markus <lartc@xxxxxxxx> wrote:
Hi,

my box is connected to 3 networks, eth0 eth1 wlan0. I want "my" traffic to go
via wlan0 and everything from eth1 NATed to eth0:
eth0 192.168.1.10/24
eth1 172.16.1.1/12
wlan0 192.168.10.190/24

I first tried this with two single hosts:

iptables -A POSTROUTING -j MASQUERADE -o eth0 -t nat
iptables -A POSTROUTING -j MASQUERADE -o wlan0 -t nat

echo 200 Forw >> /etc/iproute2/rt_tables

ip rule add from 172.30.230.230 table Forw

ip route add 192.168.1.99 via 192.168.10.1 dev wlan0 table main
ip route add 192.168.1.99 dev eth0 table Forw

ip -statistics route flush cache

ip route get 192.168.1.98 from 172.30.230.230 iif eth1
#    192.168.1.98 from 172.30.230.230 dev eth0  src 172.16.1.1
#    cache <src-direct>  mtu 1492 advmss 1452 fragtimeout 64 iif eth1
ip route get 192.168.1.99 from 172.30.230.230 iif eth1
#    192.168.1.99 from 172.30.230.230 dev eth0  src 172.16.1.1
#    cache <src-direct>  mtu 1492 advmss 1452 fragtimeout 64 iif eth1
ip route get 192.168.1.98
#    192.168.1.98 dev eth0  src 192.168.1.10
#    cache  mtu 1492 advmss 1452 fragtimeout 64
ip route get 192.168.1.99
#    192.168.1.99 via 192.168.10.1 dev wlan0  src 192.168.10.190
#    cache  mtu 1500 advmss 1460 fragtimeout 64

Before 172.30.230.230 was able to ping 192.168.1.99 and 192.168.1.98, after
192.168.1.99 was unreacheable.

What's wrong? Please help...

Markus

_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc



--
"The network is the computer"
_______________________________________________
LARTC mailing list
LARTC@xxxxxxxxxxxxxxx
http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc

[Index of Archives]     [LARTC Home Page]     [Netfilter]     [Netfilter Development]     [Network Development]     [Bugtraq]     [GCC Help]     [Yosemite News]     [Linux Kernel]     [Fedora Users]
  Powered by Linux