Setting up static IP on Linux

Posted on


I understand an interface file in Linux needs to be edited and the corresponding lines added. I don’t understand what network and broadcast are for, they seem extraneous compared to a Windows static IP configuration.

In my case my the gateway is and my machine IP is

What would be my network and broadcast address? Is the below correct and what exactly do these lines mean?

iface eth0 inet static


As you can see from the official documentation, those parameters (network and broadcast) are not required.

In fact,

(network, broadcast and gateway are optional)

In your example, your network would be and your broadcast These can be derived from your address and netmask parameters. To understand these parameters and how to determine them, you need to read up on IP subnetting.

In my opinion, the network and broadcast parameters can usually be omitted.

Quick primer

In IP, you usually have an address ( and a netmask (

The netmask explains how many of the bits in the address refer to the network and how many refer to the host. In this example, it’s 24bits (that’s what the netmask means, and that’s what the /24 means which you often see in this context).

These 24bits are exactly the 192.168.5 part of your address. This means, all machines with an address, that starts with 192.168.5 and a netmask of /24, are in your same network.
The remaining part (the 101) is your host part. It identifies your single machine.

When taking an address and fill the host part with zeros (in binary), that is equivalent to the network (so, If you fill the host part with ones (in binary), you get the default broadcast address (

enter image description here

The network and broadcast values are details of your subnet setup. I’m a bit rusty on this but the config you have above seems correct.

If you want to find out more about the Broadcast address and Network mask then I’d suggest reading up on subnetting.

Leave a Reply

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