I would like to change the netmask of an ubuntu 19.04 using netplan. I edited the only yaml file that I had, that is \etc\netplan\50-cloud-init.yaml
network:
ethernets:
ens160:
addresses: [10.100.0.78/24]
gateway4: 10.100.0.253
dhcp4: no
nameservers:
addresses: [10.100.0.8,10.100.0.9]
optional: true
version: 2
but if i give the command ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:50:56:bc:ff:52 brd ff:ff:ff:ff:ff:ff
inet 10.100.0.78/24 brd 10.100.0.255 scope global ens160
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:febc:ff52/64 scope link
valid_lft forever preferred_lft forever
I would like the netmask to be 255.255.0.0 . where is the netmask setting?
What is typically called the 'netmask' is the older way of defining the netmask. The netmask however is able to be converted to CIDR ranges, which is easier for some people to discuss/understand in documents where the netmask isn't calculated in their heads easily. As such, for Netplan, the netmask is defined via CIDR ranges attached to the IP address definition. (The University of Wisconsin has a nice thorough CIDR conversion table for netmask to CIDR if you wish to review this in depth or keep this for your records)
The
/24
on the end of your address indicates the CIDR prefix which in turn correlates to the netmask definitions. The netmask of /24 is 255.255.255.0.You want that mask to be
255.255.0.0
which correlates to a/16
CIDR range, so specify a/16
instead of a/24
, and update yourgateway4
accordingly.Then, run
sudo netplan apply
afterwards, and it should apply. (Or reboot the system).