Static IP with NetPlan

31,849

Solution 1

That is called CIDR notation where the first part is your IP address like 192.168.1.100 and the second part is your netmask like /24.

Together they would look like:

192.168.1.100/24

The /24 CIDR is actually for the netmask like the following:

CIDR | MASK
/24  | 255.255.255.0   
/25  | 255.255.255.128  
/26  | 255.255.255.192  
/27  | 255.255.255.224  
/28  | 255.255.255.240  
/29  | 255.255.255.248  
/30  | 255.255.255.252  
/31  | 255.255.255.254  
/32  | 255.255.255.255  

/24 is the most common in home networks. Linksys and other such routers will assign on IPv4 DHCP records that will look like 192.168.1.100 where the gateway or router IP address is 192.168.1.1. And with a subnet mask of /24 or 255.255.255.0 that means that the IP address octets have to match from 192.168.1.xxx where the last 3 digits can be anything from 1-254 to be in the same subnet.

One tool that I use on a daily basis especially with my job is the Online IP Subnet Calculator. Just to give you something along what your IP might be. I am not sure what your IP is. I am assuming it is a Public Static IP. So, I am going to use a made up IP as 74.172.65.26 with your mask of 255.255.255.252.

enter image description here

Just on the quick image there we can see that the Mask Bits is 30, so the notation would be 74.172.65.26/30 Which would mean that our gateway should be 74.172.65.25 which has to be in the same subnet as our IP address. Clicking on the CIDR just above switches to a slightly different calculator, but I input the same information and received about the same in return.

enter image description here

There we can see that our route would be 74.172.65.24 as our network and our network CIDR Notation would be 74.172.65.24/30 but that is not our IP address. Our broadcast on that network is 74.172.65.27 as that is the highest IP. This is the equivalent of an IP of 192.168.1.15 mask 255.255.255.0 network where our network CIDR Notation would be 192.168.1.0/24 and our broadcast would be 192.168.1.255 and our gateway IP would be more than likely at 192.168.1.1.

Hope this helps!

Solution 2

The way you do it at the beginning of Ubuntu 18.x plus installation, if you go static is:

Netmask: 10.10.10.0/24 (don´t put 255.255.255.0, it won´t work)
IP:      10.10.10.20
GW:      10.10.10.1
DNS:     10.10.10.1 etc

That should work!

Share:
31,849

Related videos on Youtube

mr_wahoo
Author by

mr_wahoo

Updated on September 18, 2022

Comments

  • mr_wahoo
    mr_wahoo over 1 year

    I have a dev server with a Comcast static ip that has worked wonderfully for 10 years...went to upgrade to Ubuntu 18.04 and whats this NetPlan biznezz and why will it not accept my subnet?

    Followed all documentation from Comcast (like I have every other time I have formatted this machine) and it is asking for xx.xx.xx.xx/xx bit set. I generally know what this means but I am lost...

    Let me be a tad bit clearer...I am doing a fresh install and choosing my network device from the start...so essentially setting up the netplan config from "go"....

    • chili555
      chili555 almost 6 years
      Have you set up your netplan file? May we see a redacted copy, like xx.154.23.18, etc. What is the response to: sudo netplan apply?
    • mr_wahoo
      mr_wahoo almost 6 years
      I dont have a netplan file as of yet. There is no response because I cannot get that far. This is an external static ip from Comcast. the ip is 75.151.xxx.226. The gateway is 75.151.xxx.230. Comcast tells me the subnet is 255.255.255.252. I do not know what the bit set would be. Comcast says to use /30. Or /29 for a range. Neither worked.
    • chili555
      chili555 almost 6 years
      No netplan file?? What is the result of: cat /etc/netplan/*.yaml? This may get you started. If needed, I will write a complete answer in a few hours. askubuntu.com/questions/1019610/…
    • mr_wahoo
      mr_wahoo almost 6 years
      Okay...currently, I am on the installations screen for network devices. On my first attempt at installation. I did not reading and shot straight for /etc/network/interfaces. After reading, I went to /etc/netplan/50--.yaml and tried to configure it there. Didnt work. I can just install the whole thing and come back to the netplan file, but that does me no good if I do not know what works in it.
    • Terrance
      Terrance almost 6 years
      According to subnet-calculator.com/subnet.php?net_class=A when I put in say 75.151.250.226 as your IP, which is just a guess and when I need the 75.151.250.230 gateway, that is a /29 or 255.255.255.248 netmask. Given that Comcast is putting in the gateway in your same subnet. I just have CenturyLink and their is completely different where they mask at 255.255.255.255 or /32 with a gateway that is not in the subnet. They do it by routing.
    • mr_wahoo
      mr_wahoo almost 6 years
      Hey thanks! let me look at that...I have tried what you are saying and it will give me an okay for the the 255.248 mask, then tell me the IP is not in range...
    • Terrance
      Terrance almost 6 years
      You are adding the gateway as a separate line and as only the IP itself without the /29 on it, right?
    • mr_wahoo
      mr_wahoo almost 6 years
      Okay here's what just happened...I went to where you said..when I used the subnet ID for the mask everything clicked....gonna run with that and see what happens. I am not in any file...I am doing this from a bare install...on Ubuntu 18.04 server
    • mr_wahoo
      mr_wahoo almost 6 years
      That wrrked. FYI: I used the subnet mask ID from the site you linked too. It works. I shelld into my account from my workcomp just now...seems okay...
  • mr_wahoo
    mr_wahoo almost 6 years
    This isnt a home network. This is a development web/* server utilizing Comcast static ips. My problem is when I try to apply the 255.255.255.252 subnet. I do not know what the /* would be. I keep getting a "has bits set" error. I would really like to use this version but I may either not use netplan or go back to 16. I really appreciate any help. Thanks!
  • Terrance
    Terrance almost 6 years
    @mr_wahoo I added in some more edits and a tool that I use on a daily basis that might help you determine what your /* would be. I am assuming that yours would have to be a /30 on a 255.255.255.252 masked network.
  • mr_wahoo
    mr_wahoo almost 6 years
    Hey! I got it. The guy above sent me the same link. Never knew about that site. Thanks so much for your responses. I hope to be able to answer as fast for ppl as you guys do one day! Thanks again!
  • Terrance
    Terrance almost 6 years
    @mr_wahoo Keep learnin! There is so much potential out there and believe it or not, but I have fun with this! I find it challenging and when I help people I in turn learn a lot myself. :) Keep up the good work!
  • Terrance
    Terrance almost 6 years
    @mr_wahoo By the way, I am that same guy! =)
  • mr_wahoo
    mr_wahoo about 5 years
    I apologize. I forgot to mark the answer. I appreciate your input. Thanks!