How To Set DHCP/Static IP Address in Centos/RHEL/Fedora & Debian/Ubuntu/Kubuntu/MEPIS Set DHCP/Static IP Address

Basically the two main types of distros are Debian and RHEL/Centos based.  I'm just going to give a quick overview of how the configuration of IP interfaces works in Debian/Centos based distros.

*Just one thing to remember, when setting IPs statically you have to manually specify a DNS server in /etc/resolv.conf (since DHCP is what normally does it automatically)

Debian/Ubuntu/Kubuntu/MEPIS

The IP (DHCP & Static) configuration is done from the following file: /etc/network/interfaces

Here is how the default DHCP configuration looks:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
auto eth0
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet dhcp

Here is an example of setting it statically:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
auto eth0
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
iface eth0 inet static
        address 192.168.1.147
        netmask 255.255.255.0
        gateway 192.168.1.1

 

How to Add Multiple IPs in Debian/Ubuntu

auto eth0:0

iface eth0:0 inet static

    address  192.168.1.148

    netmask 255.255.255.0

    gateway 192.168.1.1


auto eth0:1

iface eth0:1 inet static

    address  192.168.1.149

    netmask 255.255.255.0

    gateway 192.168.1.1

 

*Just one thing to remember, when setting IPs statically you have to manually specify a DNS server in /etc/resolv.conf (since DHCP is what normally does it automatically)

 

 


 

Centos/RHEL/Fedora/Mandriva

The IP (DHCP & Static) configuration is done from the following file : /etc/sysconfig/network-scripts/ifcfg-eth0

*Note the "eth0" at the end, each device has it's own entry within the network-scripts directory.

Here is how the default DHCP configuration looks:

# Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=5A:G1:29:4A:1C:76
ONBOOT=yes

Here is an example of setting it statically:

DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.245
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
ONBOOT=YES

*Just one thing to remember, when setting IPs statically you have to manually specify a DNS server in /etc/resolv.conf (since DHCP is what normally does it automatically)


Tags:

dhcp, static, ip, centos, rhel, fedora, debian, ubuntu, kubuntu, mepis, addressbasically, distros, overview, configuration, interfaces, ips, statically, manually, specify, dns, server, etc, resolv, conf, automatically, default, describes, activate, loopback, interface, auto, eth, iface, inet, primary, hotplug, netmask, gateway, multiple, mandriva, sysconfig, scripts, ifcfg, quot, entry, directory, realtek, semiconductor, ltd, rtl, pci, gigabit, ethernet, controller, bootproto, hwaddr, onboot, ipaddr,

Latest Articles

  • vi cannot copy and paste automatic visual mode solution
  • python3 error Ubuntu Linux error solution SyntaxError: invalid syntax line 12 pip{sys.version_info.major}
  • Could not read response to hello message from hook [ ! -f /usr/bin/snap ] || /usr/bin/snap advise-snap --from-apt 2>/dev/null || true: Connection reset by peer
  • -bash: expr: command not found Linux Debian Mint Ubuntu
  • How to remove metadata from pdf on Linux Ubuntu
  • How to install and configure haproxy on Linux Ubuntu Debian
  • Linux Ubuntu Mint Gnome keyboard Typing not working in certain application or window solution
  • talib/_ta_lib.c:747:10: fatal error: ta-lib/ta_defs.h: No such file or directory
  • How to install Windows or other OS and then bring to another computer by using a physical drive and Virtual Machine with QEMU
  • PXE-E23 Error BOOTx64.EFI GRUB booting is 0 bytes tftp pxe dhcp solution NBP filesize is 0 Bytes
  • vagrant install on Debian Mint Ubuntu Linux RHEL Quick Setup Guide Tutorial
  • RHEL 8 CentOS 8, Alma Linux 8, Rocky Linux 8 System Not Booting with RAID or on other servers/computers Solution for dracut and initramfs missing kernel modules
  • How to Upgrade to Debian 11 from Version 8,9,10
  • Ubuntu Linux Mint Debian Redhat Cannot View Files on Android iPhone USB File Transfer Not Working Solution
  • Virtualbox Best Networking Mode In Lab/Work Environment without using NAT Network or Bridged
  • debootstrap how to install Ubuntu, Mint, Debian install
  • Linux grub not using UUID for the root device instead it uses /dev/sda1 or other device name solution
  • How To Restore Partition Table on Running Linux Mint Ubuntu Debian Machine
  • Debian Ubuntu apt install stop daemon questions/accept the default action without prompting
  • iptables NAT how to enable PPTP in newer Debian/Ubuntu/Mint Kernels Linux