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
Internet
connection
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
details.
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.)
66.117.129.97: My Static External System Address - The real one visible
to the Internet.
192.168.1.4: My Local System Address
192.168.1.1: DSL Router Gateway Address
DNS1: 66.117.5.1
DNS2: 66.117.136.6
Note: Subnet Mask is 255.255.255.0
B) Dynamic IP Addresses - Associated with Modem Connection -
Assigned after PPP negotiation completion. (i.e. Associated
with /dev/ppp0.)
69.134.163.128: My Local System Address
67.193.208.12: Address of ISP IP Server on Internet Periphery
DNS1: 196.6.1.150
DNS2: 196.6.100.150
C) Static Address of SMTP Server being contacted.
65.200.205.193
/*
* Try to establish an TCP/IP/SMTP connection
* with local IP address 68.134.163.128--should
* be associated with /dev/ppp0.
*/
fd = dial_connect("68.134.163.128");
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:192.168.1.4 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::c0:f047:2c54/10 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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:127.0.0.1 Mask:255.0.0.0
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:68.134.163.128 P-t-P:67.193.208.12 Mask:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
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 * 255.255.255.255 UH 0 0 0 ppp0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
default router_gateway 0.0.0.0 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 65.200.205.193:smtp 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: