[Solved] IP rule table look up does not seem to work

Ashgang Asks: IP rule table look up does not seem to work
I have a sytem with three network interfaces. Below is the configuration that I’m trying to set up. wlan0 (its actually an WiFi AP interface) – other devices connects via this interface. net1 – interface facing internet that has to be linked to wlan0 to provide internet services to devices connected via wlan0. net0 – interface facing restricted internet access to answer queries only for requests from within this subnet.

The default interface is net0 and its gateway. The output of ip route show looks like this:

Code:
default via 10.228.103.241 dev net0
10.228.103.240/30 dev net0 src 10.228.103.242

Now I would like to system to look up table 7 for route rules for all requests to eth0 and

Code:
net1.  So I created ip rules as below:
0:      from all lookup local
32758:  from all lookup main
32762:  from 8.8.0.0/16 lookup iTbl
32764:  from 192.168.225.1 lookup iTbl
32765:  from 192.168.172.2 lookup iTbl
32767:  from all lookup default

8.8.0.0 is for nameservers. Its listed as iTbl because I have defined 7 as iTbl in /etc/iproute2/rt_tables.

ip route show for table 7 looks like this:

Code:
default via 192.168.172.3 dev net1
8.8.0.0/16 via 192.168.172.3 dev net1
192.168.172.0/24 dev net1  src 192.168.172.2
192.168.225.0/24 dev wlan0  src 192.168.225.1

And finally my iptables looks like this:

Code:
iptables -nvL
Chain INPUT (policy ACCEPT 245 packets, 49904 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination
    3   180 ACCEPT     all  --  wlan0   *       0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT 190 packets, 19182 bytes)
 pkts bytes target     prot opt in     out     source               destination

iptables -nvL -t nat
Chain PREROUTING (policy ACCEPT 22 packets, 2205 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain INPUT (policy ACCEPT 21 packets, 2145 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 91 packets, 7782 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain POSTROUTING (policy ACCEPT 90 packets, 7226 bytes)
 pkts bytes target     prot opt in     out     source               destination
    2   616 MASQUERADE  all  --  *      net1  0.0.0.0/0            0.0.0.0/0

When I connected a device to wlan0 interface and try to browse internet, tcpdump shows all the requests from wlan0 seem to go via net0, which actually has to go via net1 desirably. I read through many posts and forums. After trying different things I couldn’t solve the issue. I am not able to understand where its going wrong. From the tcpdump and logically looking at it, seems like the ip rule lookup to table 7 is not working. Please help to check if any of the rules has to be corrected.

Ten-tools.com may not be responsible for the answers or solutions given to any question asked by the users. All Answers or responses are user generated answers and we do not have proof of its validity or correctness. Please vote for the answer that helped you in order to help others find out which is the most helpful answer. Questions labeled as solved may be solved or may not be solved depending on the type of question and the date posted for some posts may be scheduled to be deleted periodically. Do not hesitate to share your response here to help other visitors like you. Thank you, Ten-tools.