LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-29-2004, 09:12 AM   #1
dravya
LQ Newbie
 
Registered: May 2004
Posts: 23

Rep: Reputation: 15
Question How to send icmp packets on a particular interface?


Hi all,

I have a system setup with two phones/ interfaces (ppp0 and ppp1). I access the internet via these two interfaces only.

The problem is that there are times when a packet with the ip address of ppp0 goes over ppp1 and vice-versa. For example, when a machine (with my machine as the gateway) pings a website outside, I get a change of ip address, meaning that the packet went on the wrong link. Any ideas??? What part of the kernel code deals with this?

I want to be able to send these pings on a particular interface (src add of packet should be same as ip add of interface (ppp0 or ppp1)).

I am a total newbie to the kernel code. I would greatly appreciate it if someone could give me a starting point or any suggestions would be great.

Thank you all

Dravya
 
Old 07-29-2004, 10:00 AM   #2
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
Firstly i should write out what i understand.. Your machine is gateway of your internal network and you want to route the packets coming from your internal network and going to internet by changing the original source IP address with your machine's IP address. And also doing the reverse when you get a packet coming from internet. Right?

If so, you can use iptables for changing the source address of packets going to internet via one interface of your machine. Read the source NAT documentation at www.netfilter.org

http://www.netfilter.org/documentati...O-6.html#ss6.1

Since you're using ppp interface (dynamic IP), also read the masquerading part. It's easier with masquerading when your IP is not static. Hope this helps.
 
Old 07-29-2004, 02:30 PM   #3
dravya
LQ Newbie
 
Registered: May 2004
Posts: 23

Original Poster
Rep: Reputation: 15
>Firstly i should write out what i understand.. Your machine is gateway of your internal >network and you want to route the packets coming from your internal network and going to >internet by changing the original source IP address with your machine's IP address. And >also doing the reverse when you get a packet coming from internet. Right?

Yes you are exactly right.

Thank you ver much for the links. I checked them out and as it turns out I have the exact rules in my iptables:

iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE
iptables -t nat -A POSTROUTING -o ppp1 -j MASQUERADE

and yet when a machine on my network uses my machine as the gateway to ping outside, packets travel on the wrong link causing change of ip address of the phones. I have tested this using ethereal and it clearly shows a ppp0 packet (src add of ppp0) outgoing on ppp1, as I was capturing on ppp1. Also, iptables is masquerading as it shows the number of packets it masqueraded.

Isn't iptables the last thing before the packet actually goes on the wire??? Even if ip_route_output() gives me the wrong link shouldn't iptables be able to overright it??

I am in a big dillema.... and help is really welcome.

Thanks again

dravya
 
Old 07-29-2004, 04:15 PM   #4
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
Quote:
Originally posted by dravya
Isn't iptables the last thing before the packet actually goes on the wire??? Even if ip_route_output() gives me the wrong link shouldn't iptables be able to overright it??

dravya
Yes, i also know like that.. iptables can control the packets just before they hit the wire and postrouting is done at this step. But iptables can overright (or alter) the packets matched with it's rules only. There can be any other rule in your nat table doing somethind weird. Like routing between ppp0 and ppp1 interfaces for example.. No idea except this possibility.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
ICMP Packets coolfrog Linux - Networking 4 12-22-2004 11:10 AM
dropping of ICMP packets from martian sources kishku Linux - Networking 2 10-19-2004 08:06 PM
Interpret ICMP packets SaTaN Linux - Networking 1 01-20-2004 10:23 PM
DENY ICMP Packets joseph Linux - Software 1 10-08-2003 10:03 PM
Port 0 (icmp,eth0,input) 7 packets wfhoney Linux - Security 3 09-02-2003 03:10 PM


All times are GMT -5. The time now is 12:22 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration