Linux 7 Configuring a Network Interface: Difference between revisions
(12 intermediate revisions by the same user not shown) | |||
Line 13: | Line 13: | ||
<tt>ifcfg-eth0</tt> example: | <tt>ifcfg-eth0</tt> example: | ||
< | <syntaxhighlight lang='bash'> | ||
DEVICE= | DEVICE=eth0 | ||
NAME= | NAME=eth0 | ||
TYPE= | UUID=539b9873-04b8-44cc-aa01-6e9911eaa244 | ||
ONBOOT= | #HWADDR=52:54:00:70:a5:21 | ||
IPADDR= | TYPE=Ethernet | ||
NETMASK= | ONBOOT=yes | ||
PREFIX= | BOOTPROTO=none | ||
GATEWAY= | IPADDR=192.168.1.9 | ||
DNS1= | NETMASK=255.255.255.0 | ||
PREFIX=24 | |||
GATEWAY=192.168.1.1 | |||
IPV4_FAILURE_FATAL= | DNS1=8.8.8.8 | ||
IPV6INIT= | DEFROUTE=yes | ||
IPV6_AUTOCONF= | PEERDNS=no | ||
IPV6_DEFROUTE= | PEERROUTES=no | ||
IPV6_FAILURE_FATAL= | IPV4_FAILURE_FATAL=yes | ||
IPV6_PEERDNS= | IPV6INIT=no | ||
IPV6_PEERROUTES= | IPV6_AUTOCONF=no | ||
IPV6_PRIVACY= | IPV6_DEFROUTE=no | ||
</ | IPV6_FAILURE_FATAL=no | ||
IPV6_PEERDNS=no | |||
IPV6_PEERROUTES=no | |||
IPV6_PRIVACY=no | |||
PROXY_METHOD=none | |||
BROWSER_ONLY=no | |||
</syntaxhighlight> | |||
=Configuration= | =Configuration= | ||
==IPADDR== | ==<tt>DEVICE</tt>== | ||
==<tt>IPADDR</tt>== | |||
==NETMASK== | ==<tt>NETMASK</tt>== | ||
==<tt>PREFIX</tt>== | |||
==PREFIX== | ==<tt>GATEWAY</tt>== | ||
==<tt>UUID</tt>== | |||
==UUID== | A unique ID for the interface. | ||
A unique value can be created with [[uuidgen]] | A unique value can be created with [[uuidgen]] | ||
==<tt>HWADDR</tt>== | |||
==HWADDR== | |||
Specifying the hardware or MAC address using the HWADDR directive will influence the device naming procedure. | Specifying the hardware or MAC address using the HWADDR directive will influence the device naming procedure. | ||
==<tt>DEFROUTE</tt>== | |||
{{Internal|Linux_Routing_Configuration#Default_Route|Linux Routing Configuration}} | |||
==<tt>PEERDNS</tt>== | |||
The ifcfg parameter PEERDNS determines if the file [[/etc/resolv.conf]] is modified or not. If it is set to "yes", then the parameters DOMAIN, DNS1 and DNS2 will be used to set the search and nameserver entries in the file. If PEERDNS is set to "no", the file is not modified. | |||
== | PEERDNS defaults to no unless DHCP is used, in which case it defaults to yes. If DHCP is used, usually we want to set PEERDNS to yes, unless more than one interfaces are configured, and other interface will configure DNS. | ||
==<tt>IPV6_PEERDNS</tt>== | |||
=Change the IP Address= | =Change the IP Address= | ||
Line 65: | Line 72: | ||
PREFIX="16" | PREFIX="16" | ||
NETMASK="255.255.0.0" | NETMASK="255.255.0.0" | ||
GATEWAY="172.20.1.1" | |||
</pre> | </pre> | ||
Note that this is how a static address is changes even if [[NetworkManager]] is active. | |||
=Configure a Network Interface after Cloning a VM Image= | =Configure a Network Interface after Cloning a VM Image= | ||
Line 75: | Line 85: | ||
=Change the UUID= | =Change the UUID= | ||
Use <tt>[[uuidgen]]</tt>. | Use <tt>[[uuidgen]]</tt> and replace the value from the the ifcfg-* file. |
Latest revision as of 23:51, 29 March 2021
External
Internal
Overview
The configuration files corresponding to the network interfaces are located in /etc/sysconfig/network-scripts.
ifcfg-eth0 example:
DEVICE=eth0
NAME=eth0
UUID=539b9873-04b8-44cc-aa01-6e9911eaa244
#HWADDR=52:54:00:70:a5:21
TYPE=Ethernet
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.1.9
NETMASK=255.255.255.0
PREFIX=24
GATEWAY=192.168.1.1
DNS1=8.8.8.8
DEFROUTE=yes
PEERDNS=no
PEERROUTES=no
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=no
IPV6_DEFROUTE=no
IPV6_FAILURE_FATAL=no
IPV6_PEERDNS=no
IPV6_PEERROUTES=no
IPV6_PRIVACY=no
PROXY_METHOD=none
BROWSER_ONLY=no
Configuration
DEVICE
IPADDR
NETMASK
PREFIX
GATEWAY
UUID
A unique ID for the interface.
A unique value can be created with uuidgen
HWADDR
Specifying the hardware or MAC address using the HWADDR directive will influence the device naming procedure.
DEFROUTE
PEERDNS
The ifcfg parameter PEERDNS determines if the file /etc/resolv.conf is modified or not. If it is set to "yes", then the parameters DOMAIN, DNS1 and DNS2 will be used to set the search and nameserver entries in the file. If PEERDNS is set to "no", the file is not modified.
PEERDNS defaults to no unless DHCP is used, in which case it defaults to yes. If DHCP is used, usually we want to set PEERDNS to yes, unless more than one interfaces are configured, and other interface will configure DNS.
IPV6_PEERDNS
Change the IP Address
Modify/verify the following set of variables. Make sure the hardware address is correct.
DEVICE=eth0 HWADDR="08:00:27:0A:79:9F" IPADDR="172.20.1.3" PREFIX="16" NETMASK="255.255.0.0" GATEWAY="172.20.1.1"
Note that this is how a static address is changes even if NetworkManager is active.
Configure a Network Interface after Cloning a VM Image
In general, when cloning a system, you want to generated a different Mac address when cloning an image, to avoid collisions.
If "HWADDR" is set pointing to the old hardware address, we want to remove it from the cloned configuration file, because if it stays there, and the hardware address is not available, the interface won't start.
Change the UUID
Use uuidgen and replace the value from the the ifcfg-* file.