Introduction
So what is a network interface? In plain old english, it is a logical reference to underlying network hardware. They comprise the lowest layer of the networking subsystem, interacting with the actual transport hardware.
It is important to understand network interfaces as they are the key to talking to your network hardware (like Ethernet, token-ring,ATM,etc). Different network interfaces may support one or more different protocol families, such as TCP/IP, IPX, etc.
Ifconfig The main utility for inspecting and configuring a network interface is ifconfig. First lets look at viewing all interfaces:# ifconfig -a xl0: flags=8843Ah, it appears I have several interfaces: xl0,lp0,ppp0,sl0,faith0,and lo0. What do they all mean? First lets talk about the loopback interface, lo0. This is a special interface for communicating with itself. It always has the IP address 127.0.0.1. All of the other interfaces (except xl0) will be ignored for now but I will give a brief description:mtu 1500 options=3 inet 205.238.129.221 netmask 0xfffffffc broadcast 205.238.129.223 inet6 fe80::250:daff:fe77:cc77%xl0 prefixlen 64 scopeid 0x1 ether 00:50:da:77:cc:77 media: Ethernet autoselect (100baseTX ) status: active lp0: flags=8810 mtu 1500 ppp0: flags=8010 mtu 1500 sl0: flags=c010 mtu 552 faith0: flags=8002 mtu 1500 lo0: flags=8049 mtu 16384 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x6 inet 127.0.0.1 netmask 0xff000000
lp0 -> printer interface ppp0 -> PPP interface sl0 -> slip interface faith0 -> IPv6 interfaceNow, xl0. I chose to look at xl0 because it is the logical reference to my ethernet network card I have installed in my machine. This is not to say that every network card in FreeBSD will be referenced by xl0. Unlike Linux, each corresponding Ethernet chipset driver is referenced differently in FreeBSD. A full list is located in the kernel LINT file. I happen to be using a 3com network card, for which the xl driver has been written. therefore, my network card is referenced by xl0, meaning the first 3com network card in the machine. If I added another 3com network card to my box, it would show up as xl1, add another and get xl2, etc, etc. I can get more information from the kernel dmesg.boot file like so:
# grep xl0 /var/run/dmesg.boot xl0: <3Com 3c905C-TX Fast Etherlink XL> port 0x9000-0x907f mem 0xf6800000-0xf680007f irq 9 at device 10.0 on pci1 xl0: Ethernet address: 00:50:da:77:cc:77 miibus0:This is what the kernel probe found at boot time.on xl0
Lets look again at just the xl0 ifconfig output:
# ifconfig xl0 xl0: flags=8843This tells us some interesting things. The first line show the interface flagsmtu 1500 inet 205.238.129.221 netmask 0xfffffffc broadcast 205.238.129.223 inet6 fe80::250:daff:fe77:cc77%xl0 prefixlen 64 scopeid 0x1 ether 00:50:da:77:cc:77 media: Ethernet autoselect (100baseTX ) status: active
# ifconfig -m xl0 xl0: flags=8843Take special note of the media lines down at the bottom. To manually set them:mtu 1500 options=3 capability list: =3 inet 205.238.129.221 netmask 0xfffffffc broadcast 205.238.129.223 inet6 fe80::250:daff:fe77:cc77%xl0 prefixlen 64 scopeid 0x1 ether 00:50:da:77:cc:77 media: Ethernet autoselect (100baseTX ) status: active supported media: media autoselect media 100baseTX mediaopt full-duplex media 100baseTX media 10baseT/UTP mediaopt full-duplex media 10baseT/UTP media 100baseTX mediaopt hw-loopback
To set to 100BaseTX : # ifconfig xl0 media 100baseTX Or to set to 100BaseTX and run in full-duplex: # ifconfig xl0 media 100baseTX mediaopt full-duplex