LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 08-11-2023, 01:22 PM   #1
intmail01
Member
 
Registered: May 2013
Posts: 91

Rep: Reputation: Disabled
How to sent paket to a specific destination IP through a specific interface


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.255
When 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 Unreachable
tcpdump 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;


The main 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
 
Old 08-12-2023, 12:08 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,153

Rep: Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265Reputation: 1265
Why would you mangle? Just add a route to 8.8.8.8 via 11.0.0.1
 
1 members found this post helpful.
Old 08-13-2023, 11:02 AM   #3
intmail01
Member
 
Registered: May 2013
Posts: 91

Original Poster
Rep: Reputation: Disabled
Your route works, I did this:

Quote:
ip route add 8.8.8.8 via 11.0.0.1 ;
ip route del default via 11.0.0.1 dev eth1 ;


Quote:
Why would you mangle? Just add a route to 8.8.8.8 via 11.0.0.1
There are many IP address and some route depends also on port destination. I use mangling and IP SET feature to filter them.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Paket Manager do not work gundul3l3k Puppy 8 11-27-2011 09:56 AM
Shore wall make destination through interface john8675309 Linux - Networking 0 08-25-2006 09:09 PM
Iptables / routing to destination address through interface Xeta Linux - Networking 7 05-10-2006 03:17 PM
Paket Filtering (string) Bugger Linux - Security 7 01-11-2006 08:08 AM
"udftools paket writing drama" behmjose Linux - Software 0 06-02-2004 07:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration