Professional Documents
Culture Documents
aliasing. IP
aliasing is very useful for setting up multiple virtual sites on Apache using one single network interface with different
IP addresses on a single subnet network.
The main advantage of using this IP aliasing is, you dont need to have a physical adapter attached to each IP
IP, but
instead you can create multiple or many virtual interfaces (aliases
aliases) to a single physical card.
The instructions given here are applies to all major Linux distributions like Red Hat
Hat, Fedora
Fedora, and CentOS
CentOS. Creating
multiple interfaces and assign IP address to it manually is a daunting task. Here well see how we can assign IP address
to it defining a set of IP range. Also understand how we are going to create a virtual interface and assign different
range of IP Address to an interface in one go. In this article we used LAN IP
IPss, so replace those with ones you will be
using.
# cd /etc/sysconfig/network-scripts/
# ls -l
http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/
Sample Output
ifcfg-eth0
ifcfg-lo
ifdown
ifdown-bnep
ifdown-eth
ifdown-ippp
ifdown-ipv6
ifdown-isdn
ifdown-post
ifdown-ppp
ifdown-routes
ifdown-sit
ifdown-tunnel
ifup
ifup-aliases
ifup-bnep
ifup-eth
ifup-ippp
ifup-ipv6
ifup-isdn
ifup-plip
ifup-plusb
ifup-post
ifup-ppp
ifup-routes
ifup-sit
ifup-tunnel
ifup-wireless
init.ipv6-global
net.hotplug
network-functions
network-functions-ipv6
Lets assume that we want to create three additional virtual interfaces to bind three IP addresses (172.16.16.126
172.16.16.126,
172.16.16.127
172.16.16.127, and 172.16.16.128
172.16.16.128) to the NIC
NIC. So, we need to create three additional alias files, while ifcfg-eth0
ifcfg-eth0 keeps
the same primary IP address. This is how we moving forward to setup three aliases to bind the following IP addresses.
Adapter
IP Address
Type
------------------------------------------------eth0
172.16.16.25
Primary
eth0:0
172.16.16.26
Alias 1
eth0:1
172.16.16.27
Alias 2
eth0:2
172.16.16.28
Alias 3
Where :X
:X is the device (interface
interface) number to create the aliases for interface eth0
eth0. For each alias you must assign a
number sequentially. For example, we copying existing parameters of interface ifcfg-eth0
ifcfg-eth0 in virtual interfaces called
ifcfg-eth0:0
ifcfg-eth0:0, ifcfg-eth0:1 and ifcfg-eth0:2
ifcfg-eth0:2. Go into the network directory and create the files as shown below.
#
#
#
#
cd
cp
cp
cp
/etc/sysconfig/network-scripts/
ifcfg-eth0 ifcfg-eth0:0
ifcfg-eth0 ifcfg-eth0:1
ifcfg-eth0 ifcfg-eth0:2
http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/
ifcfg-eth0:0
DEVICE="eth0:0"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.126
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
ifcfg-eth0:1
DEVICE="eth0:1"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.127
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
ifcfg-eth0:2
DEVICE="eth0:2"
BOOTPROTO=static
ONBOOT=yes
TYPE="Ethernet"
IPADDR=172.16.16.128
NETMASK=255.255.255.224
GATEWAY=172.16.16.100
HWADDR=00:0C:29:28:FD:4C
Once, youve made all changes, save all your changes and restart/start the network service for the changes to reflect.
To verify all the aliases (virtual interface) are up and running, you can use ifconfig
ifconfig or ip
ip command.
http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/
eth0:1
eth0:2
Ping each of them from different machine. If everything setup correctly, you will get a ping response from each of
them.
ping 172.16.16.126
ping 172.16.16.127
ping 172.16.16.128
Sample Output
[root@tecmint ~]# ping 172.16.16.126
PING 172.16.16.126 (172.16.16.126) 56(84) bytes of data.
64 bytes from 172.16.16.126: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.126: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.126: icmp_seq=3 ttl=64 time=0.159 ms
--- 172.16.16.126 ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms
[root@tecmint ~]# ping 172.16.16.127
PING 172.16.16.127 (172.16.16.127) 56(84) bytes of data.
64 bytes from 172.16.16.127: icmp_seq=1 ttl=64 time=1.33 ms
64 bytes from 172.16.16.127: icmp_seq=2 ttl=64 time=0.165 ms
64 bytes from 172.16.16.127: icmp_seq=3 ttl=64 time=0.159 ms
--- 172.16.16.127 ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.159/0.552/1.332/0.551 ms
[root@tecmint ~]# ping 172.16.16.128
PING 172.16.16.128 (172.16.16.128) 56(84) bytes of data.
64 bytes from 172.16.16.128: icmp_seq=1 ttl=64 time=1.33 ms
http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/
Seems everything working smoothly, With these new IPs you can setup virtual sites in Apache
Apache, FTP accounts and
many other things.
http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/
collisions:0 txqueuelen:1000
RX bytes:127317 (124.3 KiB) TX bytes:200787 (196.0 KiB)
Interrupt:18 Base address:0x2000
eth0:0
eth0:1
eth0:2
eth0:3
eth0:4
http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/