cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Etc


Reference














.

os:linux:network:ifcfg.html



Linux#Netowrk

Configuration - How to Configure Network Interface in Linux

RHEL/CentOS

/etc/sysconfig/network-scripts/ifcfg-*

Configuration

Option Explanation
DEVICE the name of the physical device
BOOTPROTO none : No boot-time protocol should be used. Static IP use 'none'.
dhcp : The DHCP protocol should be used.
bootp : The BOOTP protocol should be used.
'STATIC' is invalid parameter. if you use 'STATIC', it see 'NONE'.
ONBOOT yes : This device should be activated at boot-time.
no : This device should not be activated at boot-time.
IPADDR IP address.
NETMASK the netmask value.
USERCTL yes : Non-root users are allowed to control this device.
no : Non-root users are not allowed to control this device.
HWADDR the hardware address of the Ethernet device in the form AA:BB:CC:DD:EE:FF.
SLAVE yes : This device is controlled by the channel bonding interface specified in the MASTER directive.
no : This device is not controlled by the channel bonding interface specified in the MASTER directive.
ETHTOOL_OPTS any device-specific options supported by ethtool.
GATEWAY the IP address of the network router or gateway device (if any).


Sample Configurations

Sample : DHCP

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes

Sample : Static IP

/etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.5
NETMASK=255.255.255.0
USERCTL=no


Reference

Debian/Ubuntu

/etc/network/interfaces

DHCP Sample

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

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp

Static IP Sample

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

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto ens3
#iface ens3 inet dhcp
iface ens3 inet static
address 192.168.10.30
network 192.168.10.0
netmask 255.255.255.0
broadcast 10.0.0.255
gateway 192.168.10.1
dns-nameservers 192.168.10.10



os/linux/network/ifcfg.html.txt ยท Last modified: 2018/01/03 by admin

Page Tools