We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Learn how to – Set hostname & Static IP address on FreeBSD 12/13

Learn how to – Set hostname & Static IP address on FreeBSD 12/13.

So you’re trying to learn how to set a hostname & static IP address on FreeBSD 12/13?. In this guide I’ll show you how easy it is to a hostname and a Static IP address on FreeBSD 12/13.  Please note that the FreeBSD network interface identifier uses the driver name followed by a number.

# ifconfig
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=81009b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,VLAN_HWFILTER>
	ether 08:00:27:12:6b:98
	inet 10.0.0.11 netmask 0xffffff00 broadcast 10.0.0.255 
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2 
	inet 127.0.0.1 netmask 0xff000000 
	groups: lo 
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

To have a persistent IP address on your FreeBSD 12/13 server, the IP address must be assigned to an interface and the IP configuration included in /etc/rc.conf. Let’s consider an example below:

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

Set Hostname on FreeBSD 12 / FreeBSD 13

Set a hostname on FreeBSD 12/13 using the commands below:

$ sudo hostname freebsd.example.com
$ sudo vim /etc/rc.conf
hostname=freebsd.example.com

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 / FreeBSD 13

Now that you have the hostname set, proceed to configure a Static IP address on FreeBSD.

sudo vim /etc/rc.conf

Add:

ifconfig_em0="inet 192.168.13.4 netmask 255.255.255.0"
defaultrouter="192.168.13.1"

Restart FreeBSD network service and routing table:

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

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

ifconfig_em0="DHCP"

Cart

Your Cart is Empty

Back To Shop