Network addresses

What is a netword address ?

IP means Internet Protocol. But first, let's talk about Santa 🎅.

To send a letter asking for all the presents you want, you write to the famous address "Santa Claus, North Pole, Rainbow road.". But how does Santa knows how where to answer? Of course you wrote your own address on the back of the envelope.

That's how works computers and servers : you know where is the video you want to watch, and the server hosting the video knows where to send data.

Every device has its own IP on the internet. There are numbers like, not as good looking as Santa's pretty address isn't it?

How devices knows what is the IP of domain name like ? It there a directory?

Indeed there is something like that : DNS. We'll talk about it later.

There are differences between local (or private) IP ans public IP. Most of the time, to reach the internet, your ISP lend you a router so your network look like this :

|                       |
| Local Network (home)  |
|     PRIVATE IP        |
|                       |
|                       |
|      laptop       <---+------+
|      |      |
|                       |      |
|                       |      |
|     Phone         <---+--+  ++---------------+
|      |  |  |                |
|                       |  +--+  Router  (box) |    +----------+
|                       |     |                |<---+ INTERNET |
|     Computer      <---+-----+  PUBLIC IP:    |    +----------+
|      |     |    |
|                       |  +--+                |
|   * * * * * * * * *   |  |  ++---------------+
|   * Your server   <---+--+   |
|   *  *   |      |
|   * * * * * * * * *   |      |
|                       |      |
|     Game console   <--+------+
|      |
|                       |

To host a server, it is useful to have a satic IP delivered by your ISP. Some don't, so you may want to look for a VPN or dynamic DNS or change ISP :)


To run your own server, you must know what are its IP, public, local, and its gateway (router). At first, one may want to configure its network using dhcp then configure a static network when more confident.

Let's see a few words to do so.

Public or local/private address

First, understand your server is probably behind a router given by your ISP. The router received a public IP. People "on the internet" can reach this IP.

The router allocate private addresses to devices connected in your local network. Each device has its own private IP : one for your phone, another for a printer, a computer, a console... They all share one public address.

Private addresses can be in three ranges :

Your private or local IP is the one your computer use, the one it knows.

To find your local IP, run "ifconfig" and filter for "inet". You'll see something like that :

# ifconfig |grep inet
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3
inet netmask 0xff000000
inet netmask 0xffffff00 broadcast
inet6 fe80::feaa:14ff:fe65:5f86%re0 prefixlen 64 scopeid 0x1

inet means IPV4, inet6 means IPv6.

Your public address is the one "used" when you browse the web. Websites you're used to read see this IP. If you don't know it, you can check one of these links (amongst many others):





The router is the box your ISP gave you. We also call it a gateway because on a side it is the "public" network, on the other your "private network". The router deals with redirections : if someone wants to reach your website, the router will lead him to your server's private address.

To find your gateway IP, use "route" command:

# route -n show
Routing tables
Destination        Gateway            Flags   Refs      Use   Mtu  Prio Iface
default        UGS       35     4827     -     8 re0
224/4              URS        0       13 32768     8 lo0
127/8              UGRS       0        0 32768     8 lo0          UHhl       9      969 32768     1 lo0

The first line is what you're looking for : in this example.


Every device in your network has a name to identify it. It is the hostname.

On a computer, you can change this name. To do so on OpenBSD, edit the /etc/myname file and write the complete hostname:



To configure a network interface, you can use DHCP to autmatically get a local address. Be careful though, the "D" means "Dynamic", so this addres might change in the future depending on your router.

To do so, edit /etc/hostname.if file, and replace ".if" by the name of your inteface (run "ifconfig" to find it) and just write "dhcp" inside.


Static configuration

A bit more complicated, static configuration gives you more control.

In /etc/hostname.if (replace "if" with your interface name) :

inet   alias
## and as many as you want
# inet 	(alias) local_ip       network_mask      broadcast_add

If you're not sure, at first configure using dhcp and look at the output of "ifconfig".

You must specify the route to your gateway. To do so, you can edit "/etc/mygate" file or add a "!route" command to "/etc/hostname.if". I prefer the latter as it avoid to split configuration in multiple places.

The gateway is you router's IP : here.

inet   alias
!route add -inet default

See also :

man hostname.if


IPv6 is the new protocol to use facing the lack of ipv4 available. The main advantage is that you don't need a router doing NAT : your machine is directly reachable.

To configure your interface, magic happens in /etc/hostname.if with the "inet6" lines:

inet6   2001:db8:1:1::2    64 # adresse
inet6   autoconf              # SLAAC, if you want
!route add -inet6 default 2001:db8::1

You can mix inet and inet6 instructions.