3

I'm trying to understand the syntax of ifupdown a bit better, and on several sites detailing fairly straightforward static configurations, the example documentation includes a line stating `network 192.168.0.0' -- or something obviously similar. For example,

# The loopback network interface
auto lo eth0
iface lo inet loopback

# The primary network interface
iface eth0 inet static
    address 192.168.10.33
    netmask 255.255.255.0
    broadcast 192.168.10.255
    network 192.168.10.0
    gateway 192.168.10.254 
dns-nameservers 192.168.10.254

What exactly does this line do? I can't imagine that it contains anything that the netmask + address doesn't convey about, for example, broadcast addresses. There is much useful documentation about the myriad array of powerful things that one can do with /etc/network/interfaces available online. Almost all of it details various aspects of networking. Therefore, googling isn't terribly helpful!

1
  • It's optional if you got already broadcast an address as explained by Julie. I haven't tested it but possibly it could let you use that line instead of the broadcast one. – phk Jan 2 '17 at 0:21
4

The network doesn't have to be specified as it is simply the result of address & netmask (& is a binary and):

192.168.10.33 & 255.255.255.0 = 192.168.10.0

It may make it easier to understand by showing it in binary:

  11000000.10101000.00001010.00100001 (192.168.10.33)
& 11111111.11111111.11111111.00000000 (255.255.255.0)
-------------------------------------
  11000000.10101000.00001010.00000000 (192.168.10.0)
3
  • So it is just the network prefix. Why does ifconfig allow one to specify it separately, given the facts that essentially everyone has to use subnets, the binary and is many-to-one, and therefore I can't easily foresee a situation under which you might want to specify network explicitly? – Landak Jan 2 '17 at 0:24
  • 1
    Many of those values are inter-changeable since they are calculations on one another and can easily be computed if not specified. – Julie Pelletier Jan 2 '17 at 0:27
  • A common static IP configuration only needs the IP address, gateway and network mask which in its simples form can be represented as address 192.168.10.33/24 for the IP address, along with its gateway. – Julie Pelletier Jan 2 '17 at 0:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.