[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 501
  • Last Modified:

500: ppp0 to eth0

Hi,

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".
BUT
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?
Thanks
0
smotbd
Asked:
smotbd
  • 4
  • 4
1 Solution
 
nociSoftware EngineerCommented:
You probably refer to

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

like:

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.
0
 
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!
0
 
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!



0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
or
   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.
0
 
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.
0
 
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...
0
 
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!!)




0
 
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 172.16.1.25 dev eth0

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

0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now