How can I add a sub-interface in CentOS 7?
I have an application that requires a separate interface for the public IP and the private IP however a Linode only comes with one interface. I want to try using a sub-interface but I'm not sure how to go about setting that up. I'm using CentOS 7.
1 Reply
You can create a sub-interface in CentOS7 by creating a new interface network-script. For instance, a Linode will be provisioned with the interface "eth0" automatically, to create the sub-interface "eth0:1" you would need to create the script file "ifcfg-eth0:1" in the network-scripts directory:
/etc/sysconfig/network-scripts/ifcfg-eth0:1
Once you've created that file you'll need to provision it with the correct parameters. Using the example address 192.168.1.10/24 with the default-gateway 192.168.1.1 the file would need to be configured like this:
DEVICE="eth0:1"
NAME="eth0:1"
ONBOOT="yes"
BOOTPROTO="none"
GATEWAY=192.168.1.1
IPADDR=192.168.1.10
PREFIX0=24
Save the changes and then make sure that the Network Helper feature is turned off (if not it will rewrite your interface file changes):
You can then reboot the Linode and the sub-interface will be provisioned with the IP specified in the network-script configuration.