500: ppp0 to eth0


I have set up 2 network cards, each with an individual IP address.

I also have a script that forwards all incoming traffic on "port a" to "port b".
I now want the script to port forward data from ppp0, port a ---->to------> eth0, port b.

How do I define whether it's ppp0 or eth0 I want the data to come from and go to?
Data can only come from ppp0 (3G card)
AND data can only go to LAN through eth0.

Understand? any clues?
Who is Participating?
nociSoftware EngineerCommented:
How to add to the permanent, depends on your distro....

in RH: /etc/sysconfig/network/routes (IIRC) or something very close to it.
in Suse some like wise file.

an example:

route add -host dev eth0

so no " and no < or > just the ip address.

nociSoftware EngineerCommented:
You probably refer to

iptables filter rules, then -i  & -o specify the input & output interface for a FORWARD rule.


iptables -I FORWARD -i ppp0 -o eth0 -p tcp --dport 25 -j ACCEPT        

- would allow SMTP to pass on.
If this is not enough then please provide more details about what you want to pass on.
smotbdAuthor Commented:
Well, I don't want to use iptables. I have written a PHP code that forwards data coming in on port a to port b.
This works fine if using just one network interface i.e. 3G card or ethernet. BUT I want to use both 3G and ethernet because I want a 3G connection for mobility and then have an ethernet connection from the mobile PC to another PC. So basically I want to forward data from my mobile PC to my other PC linked via ethernet. My PHP is running on my mobile PC and my other PC is listening a particular port for this data. The PHP does forward to port B of the other PC IP address but how will it know to use eth0 and not ppp0. Obviously only eth0 will have access to other PC as other PC not on internet(only connected to mobile PC) so how can I say - use eth) to forward data to tother PC? Will I need to or will it just try to network interface??

Thanks....bit confusing I know!
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

smotbdAuthor Commented:
OK, what I should ask is this to make it simpler(same thing):
I have a PHP client running on a PC(call it PC1) that connects to two servers listening on a particular port.
This PC1 has a 3G card and an ethernet connection.
I want one connection to a server using 3G and another connection using ethernet.
I can get PHP to connect to both servers via 3G individually or via ethernet individuall......BUT..........

How do I get the PHP client to connect to server 1 via 3G and server 2 via ethernet? That is my problem!

nociSoftware EngineerCommented:
the the connecting part is simple:
  you connect to the intended node by IP, the IP routing layer should solve this for you
  just specify the address of the target.

If you need a specific route just add a host route:
   route add -host <ipaddress> dev eth0
   route add -host <ipaddress> dev ppp0

If you need to listen on a specific port try to "socket_bind" your socket to an address and port.
Use the ipaddress of the intended interface.
nociSoftware EngineerCommented:
BTW the route add's are not permanent, as given they work until reboot or
update of routing tables. with route add/del statements.
smotbdAuthor Commented:
Thanks noci.......

Not by my PC for couple of days but will try end of week and will get back to you.
Think your suggestions should work...
smotbdAuthor Commented:
So how would I make the 'route add....' pernament??? I need it to be pernament.

What do you mean by "-host <ipaddress>" ?? Is all that in the "" just the ip address.
Do I use "<" and ">" ?

Can you give example please so I can try it out when I'm by my linux PC tomorow.

Many thanks....(my linux skills is very ameture sorry!!)

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.