FreeBSD: HowTo Change IP Address / Setup New IP Address For Existing Interface

by on December 1, 2004 · 11 comments· LAST UPDATED April 2, 2012


In this quick post I will explain how to add and configuring a network card under FreeBSD operating system using command line options.

To display the current configuration for the network interfaces on your FreeBSD server, type the following command:
# ifconfig

How Do I Configure the Network Card Under FreeBSD?

You need to use the ifconfig command as follows to assign an IP address:
# ifconfig interfaceName inet IPAddress

To assign an ip to lnc0 interface, enter:
# ifconfig lnc0 inet

Please note that lnc0 is an ethernet interface name. It can be Obtained by tying the following command:
# ifconfig -a

FreeBSD Ntwork Card's Configuration

To setup up ip address permanently open a file called /etc/rc.conf and append/modify network entries as follows:
# vi /etc/rc.conf
Setup values as follows:
ifconfig_lnc0="inet netmask"
### Default gateway ###

Save and close the file. Please note that ifconfig_lnc0 is Ethernet interface name. It can be Obtained using ifconfig -a command.

You can restart networking service using the following command:
# /etc/rc.d/netif restart && /etc/rc.d/routing restart

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 11 comments… read them below or add one }

1 Anonymous September 5, 2005 at 7:25 pm

Thanks for this tip. It was very helpful


2 Hyip July 19, 2008 at 9:25 am

Could you please set up an .exe file to do the above procedure
I think making a .exe file with the above commands will make the job easier for repeatedly changing ip addresses


3 Claus Larsen December 16, 2008 at 1:08 pm

An exe file, do you have any idea about what you are saying, exe files is a windows thing.


4 Senphet December 15, 2009 at 9:31 pm

.exe for bsd!? thanks for the good laugh ; )


5 wakka wakka September 10, 2010 at 10:49 pm

lmao, maybe he meant a .bat file not .exe!


6 ozy-ns December 20, 2010 at 1:47 pm

The .bat file is from windows too ;)


7 TnyTm February 17, 2011 at 2:44 pm

Friggen windows nerds with your exe and bat files. However can you create a vbs script perhaps. I like the idea of changing the IP address easily from script. vbs would be nice.


8 Joe's Morgue April 2, 2012 at 12:00 pm

I’m VERY much a beginner with *nix of ANY form [including FreeBSD] AND I can’t spell, but….

.EXE and .BAT are NOT from Windows. They are from the days of DOS, which was usable within Windows….

He is using a term he [and you] understood from his DOS [Windows] experience…


9 Mohammed Khalid February 2, 2013 at 5:34 am

Thanks a lot


10 Jason May 2, 2014 at 4:29 pm


Just goes to show, that helpdesk staff shouldnt work on network stuff


11 John Stepp February 11, 2015 at 9:07 pm

making a binary for this seems a little overkill.
alias setnet ‘ee /etc/rc.conf’
alias restartnet ‘/etc/rc.d/netif restart && /etc/rc.d/routing restart’

(I know, ee; I just do not want to relearn vi at my age.)


Leave a Comment

Tagged as: , , , , , , , , , , , , , , , ,

Previous post:

Next post: