User Tools

Site Tools


sysconfig:networking

Network Configuration

Cucumber Linux network configuration is handled by the network-scripts package. This package provides the network init script (/etc/rc.d/init.d/network) as well as the /sbin/ifup, /sbin/ifdown and /sbin/ifhelp scripts. The actual configuration files are stored in /etc/network.

Configuring a Network Interface

Each network interface to be configured by the network scripts has a config file under /etc/network/interfaces. The file name is the name of the interface to configure. Each config file is required to define the following two fields:

ONBOOT=<yes|no>
METHOD=static

The ONBOOT field tells the network init script whether or not this interface should automatically be brought up when the system boots. A value of yes tells the network script to bring it up with the system. Any other value tells the network script not to.

The METHOD field tells the network scripts how the interface should be configured (i.e. static for a static ip address). For a list of valid configuration methods for your system, run ls /etc/network/methods. Each method works differently, and each method requires different fields in the /etc/network/interfaces/<interface> file. For documentation about a specific method, run ifhelp <method>. Additionally, most methods provide a template file for you in /etc/network/templates.

Manually Bringing Interfaces Up and Down

The ifup script allows you to manually bring a network interface up. The syntax is ifup <interface>. The interface must exist in /etc/network/interfaces for this to work.

The ifdown script allows you to manually bring a network interface down. The syntax is ifdown <interface>. The interface must exist in /etc/network/interfaces for this to work.

Example Configurations

Configuring an Ethernet Interface with DHCP

In this example, we will configure the ethernet interface enp0s3. If your ethernet interface has a different name, replace enp0s3 with the name of your ethernet interface. A list of all present network interfaces can be obtained by running ifconfig -a.

  1. First, copy over the DHCP configuration template by running cp /etc/network/templates/dhcp /etc/network/interfaces/enp0s3.
  2. Next, edit the file you just created (/etc/network/interfaces/enp0s3) using your favorite text editor. Change the line ONBOOT=no to ONBOOT=yes.
  3. Finally, restart the networking service by running /etc/init.d/network restart.

That's it. Wait a minute for your machine to get assigned an IP address, and then your ethernet interface will be ready to use.

sysconfig/networking.txt · Last modified: 2017/08/29 09:46 by 192.168.2.1