Adding static IPv4 in FreeBSD
This is a quick how-to guide on adding to FreeBSD machine.
Set permanent IP
- Open
/etc/rc.conf
vi /etc/rc.conf
- Search for
ifconfig_xn0
(xn0
is interface name) and edit its contents to reflect your IP.
hostname="freebsd"
ifconfig_xn0="inet 192.168.10.1 netmask 255.255.250.0"
- Run the
/etc/netstart
script to update configuration.
./etc/netstart
Set temporary IP
NOTE: IP will be reverted after reboot.
- Get the interface name using
ifconfig -a
(you don’t wantlo
interface)
$ ifconfig -a
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
...
xn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
...
- Set the ip for
xn0
using following command.
$ ifconfig xn0 inet 192.168.10.1