25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

25% off on first invoice for all services*

SPRING SALE

Use coupon

*Offer valid for new customers only

Need help?

Our experts have had an average response time of 11.43 minutes in March 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

How to set Static IP and Hostname in FreeBSD 12

by | Nov 20, 2020

Don’t know how to set a Static IP address and hostname in FreeBSD 12? We can help you.

Today, we are going to see how our Support Engineers set hostname and static IP address on FreeBSD 12.

 

Set Static IP and Hostname in FreeBSD 12

Static IP and Hostname

Initially, we need to make sure that the IP address assigns to an interface and the IP configuration includes in /etc/rc.conf, to have a persistent IP address.

Please keep in mind that a FreeBSD network interface identifier uses the drive name followed by a number as shown below:

# ifconfig em0: flags=8843 metric 0 mtu 1500 options=81009b ether 08:00:27:12:6b:98 inet 10.0.0.11 netmask 0xffffff00 broadcast 10.0.0.255 media: Ethernet autoselect (1000baseT ) status: active nd6 options=29 lo0: flags=8049 metric 0 mtu 16384 options=680003 inet6 ::1 prefixlen 128 inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 inet 127.0.0.1 netmask 0xff000000 groups: lo nd6 options=21

For example:

  • Set Server static hostname – freebsd.example.com
  • Set interface IP Address – 192.168.13.4/24
  • Change gateway of interface to 192.168.13.1

Given below are the steps to follow:

  1. Configure network settings in FreeBSD
  2. Set hostname in FreeBSD 12
  3. Set Static IP address in FreeBSD 12
  4. Establish a DHCP Address

Let us now look into it in detail.

Configure network settings in FreeBSD

Network configurations for FreeBSD are stored in the system configuration file.

The path to this file is /etc/rc.conf, this is where the server’s host name as well as network interface configurations are set.

Given below is an example for the rc.conf file used by FreeBSD:

hostname=”freebsd12″
ifconfig_em0=”DHCP”
ifconfig_em0_ipv6=”inet6 accept_rtadv”
sshd_enable=”YES”
# Set dumpdev to “AUTO” to enable crash dumps, “NO” to disable
dumpdev=”AUTO”
  • The hostname value sets the host name of the FreeBSD server
  • ifconfig_em0 value sets the network configurations for the em0 network interface
  • ifconfig_em0_ipv6 value is the IPv6 equvelant of the ifconfig_em0 value
  • sshd_enable sees whether the SSH daemon is enabled or not.

 

Set Hostname on FreeBSD 12

$ su –
# hostname freebsd.example.com
# echo “\”hostname=freebsd.example.com\”” >> /etc/rc.conf

If the dhclient is used to set the hostname via DHCP, the hostname variable should be set to an empty string.

 

Set Static IP Address on FreeBSD 12

Once we set the hostname, proceed to configure a Static IP address on FreeBSD 12:

# vi /etc/rc.conf

Add:

ifconfig_em0=”inet 192.168.13.4 netmask 255.255.255.0″
defaultrouter=”192.168.13.1″

Later, restart FreeBSD network service and routing table:

# /etc/rc.d/netif restart && /etc/rc.d/routing restart

Simultaneously, to configure an interface for DHCP, reset the settings to:

ifconfig_em0=”DHCP”

 

Setting a DHCP Address

DHCP address for a network interface on a FreeBSD host is set by editing the system configuration file /etc/rc.conf.

For instance, to set the network interface em0 to DHCP:

ifconfig_em0=”DHCP”
  • Open the system configuration file into a text editor
vi /etc/rc.conf
  • Update the network interface to use DHCP. In our example, the interface will be em0
ifconfig_em0=”DHCP”
  • Save the changes and exit the text editor.

Meanwhile, apply new network configurations:

./etc/netstart

Similarly, the system configuration file must resemble with the ifconfig_ interface where we have updated the “DHCP” value.

For instance:

hostname=”freebsd12″
ifconfig_em0=”DHCP”
ifconfig_em0_ipv6=”inet6 accept_rtadv”
sshd_enable=”YES”
# Set dumpdev to “AUTO” to enable crash dumps, “NO” to disable
dumpdev=”AUTO”

Furthermore, to verify if the changes are done successfully use the command:

ifconfig em0

[Need further assistance? We are here for you!]

 

Conclusion

To conclude, today, we saw how our Support Engineers configure network settings in FreeBSD by setting static IP addresses and DHCP addresses.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF