Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to change my Ubuntu to static IP. My current IP setting is:

eth0      Link encap:Ethernet  HWaddr 00:0c:29:xx:xx:xx  
      inet addr:192.168.16.59  Bcast:192.168.31.255  Mask:255.255.240.0
      inet6 addr: fe80::20c:xx:xx:xx/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:234690 errors:0 dropped:0 overruns:0 frame:0
      TX packets:1864 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:22953435 (22.9 MB)  TX bytes:205616 (205.6 KB)

what should I put as the network in /etc/network/interfaces (note the network mask of 255.255.240.0)?

share|improve this question
    
What exactly do you have trouble with? I don't see any network statements in interfaces(5). You might consider rephrasing your question and add some details. –  Andreas Wiese Mar 31 '14 at 19:56
    
Stop using ifconfig, use ip addr instead. This is what ifupdown (the software that parses /etc/network/interfaces) uses under the hood anyway, so you will definitely want to get used to it. –  BatchyX Mar 31 '14 at 20:06
    
@BatchyX, I use ip addr for other things but not this one, because it'd be worse that ifconfig -- ifconfig at least gives me address, broadcast & netmask, but ip addr doesn't give me netmask, at least my version doesn't. –  xpt Apr 1 '14 at 2:40
    
@xpt: ip addr gives you the modern CIDR prefix length just next to the IP address. It also accept old-style netmask on input (i.e. 192.168.31.254/255.255.240.0) –  BatchyX Apr 2 '14 at 17:52

1 Answer 1

up vote 1 down vote accepted

If I'm understanding your question, to set a static IP, your network runs from 191.168.16.1 - 191.168.31.254, with the identity address at 192.168.16.0 and the broadcast at 192.168.31.255. I've never had to use the Network keyword, but I've never used a supernet address on a host. I've only seen them used for route aggregation.

 auto eth0
 iface eth0 inet static
 address 192.168.16.59
 network 192.168.16.0
 netmask 255.255.240.0
 broadcast 192.168.31.255
 gateway 192.168.0.1
share|improve this answer
    
My IP is not a good example for network for this case. I guess if my IP is 192.168.18.159, my network value is still 192.168.16.0, correct? BTW, are you saying that is network optional for /etc/network/interfaces? I'm following guylabs.ch/2013/07/25/configure-a-static-ip-in-ubuntu-13-04, and there is a network there. –  xpt Apr 1 '14 at 2:29
    
it depends on your network mask. for the Class C network 192.168.X.Y, a subnetted network would have >24 bits of mask (255.255.255.0-252), a supernetted net would have < 24 bits mask (255.0-255.0-252.0), and a normal (class natural) Class C would be 255.255.255.0. which one it is defines the "shape" of your IP address layout. –  Frank Thomas Apr 1 '14 at 11:27
    
Yeah, all these is because of the supernetted net, a term that I just learned from you. Otherwise, for 255.255.255.0 network mask, the examples are everywhere. So again, to confirm, for network mask of 255.255.240.0, for all IP of 192.168.18.*, 192.168.28.* till 192.168.31.*, their network value are all 192.168.16.0, right? –  xpt Apr 1 '14 at 14:07
1  
yep. now that said, there is the possibility that subnetworks are defined under this address space, so make sure when configuring systems in this way that they all have a 255.255.240.0 mask. if you see any more confining masks (more than 20 bits) you will need to recalculate the network range, ID, and broadcast when configuring systems on that network. I use this calculator: subnet-calculator.com –  Frank Thomas Apr 1 '14 at 14:16
1  
network is totally ignored by ifupdown, the system can figure it by itself anyway. Your broadcast is useless here: the system will pick the same in your case. Your gateway is not part of your subnet, so ifupdown will fail at that point. –  BatchyX Apr 2 '14 at 18:00

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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