How to Configure a Static IP Address

Add your Tips and tricks to configure and tweak your GhostBSD System here.
Post Reply
User avatar
NevilleGoddard
Developer
Posts: 517
Joined: Thu Dec 22, 2016 10:30 pm
Location: Japan

How to Configure a Static IP Address

Post by NevilleGoddard »

When booting GhostBSD sometimes there is a pause while the DHCP network is starting. This slows things down a little while but there is an easy way around this.
First open up a terminal and type -
ifconfig

Then you'll get output that looks something like this:

em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
ether bc:5f:f4:fb:a2:a9
inet 192.168.3.6 netmask 0xffffff00 broadcast 192.168.2.255
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
media: Ethernet autoselect (1000baseT <full-duplex>)
status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
inet 127.0.0.1 netmask 0xff000000
nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

The important things to look for here are :

em0 (your network device mat be different - adjust accordingly)

inet 192.168.3.6 and

netmask 0xffffff00 (on your system your numbers may be different so adjust accordingly)

Then log in as root
Then type -

ifconfig em0 inet 192.168.3.6 netmask 0xffffff00

(from your terminal output)
then still as root:

dhclient em0

(again - adjust accordingly)
The output from this command will contain something similar to:

DHCPACK from 192.168.3.4 - (your number may be different) remember 192.168.3.4 for when editing /etc/rc,conf

then the command:

route add default 192.168.3.4
-(or your number)

then edit /etc/rc.conf:

command:

ee /etc/rc.conf

Go down with your keyboard arrow keys to the line:

ifconfig_em0="DHCP"

and comment (#) this line so it looks like this:

#ifconfig_em0="DHCP"

then under this line enter these lines:

ifconfig_em0="inet 192.168.3.6 netmask 0xffffff00"
defaultrouter="192.168.3.4"

Make sure you use exactly the same numbers as your terminal output above and be careful to put correct spaces and quotation marks.

then press Esc save changes and reboot and you should have your static ip address working and slightly faster boot times. :D

If for some reason you want to go back and undo all these changes then:

Open a terminal, log in as root:
Then type :

ee /etc/rc.conf

Go down with your arrow keys to the 2 lines that you made before:


ifconfig_em0="inet 192.168.3.6 netmask 0xffffff00"
defaultrouter="192.168.3.4

and comment them (#) so they look like this:

#ifconfig_em0="inet 192.168.3.6 netmask 0xffffff00"
#defaultrouter="192.168.3.4"

Or you can just delete them


Then go to the line :

#ifconfig_em0="DHCP"

and uncomment it so it looks like this:


ifconfig_em0="DHCP"

Press Esc and save changes when prompted and reboot and it will back to the way it was before
Last edited by NevilleGoddard on Sat Apr 08, 2017 6:32 am, edited 1 time in total.
ASX
Posts: 988
Joined: Wed May 06, 2015 12:46 pm

Re: How to Configure a Static IP Address

Post by ASX »

Thanks.

Code: Select all

ifconfig_em0="inet 192.168.3.6 netmask 0xffffff00"
please note that the above can also be written as:

Code: Select all

ifconfig_em0="inet 192.168.3.6 netmask 255.255.255.0"
or

Code: Select all

ifconfig_em0="inet 192.168.3.6/24"
Also, be sure to use an IP address outside the range used from the DHCP server, else you risk a duplicate IP address.
CarolineSmith
Posts: 1
Joined: Tue Jul 18, 2017 6:02 am

Re: How to Configure a Static IP Address

Post by CarolineSmith »

Thanks for explaining here on how to configure a static IP Address which is really helpful for IT students who are getting help with assignment from me at Quality Assignment UK.
User avatar
NevilleGoddard
Developer
Posts: 517
Joined: Thu Dec 22, 2016 10:30 pm
Location: Japan

Re: How to Configure a Static IP Address

Post by NevilleGoddard »

No worries. Glad I could help!
Kernelpanic
Posts: 37
Joined: Tue Sep 29, 2015 4:59 pm

Re: How to Configure a Static IP Address

Post by Kernelpanic »

NevilleGoddard wrote:No worries. Glad I could help!
Thanks
You did it ;)
nevets
Posts: 149
Joined: Tue Jun 23, 2020 3:54 am

Re: How to Configure a Static IP Address

Post by nevets »

Thanks Neville, however... I'm no way an expert... yet doesn't the freebsd utility
sudo bsdconfig networking
run from a terminal edit these same files anyway with a terminal interface?
Happy to be mistaken. :-)
Steve
janemea343
Posts: 1
Joined: Mon Jul 18, 2022 10:51 pm

Re: How to Configure a Static IP Address

Post by janemea343 »

Right-click on the network adapter that is currently connected to the device that you are trying to configure. If you are using a Wi-Fi card, right-click its icon in the system tray and select Open Network and Sharing Center. Find the network connection for which you want to configure a static IP address and click it. Does anybody know about sidewinder key type cut and program?
Post Reply