Socket connection between multiple interfaces, through a router

S

seets375

Hi,

I have two ethernet interfaces on my system, with IPs assigned to the
interfaces from different subnets (e.g. eth1 - 10.10.10.10 and eth2 -
20.20.20.20 ). I'm connecting these interfaces to a home gateway or
router. The 'eth1' interface connects to LAN interface of the router
with IP address 10.10.10.1 and the 'eth2' interface connects to WAN
interface of the router with IP address 20.20.20.1.

I'm trying a simple socket program with C on Redhat Linux 9. I'm trying
to create a server socket (UDP or TCP) on my eth2 interface
(20.20.20.20), and a client socket (UDP or TCP) on my eth1 interface
(10.10.10.10). When I try to connect and send packets from eth1 to eth2
or vice-versa, the packets do not seem to pass through the router and
instead seem to create a local connection within the system. I verified
this with ethereal on both the interfaces eth1 and eth2). I wasn't
seeing any packets on these interfaces.

Just FYI, I was using AF_INET address family. I have routes
appropriately setup for the interfaces with 10.10.10.1 as the gateway
on the LAN side, and 20.20.20.1 as the gateway on the WAN side.

Why does the socket connection bypass the router? Is there a way to
ensure that my socket connection goes through the router, instead of
creating a local connection?

I'd appreciate if any one could help me with the solution to my above
problem, either with explanation or through sample code.

Thanks,
Seets.
 
B

Ben Pfaff

Why does the socket connection bypass the router? Is there a way to
ensure that my socket connection goes through the router, instead of
creating a local connection?

Your question is outside the domain of comp.lang.c, which discusses
only the standard C programming language, including the standard C
library. This is a remarkably narrow topic compared to what many
people expect.

For your convenience, the list below contains topics that are not
on-topic for comp.lang.c, and suggests newsgroups for you to explore
if you have questions about these topics. Please do observe proper
netiquette before posting to any of these newsgroups. In particular,
you should read the group's charter and FAQ, if any (FAQs are
available from www.faqs.org and other sources). If those fail to
answer your question then you should browse through at least two weeks
of recent articles to make sure that your question has not already
been answered.

* OS-specific questions, such as how to clear the screen,
access the network, list the files in a directory, or read
"piped" output from a subprocess. These questions should be
directed to OS-specific newsgroups, such as
comp.os.ms-windows.programmer.misc, comp.unix.programmer, or
comp.os.linux.development.apps.

* Compiler-specific questions, such as installation issues,
locations of header files, configuring your C development
environment, or choosing or managing profiling tools,
debuggers, or code coverage tools. Ask about these in
compiler-specific newsgroups, such as gnu.gcc.help or
comp.os.ms-windows.programmer.misc. Questions about writing
compilers are appropriate in comp.compilers.

* Library-specific questions, such as how to use GLib, Kazlib,
libavl, libsndfile, GMP, GNU GSL, djbfft, CLAPACK, CBLAS,
libtomcrypt, etc. Ask about these in library-specific
newsgroups or mailing lists.

* Processor-specific questions, such as questions about
assembly and machine code. x86 questions are appropriate in
comp.lang.asm.x86, embedded system processor questions may
be appropriate in comp.arch.embedded.

* ABI-specific questions, such as how to interface assembly
code to C. These questions are both processor- and
OS-specific and should typically be asked in OS-specific
newsgroups.

* Algorithms, except questions about C implementations of
algorithms. "How do I implement algorithm X in C?" is not a
question about a C implementation of an algorithm, it is a
request for source code. Newsgroups comp.programming and
comp.theory may be appropriate.

* Making C interoperate with other languages. C has no
facilities for such interoperation. These questions should
be directed to system- or compiler-specific newsgroups. C++
has features for interoperating with C, so consider
comp.lang.c++ for such questions.

* The C standard, as opposed to standard C. Questions about
the C standard are best asked in comp.std.c.

* C++. Please do not post or cross-post questions about C++
to comp.lang.c. Ask C++ questions in C++ newsgroups, such
as comp.lang.c++ or comp.lang.c++.moderated.

* Test posts. Please test in a newsgroup meant for testing,
such as alt.test.

news.groups.questions is a good place to ask about the appropriate
newsgroup for a given topic.
 
K

Keith Thompson

I have two ethernet interfaces on my system, with IPs assigned to the
interfaces from different subnets (e.g. eth1 - 10.10.10.10 and eth2 -
20.20.20.20 ). I'm connecting these interfaces to a home gateway or
router. The 'eth1' interface connects to LAN interface of the router
with IP address 10.10.10.1 and the 'eth2' interface connects to WAN
interface of the router with IP address 20.20.20.1. [...]
I'd appreciate if any one could help me with the solution to my above
problem, either with explanation or through sample code.

Standard C has no networking support. Try comp.unix.programmer or one
of the Linux groups.
 
S

seets375

Sorry for posting to the wrong groups. And thanks for pointing me to
the right ones.

Thanks,
Seets.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top