[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Multiple IP devices.

Hi Martin:

Let me clarify a few general things first.
My system has a static IP address and always has
an Internet connection via its Ethernet card--which is connected
to a DSL router. (i.e. /dev/eth0.)  Subsequently,  I made another
using  /dev/ttyS0 and a modem--via pppd--and have been
assigned a dynamic IP address by the ISP. (i.e. /dev/ppp0.)

The code I wrote attempts to use /dev/ppp0 to establish a TCP/SMTP
connection with an Internet server by binding to the dynamic address
assigned to my system by the ISP. It actually sends a TCP SYN
packet to the Internet server but via /dev/eth0 rather than /dev/ppp0.

The following files are attached to this note and contain the relevant

1) addresses:  The addresses used.
2) code: An annotated summary of my code.
3) route.out: The output of the route utility.
4) ifconfig.out: The output of the ifconfig utility.
5) netstat.out: The output of the netstat utility.

Best Regards,

Paul R.

PS: Am I replying to the right address ?

martin f krafft wrote:

> also sprach Paul Romero <paulr@rcom-software.com> [2005.05.12.0206 +0200]:
> > The PPP connection is configured such that it puts a default
> > route in the routing table.
> >
> > The problem is that I can not send TCP packets to any
> > IP node except the ISP node connected to the modem.
> > (i.e. The first one on the periphery of the Internet)
> Show us the output of
>   ip route
> or
>   /sbin/route -rn
> > Using the socket() and bind() calls I am able to coax connect() to
> > generate a TCP SYN packet with the right IP address etc. but, it
> > is still sent out over /dev/eth0.
> You just said they are always sent via the modem, didn't you?
> > How does one force packets to be
> > sent over /dev/ppp0 without bringing down
> > /dev/eth0 ?
> To override the source IP used (which is determined by the routing
> table and destination IP), you have to do just that: use bind() to
> "coax" it. Many tools (like ping, ssh, etc.) provide an option to do
> this.
> --
> Please do not send copies of list mail to me; I read the list!
>  .''`.     martin f. krafft <madduck@debian.org>
> : :'  :    proud Debian developer, admin, user, and author
> `. `'`
>   `-  Debian - when you have better things to do than fixing a system
> Invalid/expired PGP subkeys? Use subkeys.pgp.net as keyserver!
> this space intentionally left occupied.
>   ------------------------------------------------------------------------
>                        Name: signature.asc
>    signature.asc       Type: application/pgp-signature
>                 Description: Digital signature

Paul Romero

RCOM Communications Software

Phone/Fax: (510)339-2628
E-Mail: paulr@rcom-software.com
A) Default IP Addresses - Associated with the Ethernet Card - Always Up
(i.e. Associated with /dev/eth0.) My Static External System Address - The real one visible
                                                   to the Internet.  My Local System Address  DSL Router Gateway Address


Note: Subnet Mask is

B) Dynamic IP Addresses - Associated with Modem Connection -
Assigned after PPP negotiation completion. (i.e. Associated
with /dev/ppp0.) My Local System Address Address of ISP IP Server on Internet Periphery


C) Static Address of SMTP Server being contacted.

	 * Try to establish an TCP/IP/SMTP connection
	 * with local IP address
	 * be associated with /dev/ppp0.
	fd = dial_connect("");

int dial_connect(char *localip)
	 * Convert address to binary format and get local host data.
	 * Ths should correspond to /dev/ppp0
	ipadd = ui_ip_atoi(localip);
	hp = gethostbyaddr((char *) &ipadd, 4, AF_INET);
	memset((void *) &localadd, 0, sizeof(localadd));
	memcpy((void *) &localadd.sin_addr, hp->h_addr, hp->h_length);
	localadd.sin_port = 0;	/* Assume Port No. is irrelevant. */
	 * Do a DNS look up and obtain remote SMTP Server address etc.
	 * (i.e. Any valid DNS will work and the access media is
	 * irrelevant.)
	hp = gethostbyname("mail.imodem.net");
	memset((void *) &remadd, 0, sizeof(remadd));
	memcpy((void *) &remadd.sin_addr, hp->h_addr, hp->h_length);
	remadd.sin_port = htons(25);	/* SMTP Port No. */
	remadd.sin_family = AF_INET;
	 * Get a TCP socket.
	sock_fd = socket(PF_INET, SOCK_STREAM, 0);
	 * Bind the local address data to that socket--associated
	 * with /dev/ppp0.
	bind(sock_fd, (struct sockaddr *) &localadd, sizeof(localadd));
	 * Try to establish a TCP/SMTP connection to the
	 * mail.imodem.net server.
	 * This call just eventually times out--errno = 110.
	 * Furthermore, the TCP SYN packet is generated with
	 * the expected IP addresses but conveyed via /dev/eth0
	 * rather than /dev/ppp0. (i.e. Verified this with
	 * tcpdump);
	connect(sock_fd, (struct sockaddr *) &remadd, sizeof(struct sockaddr));

eth0      Link encap:Ethernet  HWaddr 00:C0:F0:47:2C:54  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::c0:f047:2c54/10 Scope:Link
          RX packets:284 errors:0 dropped:0 overruns:0 frame:0
          TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100 
          Interrupt:10 Base address:0xe000 

lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:3924  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 

ppp0      Link encap:Point-to-Point Protocol  
          inet addr:  P-t-P:  Mask:
          RX packets:194 errors:0 dropped:0 overruns:0 frame:0
          TX packets:96 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:10 

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
tnt23.sfo8.da.u *      UH    0      0        0 ppp0     *        U     0      0        0 eth0
default         router_gateway         UG    0      0        0 eth0

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      1 1Cust128.tnt23.sfo:1026     SYN_SENT    
Active UNIX domain sockets (w/o servers)
Proto RefCnt Flags       Type       State         I-Node Path
unix  1      [ ]         STREAM     CONNECTED     291    @00000009
unix  1      [ N ]       STREAM     CONNECTED     285    @00000008
unix  1      [ ]         STREAM     CONNECTED     743    @0000002d
unix  1      [ ]         STREAM     CONNECTED     215    @00000002
unix  1      [ ]         STREAM     CONNECTED     95     @00000001
unix  1      [ ]         STREAM     CONNECTED     269    @00000006
unix  1      [ ]         STREAM     CONNECTED     744    /dev/log
unix  1      [ ]         STREAM     CONNECTED     292    /tmp/.X11-unix/X0
unix  1      [ ]         STREAM     CONNECTED     286    /tmp/.X11-unix/X0
unix  1      [ ]         STREAM     CONNECTED     279    /tmp/.X11-unix/X0
unix  1      [ ]         STREAM     CONNECTED     216    /dev/log
unix  1      [ ]         STREAM     CONNECTED     96     /dev/log

Reply to: