From owner-freebsd-net@FreeBSD.ORG Sun Mar 31 19:39:32 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id AEAEB283 for ; Sun, 31 Mar 2013 19:39:32 +0000 (UTC) (envelope-from richard@tector.org.uk) Received: from mx0.thekeelecentre.com (mx0.thekeelecentre.com [88.98.64.52]) by mx1.freebsd.org (Postfix) with ESMTP id 722BAC00 for ; Sun, 31 Mar 2013 19:39:31 +0000 (UTC) Received: from filter.mx0.thekeelecentre.com (unknown [88.98.64.55]) by mx0.thekeelecentre.com (Postfix) with ESMTP id E141FB94D for ; Sun, 31 Mar 2013 20:33:33 +0100 (BST) X-Virus-Scanned: amavisd-new at thekeelecentre.com Received: from mx0.thekeelecentre.com ([88.98.64.52]) by filter.mx0.thekeelecentre.com (filter.mx0.thekeelecentre.com [88.98.64.55]) (amavisd-new, port 10024) with ESMTP id OwVX7YDZweuK for ; Sun, 31 Mar 2013 19:33:32 +0000 (UTC) Received: from [10.0.2.13] (nat-gw.hl.tector.org.uk [88.96.67.61]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mx0.thekeelecentre.com (Postfix) with ESMTPSA id E410CB921 for ; Sun, 31 Mar 2013 20:33:31 +0100 (BST) Message-ID: <51588F43.7060609@tector.org.uk> Date: Sun, 31 Mar 2013 20:32:19 +0100 From: Richard Tector User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130307 Thunderbird/17.0.4 MIME-Version: 1.0 To: freebsd-net@freebsd.org Subject: Route next-hop interface behaviour Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 31 Mar 2013 19:39:32 -0000 Hi, I'm not sure if it is expected behaviour but when configuring a static route (default or otherwise) the outbound interface recorded in the table does not update when the system's IP changes interface, even when removing and re-adding it. Fairly simple topology, system running 9.1-STABLE (30th March) with just one of four 'em' interfaces in use - em0 with 10.0.2.199. Default route to 10.0.2.1. Whilst troubleshooting some odd TCP behaviour I thought I'd try a different interface and so downed the active interface and brought up one on a PCI card, and swapped the cable over: # ifconfig em0 down # ifconfig em2 inet 10.0.2.199/24 # ifconfig em2 up ##### If I then ping an external host it shows as the destination network being inaccessible: root@daffy:~ # ping 212.23.6.76 PING 212.23.6.76 (212.23.6.76): 56 data bytes ping: sendto: Network is down ##### Can contact the next hop just fine: root@daffy:~ # ping 10.0.2.1 PING 10.0.2.1 (10.0.2.1): 56 data bytes 64 bytes from 10.0.2.1: icmp_seq=0 ttl=64 time=0.211 ms ##### Routing table shows that the default route is still bound to em0 even though the next hop is on em2: root@daffy:~ # netstat -rfinet -n Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.0.2.1 UGS 0 3141 em0 ^^^ 10.0.2.0/24 link#4 U 1 255 em2 10.0.2.199 link#1 UHS 1 0 lo0 127.0.0.1 link#9 UH 0 0 lo0 ##### Removing the default route and re-adding also leaves it on the old interface: root@daffy:~ # route delete default delete net default root@daffy:~ # route add default 10.0.2.1 add net default: gateway 10.0.2.1 root@daffy:~ # netstat -rfinet -n Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.0.2.1 UGS 0 0 em0 10.0.2.0/24 link#4 U 0 688 em2 10.0.2.199 link#1 UHS 1 0 lo0 127.0.0.1 link#9 UH 0 0 lo0 I can understand the initial problem, but surely when I re-add the route it should do a lookup against the table for the next hop, ie. 10.0.2.0/24, and use the associated Netif? What's interesting is that if I remove the IP configuration from em0 it removes the default route above (even though the interface is downed). Re-adding the route works. Regards, Richard