Netmask Set With Ifconfig Doesn’t Hold

Home » CentOS » Netmask Set With Ifconfig Doesn’t Hold
CentOS 3 Comments

I gather that ifconfig is a way of setting the netmask in the current shell instead of a persistent value.  I say this because I am running it and see it for my specific network interface, directly after running it. However if I restart the network service the netmask is reverted to the previous value. What is the correct way to set the new netmask for the network interface to make it persistent.  
if it’s different for CentOS 6 and 7 I’d like to know that too. FYI – I tried searching about this but none of the info has really helped so far.  Also consider this like “changing netmask for dummies” since I am not an administrator and am just searching and trying these things. Thanks very much in advance.KM

3 thoughts on - Netmask Set With Ifconfig Doesn’t Hold

  • CentOS 6 & 7 use network manager to control the interfaces. Probably the easiest way to edit a connection for inexperienced users from the command line is ‘nmtui’.

    You can also use ‘nmcli’ from the command line, but you have to craft the command yourself and it can get quite involved if you don’t know what you are doing.

    You may need to restart the network to pick up the new config after editing it.

    P.

  • I should have mentioned that I tried nmtui but found no settings for a netmask anywhere.  like I said …. dummy.KM
    CentOS 6 & 7 use network manager to control the interfaces.  Probably the easiest way to edit a connection for inexperienced users from the command line is ‘nmtui’.

    You can also use ‘nmcli’ from the command line, but you have to craft the command yourself and it can get quite involved if you don’t know what you are doing.

    You may need to restart the network to pick up the new config after editing it.

    P.

  • It’s part of the IP address – so you put something like

    192.168.0.1/24

    for a 255.255.255.0 subnet. It’s called a CIDR address.

    P.