I haven’t written about things like this in a while but the question was put to me and I thought it’d be worth jotting something down.
Perhaps you prefer something like the generic eth0 used on
your Linux boxes, or maybe something as short as e0 typically found on
Cisco and Adtran router and switches. Then again maybe you just want to name them somthing specific like public, private or DMZ.
So first you are probably asking yourself why would you ever want to change the name of your bge0 to something else? To answer it simply comes down to keeping things simple. Redundant no? Honestly if you have a set of standard ipfw firewall rules for instance that you wish to roll out to all of your machines however they all have different NIC cards then this will require quite a lot of work.Therefore why not just make it part of your initial setup to generic things up a bit?
Honestly, if you take a few minutes to prepare your machines ahead of time then you can use some sort of version control tools like svn to hold a single copy of your base firewall rules. Then you can perform a simple checkout and raise your shields in seconds. I quick change to the base checked back in and then if you had all machines on a trigger system they can checkout the current versions effectively remodulating the shield frequencies. Ok perhaps that was a bit too Star Trekky for most people.
So here’s how to do it. On the command line as root or via sudo you can invoke ifconfig directly as follows;
ifconfig bge1 name e1
Here is the basic ifconfig output prior to executing the above command:
bge0: flags=8843 metric 0 mtu 1500
options=9b
ether 00:0b:cd:f2:d8:c3
inet 10.10.10.13 netmask 0xffffff00 broadcast 204.107.76.255
media: Ethernet autoselect (100baseTX )
status: active
bge1: flags=8802 metric 0 mtu 1500
options=9b
ether 00:0b:cd:f2:d8:c2
media: Ethernet autoselect (none)
status: no carrier
lo0: flags=8049 metric 0 mtu 16384
inet 127.0.0.1 netmask 0xff000000
And the same after executing the command:
bge0: flags=8843 metric 0 mtu 1500
options=9b
ether 00:0b:cd:f2:d8:c3
inet 10.10.10.13 netmask 0xffffff00 broadcast 204.107.76.255
media: Ethernet autoselect (100baseTX )
status: active
e1: flags=8802 metric 0 mtu 1500
options=9b
ether 00:0b:cd:f2:d8:c2
media: Ethernet autoselect (none)
status: no carrier
lo0: flags=8049 metric 0 mtu 16384
inet 127.0.0.1 netmask 0xff000000
Notice that the only change was the name identifying the second ethernet interface. Of course being able to manually manipulate the ethernet interface names is all well and good. I suppose you could also write your own script and stuff it into the rc.network startup somewhere but that’d be a total waste of effort when tyou can just use the built in rc.conf as follows to make the same change occur at startup.
You would make a change similar to the following in /etc/rc.conf
ifconfig_bge0_name=”e0″
ifconfig_e0=”inet 10.10.10.13 netmask 255.255.255.0″
After a reboot you would see the following ifconfig output:
e0: flags=8843 metric 0 mtu 1500
options=9b
ether 00:0b:cd:f2:d8:c3
inet 204.107.76.13 netmask 0xffffff00 broadcast 204.107.76.255
media: Ethernet autoselect (100baseTX )
status: active
bge1: flags=8802 metric 0 mtu 1500
options=9b
ether 00:0b:cd:f2:d8:c2
media: Ethernet autoselect (none)
status: no carrier
lo0: flags=8049 metric 0 mtu 16384
inet 127.0.0.1 netmask 0xff000000
Observe that the interface formerly known as bge0 is now simply e0. I shall leave that up to you imagination as to why the name of e1 has reverted back to bge1.
Honestly FreeBSD allows you the power to name the interfaces
whatever you like. Maybe, just maybe you are one of those individuals
that like to name things after your favorite flavor of ice cream, or
after your favorite characters or Dune. Now that you know how the choice is entirely up to you. Go have fun with it!
I hope that this little technical note has been helpful.
chris says
just ran across the situation that dhcrelay only writes the interface name in its agent-circuit-id option. In order for this to be any useful, such renaming will come in very handy. Have not tested it yet. though.
ahmed allam says
pfsense use interface names rather than mac addresses if you remove some interfaces and ad some the interfaces order change and pfsense starts assigning the wrong devices to your interfaces. keeping persistant interface namings helps avoid such a scenario. since pfsense is running on freebsd the above method you’ve mentioned is a must.
steve88emant says
thanks!!!