How can I configure a static IP v4 address?
Environment
- Red Hat Enterprise Linux 4
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
Issue
- I would like to configure a static IP address on my RHEL server.
Resolution
For RHEL 7 with NetworkManager, please see How to configure IP addressing with NetworkManager (nmcli) in RHEL 7
-
Create an
ifcfgfile in the/etc/sysconfig/network-scripts/directory for the interface. Assuming the interface is namedeth0, set the IP address and netmask as needed:$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 ONBOOT=yes BOOTPROTO=none IPADDR= NETMASK= # *** HWADDR is only required for RHEL 5 and below *** # HWADDR= # # Other optional parameters: # GATEWAY= # DNS1= # DNS2= # DOMAIN= -
Once the configuration file has been defined, it can be activated with the
ifupcommand:# ifup eth0
Diagnostic Steps
-
If needed, the MAC address (HWADDR) can be found with the
ip linkcommand:$ ip link show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 1c:c1:de:ee:4e:e8 brd ff:ff:ff:ff:ff:ff ^ MAC address
SBR
Product(s)
Components
Category
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.