{"id":428,"date":"2010-07-16T23:30:47","date_gmt":"2010-07-17T04:30:47","guid":{"rendered":"http:\/\/www.dannorris.com\/?p=428"},"modified":"2019-04-01T13:57:25","modified_gmt":"2019-04-01T13:57:25","slug":"unplumb-or-unbinding-nics-on-linux-2","status":"publish","type":"post","link":"https:\/\/www.dannorris.com\/blog\/2010\/07\/16\/unplumb-or-unbinding-nics-on-linux-2\/","title":{"rendered":"unplumb (or unbinding) NICs on Linux"},"content":{"rendered":"<p>\t\t\t\tI&#8217;ve been quiet for a long time now, but this entry hopefully will  shake the cobwebs off and get me back into the habit.<\/p>\n<p>I recently had a need to &#8220;unplumb&#8221; (from Solaris fame) or make  interfaces on Linux &#8220;disappear&#8221; from the ifconfig list. It could be that  I don&#8217;t know how to completely deconfigure an interface, but I didn&#8217;t  find any methods to unassign an IP address from a Linux Ethernet  interface after it was assigned. You can take interfaces down (ifconfig  eth3 down) and reconfigure them to assign different addresses, but not  remove the address completely.<\/p>\n<p>After many searches and finding nothing that matched my need, I  turned to my fellow <a href=\"http:\/\/www.oaktable.net\/\">Oakies<\/a> (thanks, <a href=\"http:\/\/markjbobak.wordpress.com\/\">Mark<\/a>!) who turned up <a href=\"http:\/\/www.linux-archive.org\/fedora-user\/55472-hiding-network-interface.html\">this  post<\/a> from 2 years ago that hinted at a solution. It is  driver-specific which is not ideal, but that makes sense given what I&#8217;m  trying to do.<\/p>\n<p>Here&#8217;s the generic version of the solution:<\/p>\n<pre>echo \"&lt;interface_name&gt;\" &gt; \/sys\/bus\/pci\/drivers\/&lt;driver_name&gt;\/unbind<\/pre>\n<p>Determining the driver_name is pretty simple: check the  \/etc\/modprobe.conf file (on OEL\/RHEL 5.x). In that file, you&#8217;ll find  things like this:<\/p>\n<pre>...\nalias eth0 igb\nalias eth1 igb\nalias eth2 igb\nalias eth3 igb\n...\n<\/pre>\n<p>These lines indicate that the Ethernet driver used on this system by  eth[0-3] is the igb driver. Now that you know the driver name, the  tricky part is figuring out what the driver wants you to use as the  interface name. I&#8217;ll give a few examples (and I haven&#8217;t figured out the  scientific way to determine what the driver expects short of reading  source code).<\/p>\n<p>For the bnx2 driver, you can use the relatively simple ethernet  interface name, like this:<\/p>\n<pre>echo \"eth2\" &gt; \/sys\/bus\/pci\/drivers\/bnx2\/unbind<\/pre>\n<p>For my test system, the igb driver doesn&#8217;t use the &#8220;simple&#8221; Ethernet  interface name like the bnx2 driver does. Instead, when trying that, it  gives an error that the interface doesn&#8217;t exist. Time to dig in a little  deeper.<\/p>\n<p>On this system, the igb directory looks like this:<\/p>\n<pre># ls -l \/sys\/bus\/pci\/drivers\/igb\/\n\n\n<\/pre>\n<p>So, knowing that I have 4 interfaces on the system, I made the  correlation to the 4 addresses that appear as symlinks in the driver&#8217;s  directory and expect that they indicate the interface name. Checking a  couple of those (each symlink references a directory), I see this:<\/p>\n<pre># ls -Ll \/sys\/bus\/pci\/drivers\/igb\/0000:01:00.0\n\n\n<\/pre>\n<p>You can see the directory with name &#8220;net:&lt;interface_name&gt;&#8221; as a  subdirectory in each listing above. This tells us which interface from  \/sys\/bus\/pci\/drivers\/igb\/0000* corresponds with which of the Linux  Ethernet interface names. From this, we can see that eth2 is really  0000:07:00.0. So, in order to unbind this interface such that it no  longer appears in the &#8220;ifconfig -a&#8221; output, we run this command:<\/p>\n<pre>echo \"0000:07:00.0\" &gt; \/sys\/bus\/pci\/drivers\/igb\/unbind<\/pre>\n<p>and then it no longer appears in the &#8220;ifconfig -a&#8221; output. If you  wanted to make this permanent, you should comment out the corresponding  line from \/etc\/modprobe.conf so that it won&#8217;t be configured at boot  time. Using the echo command above takes effect immediately, but won&#8217;t  persist through a reboot (after reboot, the interface will return)  unless the \/etc\/modprobe.conf changes are made.<\/p>\n<p>Now, hopefully the next blog post after this one won&#8217;t require 14  more months of preparation!\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve been quiet for a long time now, but this entry hopefully will shake the cobwebs off and get me back into the habit. I recently had a need to &#8220;unplumb&#8221; (from Solaris fame) or make interfaces on Linux &#8220;disappear&#8221; from the ifconfig list. It could be that I don&#8217;t know how to completely deconfigure &hellip; <a href=\"https:\/\/www.dannorris.com\/blog\/2010\/07\/16\/unplumb-or-unbinding-nics-on-linux-2\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;unplumb (or unbinding) NICs on Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,15,22],"tags":[80,117,132,220,222],"class_list":["post-428","post","type-post","status-publish","format-standard","hentry","category-linux","category-oracle","category-technical","tag-ethernet","tag-linux","tag-network","tag-unbind","tag-unplumb"],"_links":{"self":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts\/428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/comments?post=428"}],"version-history":[{"count":1,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts\/428\/revisions"}],"predecessor-version":[{"id":494,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/posts\/428\/revisions\/494"}],"wp:attachment":[{"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/media?parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/categories?post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dannorris.com\/blog\/wp-json\/wp\/v2\/tags?post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}