Setting a Static IP in Fedora/CentOS/RHEL

  1. Log into a terminal as a user who has sudo permissions
  2. Run the ifconfig command to check the name of the interface you want to set as static.

    In our case the adapter’s label is ens33
  3. The configuration file is located in /etc/sysconfig/network-scripts/ so we’ll open up the text file in the vi text editor using the command sudo vi /etc/sysconfig/network-scripts/ifcfg-ens33
    Note: ens33 in the file name is to be replaced with the desired interface name
  4. After opening the configuration file, use the arrow buttons to navigate to BOOTPROTO= and, pressing the i button for insert mode, set the value after the equals sign to “static”

  5. Navigate to or create the IPADDR line and set the desired IP after the equals sign
  6. Navigate to or create the PREFIX line and enter the subnet mask length in bits (eg 192.168.1.1/24 has a 24 bit subnet mask length)
  7. Navigate to or create the GATEWAY line and enter the IP address of the network’s default gateway
  8. Navigate to or create the  DNS1 line and enter the IP address of the primary DNS server
  9. Navigate to or create the  ONBOOT line and set the value to “yes”
  10. If a second DNS server is required, make a newline and type DNS2= with the secondary DNS server IP following
  11. Press Esc then :wq to exit insert mode then save and quit the editor
  12. To apply the changes, restart the interface with ifdown ens33 then ifup ens33

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.