LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   activating a network interface (https://www.linuxquestions.org/questions/programming-9/activating-a-network-interface-253127/)

marri 11-10-2004 03:18 AM

activating a network interface
 
hi
I need to make a program that handles a single ethernet interface.
I have one PC and two ethernet cards in it. The first card (eth0) is used for internet connection but the other interface (eth1) is used for the second computer to allow it to connect to the internet through interface eth0.

The main task is to probe the network (eth1) card if somebody has connected to it, and if so open a pipe between eth0 and eth1.
Of course I would need to close it again.

I know that much of this sounds like a routing thing, but how can I easily monitor the card?.

regards

pycoucou 11-10-2004 09:06 AM

What you want is not really clear for me. Anyway, you want to do a masquerading, isn't it?

You should use iptables (kernel 2.4) to handle the different cases and properly forward the ports. As a consequence, the main computer would be transparent from your local network and your local network be invisible.

But, I may misunderstand your question. ..

Cheers,
PY

Peterius 11-10-2004 10:47 PM

In case the previous post didn't answer your question, a quick google search of something I recall reveals:

http://www.ibiblio.org/peanut/Kernel...ng/ifenslave.c

search it for "ifr.ifr_name" and you'll find a bunch of good stuff you can use as hints for further google searches or "man" page lookups.

Basically, you can, I think, set "ifr.ifr_name" in the struct ifreq to "eth0" or "eth1" and use that to get the "if_index" I think it is, that you set in one of them struct sockaddr, thingies.. then you can bind a socket to a particular interface/card and pick up things solely on that interface and conceivably, using the same method, place them on the other interface.


All times are GMT -5. The time now is 07:37 AM.