From owner-freebsd-questions@freebsd.org Mon Oct 26 22:18:10 2015 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AD1C48413 for ; Mon, 26 Oct 2015 22:18:10 +0000 (UTC) (envelope-from joh.hendriks@gmail.com) Received: from mail-wi0-x232.google.com (mail-wi0-x232.google.com [IPv6:2a00:1450:400c:c05::232]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 557AF155B for ; Mon, 26 Oct 2015 22:18:10 +0000 (UTC) (envelope-from joh.hendriks@gmail.com) Received: by wicll6 with SMTP id ll6so134682173wic.0 for ; Mon, 26 Oct 2015 15:18:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:references:to:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=AQiyCWjTBcwYQ8iLOfowfAV2mHvgX7cRRACi48fDgPU=; b=bHkpnLTK1JRX+lF4P086jORxCULaDS6B52pczcChU+vmIFNfFrcBUEL0aIl6wuHklv erp7L3g7Lvh0XhVWlMHq7uJ+v08hZcdsdpwWMji3tp8PpOIKQXgZMyBQ+Qms96kW/m8z KKPmPFHBBusEa1R19x497lxBzLHpUO2ts6sw6z2RwHOhSz+ZTGngwK/ff7Q4WD0Dtxkk QdplZWi2ixpaNmy7pS4HRRD6Dg0FZ0aKqNNVGnK3GqvXMQvnvYCN2qeOoHuArX5d9hNj ttVokWnX9HVlXwRsfOfUoH6Rv7kISRvTSsx2Kyj18RspZjEmeS5boPqTpjex31H4A88Q 5nMA== X-Received: by 10.180.91.132 with SMTP id ce4mr21730661wib.43.1445897888811; Mon, 26 Oct 2015 15:18:08 -0700 (PDT) Received: from Johans-MacBook-Air.local (92-70-102-130.glasvezel.netexpo.nl. [92.70.102.130]) by smtp.googlemail.com with ESMTPSA id a13sm12035749wiv.10.2015.10.26.15.18.07 for (version=TLSv1/SSLv3 cipher=OTHER); Mon, 26 Oct 2015 15:18:07 -0700 (PDT) Subject: Re: NIC naming References: <562E4D92.3000308@gmail.com> <562E551F.6060406@freebsd.org> <0746B048-19AB-4AA6-8439-4DF7A08D10AE@elde.net> <562E909B.5050408@ccsys.com> To: freebsd-questions@freebsd.org From: Johan Hendriks Message-ID: <562EA69D.5010706@gmail.com> Date: Mon, 26 Oct 2015 23:18:05 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Oct 2015 22:18:10 -0000 Op 26/10/15 om 22:05 schreef Jake: >> On Oct 26, 2015, at 4:44 PM, Chad J. Milios wrote: >> >>> On 10/26/2015 2:16 PM, Terje Elde wrote: >>> >>>> On 26 Oct 2015, at 17:30, Matthew Seaman wrote: >>>> >>>> This probably doesn't solve your problem, which appears to be knowing >>>> which of the ethernet ports on your machine is em0 -- the usual method >>>> to do that is by ifconfig'ing everything else down and then testing with >>>> a network cable until you find the working port. However it might help >>>> clarify the system configuration. >>> ifconfig will give you the MAC of the card. I'm not sure if there's a standard tool for it, but it should be easy to do something like "rename the card with MAC address X to Y" >> you can put the following one-liner (fix if your email client breaks) directly into /etc/rc.conf or /etc/rc.conf.local (replace 01:23:45:67:89:ab with your "main" card's MAC address and that interface will always be named, in this example net0: >> >> eval setvar `ifconfig | while read a b; do if [ "$b" != "${b#flags=}" ]; then c=${a%:}; fi; if [ "$a" = ether -a "$b" = 01:23:45:67:89:ab ]; then echo ifconfig_${c}_name net0; fi; done` >> >>> Personally, I've started renaming along the lines of renaming em0 to em_lan0, em1 to em_wan1 and so on. Makes it a bit easier to see what's going on, both for when another admin might inherit the box, and also for myself, if I haven't touched the box in a few years. >> you may replace net0 with legal names such as up0, up1, down0, down1, down2, down4 (or in#, out#, wan#, lan#) etc. whatever makes most sense to describe your use case (just not wlan#. use wifi# or wphy# for your wlan#'s phy interface): >> >> name_mac () { >> eval setvar `ifconfig | while read a b; do if [ "$b" != "${b#flags=}" ]; then c=${a%:}; fi; if [ "$a" = ether -a "$b" = $2 ]; then echo ifconfig_${c}_name $1; fi; done` >> } >> >> name_mac up0 aa:aa:aa:aa:aa:aa >> name_mac down0 bb:bb:bb:bb:bb:bb >> name_mac down1 cc:cc:cc:cc:cc:cc >> >>> Sure, you could argue all of this should be documented somewhere as well - and you wouldn't be wrong - but renaming makes things obvious where the next admin will look, not just in some doc that might be somewhere he didn't. >>> >>> Terje >> -Chad J. Milios >> P.S. any snippets of code contained in this email are hereby placed in the public domain. >> > Both of those should say "elif" near the middle there instead of "fi; if" to be a tiny bit faster, but either way works. Doh! I just did this little hack now. I've always just went with the straight ifconfig_phy0_name=net0; ifconfig_phoo0_name=net1; ifconfig_phum0_name=net2; myself and don't move cards around much. > _______________________________________________ > freebsd-questions@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" Thank you all for the answers. The reason I asked is we are going to add a network card to most of our servers, but the tests show that emx, or igbx for that matter got tossed around. So what was first em0 is now em2 so the rc.conf files do not match the physical cable anymore. Not a big problem, we have the time so we just find out the new layout. Johan