title: ip addr command setting incorrect subnet mask while assigning IP to an interface as compared to ifconfig command
body: <p>I am trying to set the IP address to an interface on my <code>Ubuntu 18.04</code> machine using <code>ip addr</code> command however the <code>ip addr</code> command sets the subnet mask as <code>255.255.255.255</code> for a Class C IP address where as the <code>ifconfig</code> command sets the subnet mask as <code>255.255.255.0</code> for the same Class C IP address.</p>
  
  <p>Sharing below the commands and their respective outputs.</p>
  
  <p><code>ip addr</code> command and its output.</p>
  
  <pre><code>nvidia@tegra-ubuntu:~$ sudo ip addr flush dev hv0                                                                                                                                                                               
  nvidia@tegra-ubuntu:~$ sudo ip add 192.168.0.2 dev hv0
  nvidia@tegra-ubuntu:~$ ifconfig
  hv0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
          inet 192.168.0.2  netmask 255.255.255.255  broadcast 0.0.0.0
          ether 0a:86:4c:f8:4f:01  txqueuelen 1000  (Ethernet)
          RX packets 867  bytes 77026 (77.0 KB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 756  bytes 71072 (71.0 KB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
          device interrupt 5  
  
  </code></pre>
  
  <p><code>ifconfig</code> command and its output.</p>
  
  <pre><code>nvidia@tegra-ubuntu:~$ sudo ip addr flush dev hv0
  nvidia@tegra-ubuntu:~$ sudo ifconfig hv0 192.168.0.2 up                                                                                                                                                                                       
  nvidia@tegra-ubuntu:~$ ifconfig
  hv0: flags=4163&lt;UP,BROADCAST,RUNNING,MULTICAST&gt;  mtu 1500
          inet 192.168.0.2  netmask 255.255.255.0  broadcast 192.168.0.255
          ether 0a:86:4c:f8:4f:01  txqueuelen 1000  (Ethernet)
          RX packets 867  bytes 77026 (77.0 KB)
          RX errors 0  dropped 0  overruns 0  frame 0
          TX packets 756  bytes 71072 (71.0 KB)
          TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
          device interrupt 5  
  </code></pre>
  
  <p>I would like to understand whether this is expected behavior or is this an issue with the <code>ip addr</code> command.</p>
  
  <p>I also understand the mechanism to overcome this issue is to explicitly however I do not want to use them as if now and would like to understand the reason behind this change of behavior.</p>