oreilly.comSafari Books Online.Conferences.


FreeBSD Networking Basics
Pages: 1, 2

Verifying Your DHCP Lease

If your IP settings are assigned by a DHCP server, you can see all of your settings at once by viewing your current lease.

The lease itself is contained within curly brackets. If you have several leases, the one at the top of the file is your most recent lease.

% more /var/db/dhclient.leases
lease {
  interface "ed0";
  option subnet-mask;
  option time-offset -18000;
  option dhcp-lease-time 345600;
  option routers;
  option dhcp-message-type 5;
  option dhcp-server-identifier;
  option domain-name-servers,,;
  renew 2 2004/4/13 02:13:03;
  rebind 3 2004/4/14 23:34:37;
  expire 4 2004/4/15 11:34:37;

Adding an Interface

It's one thing to know how to verify your interface configuration, but what if you need to configure an interface? Let's say you've just added another NIC to your system. Once your computer reboots, you'll want to verify that the new NIC was recognized. You can use ifconfig and look for an additional interface. You could also search the boot probe messages for found Ethernet addresses. Remember to include a capital E in your search:

% grep Ethernet /var/run/dmesg.boot 
rl0: Ethernet address: 00:05:5d:d2:19:b7
rl1: Ethernet address: 00:05:5d:d1:ff:9d
ed0: <NE2000 PCI Ethernet (RealTek 8029)> port 0x9800-0x981f irq 10 at 
device 11.0 on pci0

If your new NIC is listed, it's ready to be configured -- but what if the new NIC wasn't found at bootup? The first question to ask yourself is, "Have I created a custom kernel?" If so, check your kernel configuration file; you may have removed the driver required by the new NIC.

If that's not the issue, you may have to reboot and examine your CMOS settings. Have you disabled any IRQs? Do you have enabled onboard devices that you don't use? If so, they may be wasting an IRQ, and there aren't any left over for your new NIC. If you do decide to change a CMOS setting, record the original value on a piece of paper. Change one setting, boot up and see if it made a difference. Repeat as necessary.

If the NIC is PCI, check your CMOS PnP OS setting. Sometimes changing it from yes to no will resolve the issue. Also, sometimes seating the NIC in another PCI slot solves the problem. Finally, as a last resort, you can determine if it is an IRQ problem by removing all cards except the new NIC and your video card. If the NIC is recognized, you have more cards than you have IRQs.

Configuring IP Address Information

Once your NIC is recognized, decide whether to set the IP address information manually or to use a DHCP server. Either method requires a change to /etc/rc.conf. If you prefer, you can use /stand/sysinstall, which will edit this file for you. This is the same utility you used when you installed your FreeBSD system. Once the utility starts, choose Configure, then Networking, and then use your space bar to select Interfaces.

Otherwise, edit /etc/rc.conf directly using your favorite text editor. For example, these lines statically assign an IP address and subnet mask to rl0, and set the default gateway:

ifconfig_rl0="inet netmask" \

Also, if you're using static IP addressing, don't forget to add the IP addresses of your DNS servers to /etc/resolv.conf.

If you instead use a DHCP server to receive your IP address information, you only need to add one line to /etc/rc.conf:


You don't need to add your default router or DNS server addresses, as the lease assigned by your DNS server should include this information.

When you've saved your changes to /etc/rc.conf, initialize your network settings:

# /etc/netstart

Note: If you ever need to renew your DHCP lease, use this command, but substitute rl0 for the name of your NIC:

# dhclient -r rl0

Optimizing Your Configuration

Unless you have an extremely old NIC, or you specifically purchased a 100Mbps NIC, your NIC is 10/100Mbps. This means it is capable of negotiating a speed of 10 or 100 Mbps. It most likely also negotiates either half-duplex (cannot send and receive simultaneously) or full-duplex (can send and receive simultaneously) operation. This negotiation process occurs between the NIC and the hub or switch at the other end of your networking cable.

Obviously, 100Mbps at full-duplex is much better than 10Mbps at half-duplex. The limiting factor will be the hub or switch; its documentation will indicate its speed and mode of operation. If it doesn't support 100Mbps or full-duplex, you're not getting the most out of your NIC and your networking experience will be much slower.

However, you should also be aware that even if the hub or switch supports 100Mbps and full-duplex mode, the NIC and the hub or switch still renegotiate these values on an ongoing basis. If your NIC is always plugged into the same hub or switch, it makes sense to set these values to save the overhead of negotiation.

Whether you can do this depends upon the driver for your NIC, so carefully read the man 4 for your driver. In my example network, I would be better off unplugging my ed0 and instead using one of the RealTek interfaces. Why? man 4 ed indicates that this particular driver only supports 10Mbps at half-duplex mode (IEEE 802.3 CSMA). However, man 4 rl indicates that this driver can be configured to use 100Mbps and full-duplex operation.

Here is an example of the lines I would use in /etc/rc.conf:

ifconfig_rl0="100baseTX mediaopt full-duplex"

There are several things to make note of here. One, the manpage will indicate which options are available and how to set them. Two, don't try to add a setting that your NIC driver doesn't support, as indicated by its manpage. Third, don't change your speed and duplex mode to a value that your hub or switch doesn't support!

To see if my changes worked, I'll plug my network cable into rl0 and issue the command /etc/netstart. I'll then check out the results:

% ifconfig rl0
    inet netmask 0xffffff00 broadcast
    ether 00:05:5d:d2:19:b7
    media: Ethernet autoselect (100baseTX <full-duplex>)
    status: active


This article has covered most of the configuration scenarios for Ethernet NICs. You should also refer to the "Setting Up Network Interface Cards" section of the handbook.

In the next few articles, I'd like to concentrate on printing.

Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.

Read more FreeBSD Basics columns.

Return to the BSD DevCenter.

Sponsored by: