Article 6DRYJ How to sent paket to a specific destination IP through a specific interface

How to sent paket to a specific destination IP through a specific interface

by
intmail01
from LinuxQuestions.org on (#6DRYJ)
Hi,

I want to use 2 interfaces and some packet must be route through eth1.
Let say packets to 8.8.8.8 must be sent through eth1 and others through wlan0. The gateway for eth1 is 11.0.0.1 and gateway for wlan0 is 10.0.0.1
I want to know how to do this because my mangling and routing method did not work.

These are interfaces configuration :
Code: eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 11.0.0.6 netmask 255.255.255.255 broadcast 0.0.0.0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.3 netmask 255.0.0.0 broadcast 10.255.255.255When I ping 8.8.8.8 there is nothing come back through eth1:
Code: bash-5.1# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 10.0.0.3 icmp_seq=358 Destination Host Unreachable
From 10.0.0.3 icmp_seq=359 Destination Host Unreachable
From 10.0.0.3 icmp_seq=360 Destination Host Unreachable
From 10.0.0.3 icmp_seq=361 Destination Host Unreachabletcpdump display that the target IP doesnt respond and the strange thing is why ip source is not the desired IP 11.0.0.6:
Code: bash-5.1# tcpdump -i eth1
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth1, link-type EN10MB (Ethernet), snapshot length 262144 bytes
20:21:56.883943 IP 10.0.0.3 > 8.8.8.8: ICMP echo request, id 8509, seq 26, length 64
20:21:57.907777 IP 10.0.0.3 > 8.8.8.8: ICMP echo request, id 8509, seq 27, length 64
Other commands I set:

ip rule add fwmark 6 table 6;

I delete eth1 route from main table to avoid 2 routes:
ip route del default via 11.0.0.1 ;

ip route add 11.0.0.0/24 dev eth1 table 6 ;
ip route add 11.0.0.1 via 11.0.0.6 dev eth1 table 6 ;
ip route add 0.0.0.0/1 via 11.0.0.1 dev eth1 table 6 ;
ip route add default via 11.0.0.1 dev eth1 table 6 ;

iptables -t mangle -I OUTPUT 1 -d 8.8.8.8 -j MARK --set-mark 6 ;

ip route flush cache;

Themain table:

Code: bash-5.1# ip route
default via 10.0.0.1 dev wlan0 proto static metric 600
10.0.0.0/8 via 10.0.0.3 dev wlan0
10.0.0.0/8 dev wlan0 proto static scope link metric 600
10.0.0.0/8 dev wlan0 proto kernel scope link src 10.0.0.3 metric 600
11.0.0.0/24 dev eth1 proto static scope link metric 100
127.0.0.0/8 dev lo scope link
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments