Michael's musings


This is a blog of
mcr at sandelman.ca

Mon, 22 Nov 2010

Ruby has problems with getaddrinfo(3)

Today I was trying to deploy some rails code to a host with both an RFC1918 and IPv6 address. The RFC1918 address is only valid within my CREDIL office, while the IPv6 is globally unique. When I'm in the office, IPv4 or IPv6 is fine, when I'm not, then it has to be IPv6.

With other applications when I do this, I sometimes get a delay as it tries the RFC1918 address, fails and tries IPv6 instead. SSH works great like this.

Ruby 1.8 (at least) fails: the RFC1918 address does not connect, and then ruby gives up. This makes Capistrano fail.

Capistrano uses Net::SSH, which calls TCPSocket.open. This is implemented in C code in the ruby interpreter. My reading of ruby-1.9.2-p0/ext/socket/ipsocket.c suggests that it might be okay in ruby 1.9, but I didn't look at the 1.8 code yet, and I haven't tried ruby 1.9.p

The following code exercises the problem, but you need to have an address which is both IPv6 and IPv4. It also does not seem to be consistent: it seems to depend on the network activity a bit. In theory, /etc/gai.conf can change the order that is returned, but I suspect that ruby is not using the system getaddrinfo(3).

% cat socktest.rb require 'socket' require 'timeout' factory = TCPSocket n = factory.open("sakura.gatineau.credil.org", 22) puts n.readlines n.close



posted at: 23:10 | path: /ipv6 | permanent link to this entry

Tue, 24 Aug 2010

Netgear IPv6-enabled l2/l3 switches

Netgear makes a relatively inexpensive managed switch, the FSM-726 (300). It's a 24-port 10/100 switch with two 1000/SPF combo ports.

The latest firmware for it is IPv6 capable, and I think they deserve some kudos. I haven't tried it as an IPv6 router, but you can manage it over IPv6.

FSM726V3) #show network

Interface Status............................... Always Up
IP Address..................................... 10.9.7.16
Subnet Mask.................................... 255.255.255.0
Default Gateway................................ 10.9.7.1
IPv6 Administrative Mode....................... Enabled
IPv6 Prefix is ................................ FE80::226:F2FF:FEAB:B0F2/64
IPv6 Prefix is ................................ 5001:abcd:ef01:2:226:F2FF:FEAB:B0F2/64
IPv6 Default Router............................ FE80::250:BAFF:FE2E:7AF1
Burned In MAC Address.......................... 00:26:F2:AB:B0:F2
Locally Administered MAC address............... 00:00:00:00:00:00
MAC Address Type............................... Burned In
Configured IPv4 Protocol....................... DHCP
Configured IPv6 Protocol....................... None
IPv6 AutoConfig Mode........................... Enabled
Management VLAN ID............................. 1

(Yes, I have obsured the IPv6 address, since yes, actually, you can get to this device from the Internet. Note in the picture that you have to put [] around literal IPv6 addresses in most browsers)

I was also able to copy the configuration to another host via SCP over IPv6:

(FSM726V3) #copy nvram:startup-config  scp://roster@5001:abcd:ef01:1:216:3eff:fe86:6f45/home/roster/fscm726-v3.cfg
Remote Password:********

Mode........................................... SCP
Set Server IP.................................. 5001:abcd:ef01:1:216:3eff:fe86:6f45
Path........................................... home/roster/
Filename....................................... fscm726-v3.cfg
Data Type...................................... Text Configuration

Management access will be blocked for the duration of the transfer
Are you sure you want to start? (y/n) y

File transfer operation completed successfully.


In production, I will have the management interfaces on IPv6 networks, which will not be globally announced. Why is this better than 10. network addressing? because the addresses are unique, regardless of where you go.



posted at: 19:42 | path: /ipv6 | permanent link to this entry


XML


February
Sun Mon Tue Wed Thu Fri Sat
      4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
2012
Months
FebMar
Apr May Jun
Jul Aug Sep
Oct Nov Dec