LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 01-25-2011, 08:36 PM   #1
MediocreGopher
LQ Newbie
 
Registered: Apr 2009
Posts: 12

Rep: Reputation: 0
Creating a virtual interface to get more ephemeral ports (CentOS 5)


OS: CentOS 5.5 i386 Live CD (for testing purposes). Uses kernel 2.6.18-194.

I'm attempting to generate a boat-ton of connections (at least 100k) to a remote server. I wrote a script to do so (in erlang), it works fine. However, I run out of ephemeral ports and start getting address-in-use errors. I set my local port range to 1024-65535 (by echoing into /proc/sys/net/ipv4/ip_local_port_range), but that still maxes out at about 60k connections. From what I understand, opening up a new interface and giving it an ip address should work.

My problem is that I can't do so. Whenever I try I lose internet. Here's what usually happens:
Code:
[root@livecd ~]# curl --interface eth0 google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
[root@livecd ~]# /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:21:85:E5:0F:B6  
          inet addr:172.16.202.132  Bcast:172.16.202.255  Mask:255.255.255.0
          inet6 addr: fe80::221:85ff:fee5:fb6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:434562 errors:0 dropped:0 overruns:0 frame:0
          TX packets:916856 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:87592629 (83.5 MiB)  TX bytes:65593430 (62.5 MiB)
          Interrupt:90 Base address:0x4000 

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:16436  Metric:1
          RX packets:1556 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1556 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:128016 (125.0 KiB)  TX bytes:128016 (125.0 KiB)

[root@livecd ~]# /sbin/ifconfig eth0:1 172.16.202.135
[root@livecd ~]# /sbin/ifconfig
eth0      Link encap:Ethernet  HWaddr 00:21:85:E5:0F:B6  
          inet addr:172.16.202.132  Bcast:172.16.202.255  Mask:255.255.255.0
          inet6 addr: fe80::221:85ff:fee5:fb6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:434623 errors:0 dropped:0 overruns:0 frame:0
          TX packets:916900 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:87612074 (83.5 MiB)  TX bytes:65596722 (62.5 MiB)
          Interrupt:90 Base address:0x4000 

eth0:1    Link encap:Ethernet  HWaddr 00:21:85:E5:0F:B6  
          inet addr:172.16.202.135  Bcast:172.16.255.255  Mask:255.255.0.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          Interrupt:90 Base address:0x4000 

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:16436  Metric:1
          RX packets:1556 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1556 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:128016 (125.0 KiB)  TX bytes:128016 (125.0 KiB)

[root@livecd ~]# curl --interface eth0 google.com

[root@livecd ~]# curl --interface eth0:1 google.com

[root@livecd ~]#
The first two commands show that I have internet and what my setup is. The third sets up a new interface (I think), and the last ones show the results (the two curl commands timeout).

Am I not setting up the connection correctly? I've tried doing it with the /etc/sysconfig/network-scripts files as well, but still no luck.
 
Old 01-25-2011, 09:47 PM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Greetingz!

Sounds like you have a routing problem;

Code:
luser@lhost$ netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth0
0.0.0.0         192.168.1.1     0.0.0.0         UG        0 0          0 eth0
luser@lhost$
I'm running CentOS 5.5
Code:
luser@lhost$ uname -a ; cat /etc/*release
Linux lhost 2.6.18-194.8.1.el5 #1 SMP Thu Jul 1 19:04:48 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
CentOS release 5.5 (Final)
luser@lhost$
And that seems to work for me;

Code:
luser@lhost$ sudo ifconfig eth0:1 192.168.1.122 
luser@lhost$ ifconfig -a | grep eth0
eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
eth0:1    Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx

luser@lhost$ curl --interface eth0 google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
luser@lhost$ curl --interface eth0:1 google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
luser@lhost$

Last edited by xeleema; 01-25-2011 at 09:48 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
virtual com ports in ubuntu 10.04 ieatbunnies Linux - Newbie 3 06-13-2010 01:10 PM
Outgoing local trafic over virtual interface has not virtual ip address :-( tkmbe Linux - Networking 3 08-25-2009 08:03 PM
Adding virtual interface for IP based virtual host pridefc Linux - General 6 03-16-2008 03:52 PM
Creating new network interface jrtayloriv Linux - Networking 5 12-11-2006 11:10 PM
Creating Wireless Interface vfronda Linux - Newbie 1 12-03-2006 09:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 10:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration