6

I'll start out by saying networking isn't my strong suit, I'm trying to configure a few sub-interfaces so that some code I am working will have more sockets to locally bind to. So far i've done the following, I can locally bind to my sub interface 192.168.2.210, but I can not make a remote connection with it.

Here is my ifconfig:

eth0      Link encap:Ethernet  HWaddr 00:50:56:BB:00:0B  
          inet addr:10.6.19.18  Bcast:10.255.255.255  Mask:255.255.255.0
          inet6 addr: fe80::250:56ff:febb:b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1056026 errors:0 dropped:0 overruns:0 frame:0
          TX packets:638290 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:237037186 (226.0 MiB)  TX bytes:126161362 (120.3 MiB)

eth0:1    Link encap:Ethernet  HWaddr 00:50:56:BB:00:0B  
          inet addr:192.168.2.210  Bcast:192.168.2.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

Here is what i've tried to do to configure eth0:1

ifconfig eth0:1 192.168.2.210/32 up
ip route add 192.168.2.210/32 via 10.6.19.18

Here is my netstat -r output:

192.168.2.210   devserv.        255.255.255.255 UGH       0 0          0 eth0
192.168.2.0     *               255.255.255.0   U         0 0          0 eth0
10.6.19.0       *               255.255.255.0   U         0 0          0 eth0
link-local      *               255.255.0.0     U         0 0          0 eth0
default         10.6.19.1       0.0.0.0         UG        0 0          0 eth0

Any thoughts? Thanks for looking

4
  • 4
    Please clarify what youre trying to do a bit more. Youre adding 192.168.2.210/32 which means that IP address has no network. The /32 netmask says that its the only IP address in the subnet. Also youre adding a route to say that traffic to that IP should go out your 10.6.19.18 address. This doesnt make any sense. Why would you add a route to an IP that is on the server itself? If you can provide more info about what youre trying to accomplish, we can probably help more.
    – phemmer
    May 15, 2012 at 12:14
  • "some code I am working will have more sockets to locally bind to" - note that there is an OS-imposed limit of sockets per process, which you may be able to increase, but adding more interfaces won't help unless you really need more than 60,000 sockets...
    – pjc50
    May 15, 2012 at 12:26
  • I need to be able to bind to 600,000 unique local socket pairs and establish a connection on each to a remote system. A previous system I was working on already had this networking setup using 12 sub interfaces (binding on ports 10,000-60,000 for each interface), I no longer have access to this particular server and I just need to recreate the networking configuration.
    – RandomUser
    May 15, 2012 at 12:31
  • You need more ip numbers from your real net, that is eth0:0 => 10.6.19.19, eth0:1 => 10.6.19.20 and so on. I wonder if they are available for you tho. You don't need to set routes then.
    – ott--
    May 15, 2012 at 15:05

3 Answers 3

5

Ditch ifconfig as this is being phased out for the iproute2 package;

root@bensley-n2:~# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:e0:4c:6d:0a:49 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 74:ea:3a:ad:2e:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.5/24 brd 192.168.0.255 scope global wlan0
    inet6 fe80::76ea:3aff:fead:2e00/64 scope link 
       valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether ce:70:78:f8:10:75 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
root@bensley-n2:~# ip address add 1.1.1.1/24 dev wlan0
root@bensley-n2:~# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 00:e0:4c:6d:0a:49 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 74:ea:3a:ad:2e:00 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.5/24 brd 192.168.0.255 scope global wlan0
    inet 1.1.1.1/24 scope global wlan0
    inet6 fe80::76ea:3aff:fead:2e00/64 scope link 
       valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether ce:70:78:f8:10:75 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
root@bensley-n2:~# ip route show
default via 192.168.0.1 dev wlan0 
1.1.1.0/24 dev wlan0  proto kernel  scope link  src 1.1.1.1 
192.168.0.0/24 dev wlan0  proto kernel  scope link  src 192.168.0.5 
192.168.122.0/24 dev virbr0  proto kernel  scope link  src 192.168.122.1

(You can abbreviate the ip commands: ip address add can be shortened all the way down to ip a a, and ip address show can be shortened to ip a s. show is the default action if you don't specify the second argument, so you can just type ip a if you want to be really terse.)

You don't need to add a route either for a local subnet.

1

Firstly, sockets aren't actually bound to an interface -- they're bound to an IP address. Virtual/alias interfaces are deprecated and should be avoided -- you should rather add multiple IP addresses directly to eth0. Secondly, if you want these addresses to be routable on the local network you need to use addresses on that network (i.e. 10.6.19.0/24) and not a machine-local subnet like 192.168.2.0/24 (unless you can get the router or the remote machines reconfigured with this other subnet). To add additional address, use the following command:

ip addr add 10.6.19.19/24 dev bond0

You shouldn't require any additional routing configuration since the addresses are on an existing subnet.

0

Rather than adding more addresses, which is going to get a little complicated, why dont your sockets use different ports?

2
  • I need to bind a total of 600,000 sockets, I bind on port 10,000 - 60,000 for each interface, I need 12 of these sub interfaces so I can reach my total.
    – RandomUser
    May 15, 2012 at 12:35
  • Then you need to add a gateway on the same subnet, ie in the 192.168.2.0/24. What route does the 'remote' machine take to get to this network? If it is via the 10.6.19.0/24 youll have to enable ip forwarding on this server too. But 600,000 open sockets and routing... ouch.
    – Sirch
    May 15, 2012 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .