Solved

500:  ppp0 to eth0

Posted on 2006-07-17
8
472 Views
Last Modified: 2010-08-05
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
Comment
Question by:smotbd
  • 4
  • 4
8 Comments
 
LVL 39

Expert Comment

by:noci
ID: 17122722
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
 

Author Comment

by:smotbd
ID: 17123500
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
 

Author Comment

by:smotbd
ID: 17123595
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
 
LVL 39

Expert Comment

by:noci
ID: 17124600
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 39

Expert Comment

by:noci
ID: 17124610
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
 

Author Comment

by:smotbd
ID: 17130816
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
 

Author Comment

by:smotbd
ID: 17137036
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
 
LVL 39

Accepted Solution

by:
noci earned 500 total points
ID: 17142417
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This video discusses moving either the default database or any database to a new volume.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now