• Aucun résultat trouvé

Understanding NetworkManager Configuration Files

Whether you use the graphical NetworkManager or the text-based system-confi g-network, the changes you make are written to the same confi guration fi les. In the directory /etc/

sysconfig/network-scripts, you’ll fi nd a confi guration fi le for each network interface on your server. The names of all of these fi les start with ifcfg- and are followed by the names of the specifi c network cards. If your network card is known as p6p1, for example, its con-fi guration is stored in /etc/sysconfig/network-scripts/ifcfg-p6p1. Listing 6.2 shows what the content of the network-scripts directory might look like. (The exact content depends on the confi guration of your server.)

Listing 6.2: Network configuration files are stored in /etc/sysconfig/network-script.

[root@hnl network-scripts]# ls

ifcfg-lo ifdown-ipv6 ifup ifup-plip ifup-wireless ifcfg-p6p1 ifdown-isdn ifup-aliases ifup-plusb init.ipv6-global ifcfg-wlan0 ifdown-post ifup-bnep ifup-post net.hotplug ifdown ifdown-ppp ifup-eth ifup-ppp network-functions ifdown-bnep ifdown-routes ifup-ippp ifup-routes network-functions-ipv6 ifdown-eth ifdown-sit ifup-ipv6 ifup-sit

ifdown-ippp ifdown-tunnel ifup-isdn ifup-tunnel [root@hnl network-scripts]#

c06.indd 161

c06.indd 161 1/8/2013 10:45:04 AM1/8/2013 10:45:04 AM

fi guration for the network card p6p1 that was confi gured in the preceding sections.

Listing 6.3: Sample contents of a network configuration file

[root@hnl network-scripts]# cat ifcfg-p6p1 DEVICE=p6p1

NM_CONTROLLED=yes ONBOOT=yes TYPE=Ethernet BOOTPROTO=none DEFROUTE=yes

IPV4_FAILURE_FATAL=yes IPV6INIT=no

NAME="System p6p1"

UUID=131a1c02-1aee-2884-a8f2-05cc5cd849d9 HWADDR=b8:ac:6f:c9:35:25

IPADDR=192.168.0.70 PREFIX=24

GATEWAY=192.168.0.254 DNS1=8.8.8.8

USERCTL=no

Different variables are defi ned in the confi guration fi le. Table 6.1 lists all these variables.

TA B L E 6 .1 Common ifcfg configuration file variables

Parameter Value

DEVICE Specifies the name of the device, as it is known on this server.

NM_CONTROLLED Specifies whether the device is controlled by the Net-workManager service, which is the case by default.

ONBOOT Indicates that this device is started when the server boots.

TYPE Indicates the device type, which typically is Ethernet.

BOOTPROTO Set to dhcp if the device needs to get an IP address and additional configuration from a DHCP server. If set to any-thing else, a fixed IP address is used.

c06.indd 162

c06.indd 162 1/8/2013 10:45:04 AM1/8/2013 10:45:04 AM

DEFROUTE If set to yes, the gateway that is set in this device is also used as the default route.

IPV4_FAILURE_FATAL Indicates whether the device should fail to come up if there is an error in the IPv4 configuration.

IPV6INIT Set to yes if you want to use IPv6.

NAME Use this to set a device name.

UUID As names of devices can change according to hardware

configuration, it might make sense to set a universal unique ID (UUID). This UUID can then be used as a unique identifier for the device.

HWADDR Specifies the MAC address to be used. If you want to use a different MAC address than the one configured on your network card, this is where you should change it.

IPADDR Defines the IP address to be used on this interface.

PREFIX This variable defines the subnet mask in CIDR format.

The CIDR format defines the number of bits in the sub-net mask and not the dotted decimal number, so use 24 instead of 255.255.255.0.

GATEWAY Use this to set the gateway that is used for traffic on this network card. If the variable DEFROUTER is also set to yes, the router specified here is also used as the default router.

DNS1 This parameter specifies the IP address of the first DNS server that should be used. To use additional DNS serv-ers, use the variables DNS2 and, if you like, DNS3 as well.

USERCTL Set to yes if you want end users to be able to change the network configuration. Typically, this is not a very good idea on servers.

Normally, you probably want to set the network confi guration by using tools like NetworkManager or system-config-network. However, you also can change all param-eters from the confi guration fi les. Because the NetworkManager service monitors these confi guration fi les, all changes you make in the fi les are picked up and applied immediately.

c06.indd 163

c06.indd 163 1/8/2013 10:45:04 AM1/8/2013 10:45:04 AM

The network confi guration on Red Hat Enterprise Linux is managed by the

NetworkManager service. This service doesn’t require much management, because it is enabled by default. Also, in contrast to many other services that you might use on Linux, it picks up changes in confi guration automatically. While it is commonly necessary to restart a service after changing the confi guration, this is not the case for NetworkManager.

Apart from the NetworkManager service (/etc/init.d/NetworkManager), there’s also the network service (/etc/init.d/network). The network service is what enables all net-work cards on your server. If you stop it, all netnet-working on your server will be ceased.

The NetworkManager service is used for managing the network cards. Stopping the NetworkManager service doesn’t stop networking; it just stops the NetworkManager pro-gram, which means you need to fall back to manual management of the network interfaces on your server.

Configuring Networking from the