Create sub interface on CentOS

How to create sub interface on CentOS

 

1. Currently we have interface eth0 on our Server

[root@localhost Desktop]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bf:74:53 brd ff:ff:ff:ff:ff:ff
inet 192.168.11.20/24 brd 192.168.11.255 scope global eth0
inet6 fe80::20c:29ff:febf:7453/64 scope link
valid_lft forever preferred_lft forever
3: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
link/ether a2:ad:23:a0:dd:3d brd ff:ff:ff:ff:ff:ff
[root@localhost Desktop]#

2. Create sub interface by command on Centos

[root@localhost network-scripts]# ifconfig eth0:1 192.168.11.200
[root@localhost network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bf:74:53 brd ff:ff:ff:ff:ff:ff
inet 192.168.11.20/24 brd 192.168.11.255 scope global eth0
inet 192.168.11.200/24 brd 192.168.11.255 scope global secondary eth0:1
inet6 fe80::20c:29ff:febf:7453/64 scope link
valid_lft forever preferred_lft forever
3: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
link/ether a2:ad:23:a0:dd:3d brd ff:ff:ff:ff:ff:ff
[root@localhost network-scripts]#

3. Create sub interface in network-scripts for permanently.

[root@localhost Desktop]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
[root@localhost network-scripts]# vi ifcfg-eth0:1DEVICE=”eth0:1
BOOTPROTO=”static”
IPADDR=192.168.11.20
NETMASK=255.255.255.0
HWADDR=”00:0C:29:BF:74:53″
IPV6INIT=”yes”
NM_CONTROLLED=”yes”
ONBOOT=”yes”
TYPE=”Ethernet”
UUID=”a5ca8e85-319b-4b0b-9c76-072a50a6045b”

4. Restart network and check your sub interface

[root@localhost network-scripts]# /etc/init.d/network restart
[root@localhost network-scripts]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:bf:74:53 brd ff:ff:ff:ff:ff:ff
inet 192.168.11.20/24 brd 192.168.11.255 scope global eth0
inet 192.168.11.200/24 brd 192.168.11.255 scope global secondary eth0:1
inet6 fe80::20c:29ff:febf:7453/64 scope link
valid_lft forever preferred_lft forever
3: pan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN
link/ether a2:ad:23:a0:dd:3d brd ff:ff:ff:ff:ff:ff
[root@localhost network-scripts]#

That’s all. Thanks for using IThelpblog.com

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>