2

How to configure the veth interface on CentOS 7 in such a way to make it state persistent after system reboot? For example:

veth configuration:

# create veth pair and assing IP address.
ip link add veth0 type veth peer name veth1
ip addr add 10.1.0.1/24 dev veth0
ip addr add 10.1.0.2/24 dev veth1


# bring up the interfaces
ip link set veth0 up
ip link set veth1 up

These settings are saved after network service restart but are not saved after system restart. In the RedHat documentation does not mention now to write ifcfg-vethX interface configuration file or ifup-veth and ifdown-veth scripts for the veth interfaces that should be in /etc/sysconfig/network-scripts.

2 Answers 2

1

You need to create a configuration file for your veth0 interface and place it in
/etc/sysconfig/network-scripts/ifcfg-veth0:

DEVICE="veth0"
TYPE="veth"
DEVICETYPE="Ethernet"
BOOTPROTO="static"
IPADDR="10.1.0.1"
NETMASK="255.255.255.0"
ONBOOT="yes"
NM_CONTROLLED="no"

You also need to copy these scripts and place them in

/etc/sysconfig/network-scripts/ 

directory on your system: Samples:

0

The easiest solution is probably to append the necessary commands to /etc/rc.d/rc.local. This will be executed when the system boots (by the rc-local.service systemd unit).

  1. Create the file /etc/rc.d/rc.local if it doesn't already exist.
  2. Make sure the file is executable (`chmod +x /etc/rc.d/rc.local)
  3. Add the ip commands in your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.