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";
fixed-address 192.168.2.12;
option subnet-mask 255.255.255.0;
option time-offset -18000;
option dhcp-lease-time 345600;
option routers 192.168.2.100;
option dhcp-message-type 5;
option dhcp-server-identifier 192.168.2.100;
option domain-name-servers 209.226.175.236,204.101.251.1,204.101.251.2;
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 192.168.2.25 netmask 255.255.255.0" \
defaultrouter="192.168.2.100"
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:
ifconfig_rl0="DHCP"
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="DHCP"
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
rl0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
options=8<VLAN_MTU>
inet 192.168.2.87 netmask 0xffffff00 broadcast 192.168.2.255
ether 00:05:5d:d2:19:b7
media: Ethernet autoselect (100baseTX <full-duplex>)
status: active
Success!
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.
You must be logged in to the O'Reilly Network to post a talkback.
Showing messages 1 through 12 of 12.
-
Acheiving connectivity on VMWare
2010-03-09 20:43:43 abaig [Reply | View]
-
Acheiving connectivity on VMWare
2010-06-26 07:29:49 sparcdoctor [Reply | View]
Could be the lingering bridge bug. VMware had issues in the past binding to Hamachi interfaces inactive or not. Check network settings to make sure it's not binding if you do use Hamachi. -
Acheiving connectivity on VMWare
2010-03-12 11:08:39 Dru Lavigne |
[Reply | View]
I don't have Vmware to test, but I have blogged about it at http://it.toolbox.com/blogs/bsd-guru/anyone-using-freebsd-7-in-vmware-37429 and some comments are starting to come in that may help. -
Acheiving connectivity on VMWare
2010-03-13 11:17:23 5u623l20 [Reply | View]
You need to work out something with the Edit->Virtual Network Editor. Opening the screen you will get some column with Name, Type, External connection etc. In the External connection column you will find one line with the "NAT" option. Select it. Will see some change in the following VMNET Information. Click "NAT Settings". Find the Gateway IP from the screen. In my case it is something like 192.168.157.2. Exit using "Cancel". Use any IP other than 1 and 2 in the fourth octet and use the same IP you found in the previous step as gateway. Use the Resolver of your Host PC. Voila. It's done.
Usage :
Bridge - When you have extra handy IP of the same series of your host PC.
NAT - When you dont have the above.
Host Only - When you want to use some other VM and connect them inside the network without external access.
-
Cool.
2007-02-25 16:51:34 AlexandruI [Reply | View]
As always Dru teaches us new things. Thank you !
A cool thing I think would be an article about BSD and multiple gateways (2 ISPs).
-
no option r for dhclient
2006-08-30 15:52:59 enemy [Reply | View]
I don't find the option r in man page for dhclient. I tried dhclient -r myinterface, it doesn't take -r. -
no option r for dhclient
2006-08-30 17:21:36 Dru Lavigne |
[Reply | View]
Using -r to release a lease is the behaviour found in the ISC's version of dhclient. In June of 2005, FreeBSD stopped using the ISC version and replaced it with the OpenBSD version. If you prefer the ISC version, run "pkg_add -r isc-dhcp3-client" and follow the instructions you receive at the end of the install. If you miss that message, you can read it again by typing "pkg_info -Dx dhcp". -
no option r for dhclient
2006-08-31 06:15:23 enemy [Reply | View]
Dru, thanks a lot. I really like your FreeBSD articles. I have been using Linux for a couple of years. I am moving to FreeBSD on the desktop and would also like to work on FreeBSD at work in the future.
Getting a prompt reply from the author is really cool.
Thanks a again.
-
bc gives me different output
2006-08-30 15:40:56 enemy [Reply | View]
% bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
base=16
E0
224
- The value I get is 90 when I try the same with bc -
bc gives me different output
2006-08-30 15:51:03 Dru Lavigne |
[Reply | View]
This is a typo, it should be:
ibase=16
E0
224
-
Corrections
2004-11-13 01:47:44 fxtl [Reply | View]
ifconfig_rl0="DHCP"
ifconfig_rl0="100baseTX mediaopt full-duplex"
That didn't work for me, and isn't it supposed to beifconfig_rl0="media 100baseTX mediaopt full-duplex"?
However, I got it working by creating /etc/start_if.sis0:
ifconfig sis0 media 100baseTX mediaopt full-duplex
/etc/rc.conf just has:
ifconfig_sis0="DHCP"






Im stumped as I cannot get my FreeBSD 7 virtual machine to connect to the internet. Im using the NAT option for the LAN adapter. It says that this option uses the same settings as the host machine to achieve connectivity but it isn't working. Some pointers as what should be done?