Skip to main content

Assiging Virtual IP to Server [Centos 6.5]

Creating Virtual Interface and Assign Multiple IP Addresses

Current IP of the server : 10.130.18.11.
Virtual IPs being assigned to server : 10.130.18.22, 10.130.18.23, 10.130.18.24 to our server..
Go to network-scripts directory and copy the existing ifcfg-eth0 file.
Make sure you are using a static ip for your server.
 cd /etc/sysconfig/network-scripts/
static ip assigned scripts looks as below.
 [ahmed@ahmed-server network-scripts]$ sudo vim ifcfg-eth0

 DEVICE="eth0"
 BOOTPROTO=static
 NM_CONTROLLED="no"
 ONBOOT=yes
 TYPE="Ethernet"
 IPADDR=10.130.18.11
 NETMASK=255.255.255.192
 GATEWAY=10.138.18.1
 HWADDR=A0:0C:29:28:A7:4C 
Make sure we copy the same script as ifcfg-eth0:0/1/2
 sudo cp ifcfg-eth0 ifcfg-eth0:0
 sudo cp ifcfg-eth0:0 ifcfg-eth0:1
 sudo cp ifcfg-eth0:0 ifcfg-eth0:2
Change the copied script as below.
Here we are assigned the Virtual IP addresses to the Server.

ifcfg-eth0:0 Configuration

 [ahmed@ahmed-server network-scripts]$ sudo vim ifcfg-eth0:0

 DEVICE="eth0:0"
 BOOTPROTO=static
 NM_CONTROLLED="no"
 ONBOOT=yes
 TYPE="Ethernet"
 IPADDR=10.130.18.22
 NETMASK=255.255.255.192
 GATEWAY=10.138.18.1
 HWADDR=A0:0C:29:28:A7:4C 

ifcfg-eth0:1 Configuration

 [ahmed@ahmed-server network-scripts]$ sudo vim ifcfg-eth0:1

 DEVICE="eth0:1"
 BOOTPROTO=static
 NM_CONTROLLED="no"
 ONBOOT=yes
 TYPE="Ethernet"
 IPADDR=10.130.18.23
 NETMASK=255.255.255.192
 GATEWAY=10.138.18.1
 HWADDR=A0:0C:29:28:A7:4C 

ifcfg-eth0:2 Configuration

 [ahmed@ahmed-server network-scripts]$ sudo vim ifcfg-eth0:2

 DEVICE="eth0:2"
 BOOTPROTO=static
 NM_CONTROLLED="no"
 ONBOOT=yes
 TYPE="Ethernet"
 IPADDR=10.130.18.24
 NETMASK=255.255.255.192
 GATEWAY=10.138.18.1
 HWADDR=A0:0C:29:28:A7:4C  
Now lets restart the network so that the changes take affect.
 [ahmed@ahmed-server network-scripts]$ sudo /etc/init.d/network restart
 Shutting down interface eth0:                              [  OK  ]
 Shutting down loopback interface:                          [  OK  ]
 Bringing up loopback interface:                            [  OK  ]
 Bringing up interface eth0:  Determining if ip address 10.130.18.11 is already in use for device eth0...
                                                            [  OK  ]
Checking the configuration.
 [ahmed@ahmed-server network-scripts]$ ifconfig
 eth0      Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.11  Bcast:10.130.18.63  Mask:255.255.255.192
           inet6 addr: fe80::a2d3:c1ff:fef9:d8dc/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:74 errors:0 dropped:0 overruns:0 frame:0
           TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:6687 (6.5 KiB)  TX bytes:10366 (10.1 KiB)
           Interrupt:32

 eth0:0    Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.22  Bcast:10.130.18.63  Mask:255.255.255.192
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           Interrupt:32

 eth0:1    Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.23  Bcast:10.130.18.63  Mask:255.255.255.192
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           Interrupt:32

 eth0:2    Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.24  Bcast:10.130.18.63  Mask:255.255.255.192
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           Interrupt:32
Let Ping those IPs.
 ahmed@ahmed-second-server:~# ping 10.130.18.11
 PING 10.130.18.11 (10.130.18.11) 56(84) bytes of data.
 64 bytes from 10.130.18.11: icmp_req=2 ttl=59 time=0.288 ms
 64 bytes from 10.130.18.11: icmp_req=3 ttl=59 time=0.962 ms
 64 bytes from 10.130.18.11: icmp_req=4 ttl=59 time=0.287 ms
 ^C
 --- 10.130.18.11 ping statistics ---
 4 packets transmitted, 3 received, 25% packet loss, time 3008ms
 rtt min/avg/max/mdev = 0.287/0.512/0.962/0.318 ms
 ahmed@ahmed-second-server:~# ping 10.130.18.22
 PING 10.130.18.22 (10.130.18.22) 56(84) bytes of data.
 64 bytes from 10.130.18.22: icmp_req=1 ttl=59 time=0.680 ms
 64 bytes from 10.130.18.22: icmp_req=2 ttl=59 time=1.67 ms
 64 bytes from 10.130.18.22: icmp_req=3 ttl=59 time=0.274 ms
 ^C
 --- 10.130.18.22 ping statistics ---
 3 packets transmitted, 3 received, 0% packet loss, time 2004ms
 rtt min/avg/max/mdev = 0.274/0.877/1.678/0.590 ms
 ahmed@ahmed-second-server:~# ping 10.130.18.23
 PING 10.130.18.23 (10.130.18.23) 56(84) bytes of data.
 64 bytes from 10.130.18.23: icmp_req=2 ttl=59 time=0.853 ms
 64 bytes from 10.130.18.23: icmp_req=3 ttl=59 time=0.626 ms
 64 bytes from 10.130.18.23: icmp_req=4 ttl=59 time=0.346 ms
 ^C
 --- 10.130.18.23 ping statistics ---
 4 packets transmitted, 3 received, 25% packet loss, time 3014ms
 rtt min/avg/max/mdev = 0.346/0.608/0.853/0.208 ms 

Assign Multiple IP Address Range

If you would like to create a range of Multiple IP Addresses to a particular interface called “ifcfg-eth0“, we use “ifcfg-eth0-range0” and copy the contains of ifcfg-eth0 on it as shown below.
 [ahmed@ahmed-server network-scripts]$ sudo cp -p ifcfg-eth0 ifcfg-eth0-range0
Now open “ifcfg-eth0-range0” file and add “IPADDR_START” and “IPADDR_END” IP address range as shown below.
 [ahmed@ahmed-server network-scripts]# vi ifcfg-eth0-range0

 #DEVICE="eth0"
 #BOOTPROTO=static
 #NM_CONTROLLED="no"
 #ONBOOT=yes
 TYPE="Ethernet"
 IPADDR_START=10.130.18.22
 IPADDR_END=10.130.18.24
 IPV6INIT=no
Save it and restart/start network service
 [ahmed@ahmed-server network-scripts]$ sudo /etc/init.d/network restart
 Shutting down interface eth0:                              [  OK  ]
 Shutting down loopback interface:                          [  OK  ]
 Bringing up loopback interface:                            [  OK  ]
 Bringing up interface eth0:  Determining if ip address 10.130.18.11 is already in use for device eth0...
                                                            [  OK  ]
Checking the configuration. Verify that virtual interfaces are created with IP Address.
 [ahmed@ahmed-server network-scripts]$ ifconfig
 eth0      Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.11  Bcast:10.130.18.63  Mask:255.255.255.192
           inet6 addr: fe80::a2d3:c1ff:fef9:d8dc/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:74 errors:0 dropped:0 overruns:0 frame:0
           TX packets:56 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:6687 (6.5 KiB)  TX bytes:10366 (10.1 KiB)
           Interrupt:32

 eth0:0    Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.22  Bcast:10.130.18.63  Mask:255.255.255.192
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           Interrupt:32

 eth0:1    Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.23  Bcast:10.130.18.63  Mask:255.255.255.192
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           Interrupt:32

 eth0:2    Link encap:Ethernet  HWaddr A0:0C:29:28:A7:4C
           inet addr:10.130.18.24  Bcast:10.130.18.63  Mask:255.255.255.192
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           Interrupt:32
More Info :
 http://www.tecmint.com/create-multiple-ip-addresses-to-one-single-network-interface/
 http://linuxconfig.org/configuring-virtual-network-interfaces-in-linux
 http://www.jamescoyle.net/how-to/307-create-a-virtual-ip-address-in-linux
 https://myunixlab.wordpress.com/2011/02/04/how-to-add-virtual-ip-address-in-linux/

Comments

Popular posts from this blog

Cloudera Manager - Duplicate entry 'zookeeper' for key 'NAME'.

We had recently built a cluster using cloudera API’s and had all the services running on it with Kerberos enabled. Next we had a requirement to add another kafka cluster to our already exsisting cluster in cloudera manager. Since it is a quick task to get the zookeeper and kafka up and running. We decided to get this done using the cloudera manager instead of the API’s. But we faced the Duplicate entry 'zookeeper' for key 'NAME' issue as described in the bug below. https://issues.cloudera.org/browse/DISTRO-790 I have set up two clusters that share a Cloudera Manger. The first I set up with the API and created the services with capital letter names, e.g., ZOOKEEPER, HDFS, HIVE. Now, I add the second cluster using the Wizard. Add Cluster->Select Hosts->Distribute Parcels->Select base HDFS Cluster install On the next page i get SQL errros telling that the services i want to add already exist. I suspect that the check for existing service names does n

Zabbix History Table Clean Up

Zabbix history table gets really big, and if you are in a situation where you want to clean it up. Then we can do so, using the below steps. Stop zabbix server. Take table backup - just in case. Create a temporary table. Update the temporary table with data required, upto a specific date using epoch . Move old table to a different table name. Move updated (new temporary) table to original table which needs to be cleaned-up. Drop the old table. (Optional) Restart Zabbix Since this is not offical procedure, but it has worked for me so use it at your own risk. Here is another post which will help is reducing the size of history tables - http://zabbixzone.com/zabbix/history-and-trends/ Zabbix Version : Zabbix v2.4 Make sure MySql 5.1 is set with InnoDB as innodb_file_per_table=ON Step 1 Stop the Zabbix server sudo service zabbix-server stop Script. echo "------------------------------------------" echo " 1. Stopping Zabbix Server &quo

Access Filter in SSSD `ldap_access_filter` [SSSD Access denied / Permission denied ]

Access Filter Setup with SSSD ldap_access_filter (string) If using access_provider = ldap , this option is mandatory. It specifies an LDAP search filter criteria that must be met for the user to be granted access on this host. If access_provider = ldap and this option is not set, it will result in all users being denied access. Use access_provider = allow to change this default behaviour. Example: access_provider = ldap ldap_access_filter = memberOf=cn=allowed_user_groups,ou=Groups,dc=example,dc=com Prerequisites yum install sssd Single LDAP Group Under domain/default in /etc/sssd/sssd.conf add: access_provider = ldap ldap_access_filter = memberOf=cn=Group Name,ou=Groups,dc=example,dc=com Multiple LDAP Groups Under domain/default in /etc/sssd/sssd.conf add: access_provider = ldap ldap_access_filter = (|(memberOf=cn=System Adminstrators,ou=Groups,dc=example,dc=com)(memberOf=cn=Database Users,ou=Groups,dc=example,dc=com)) ldap_access_filter accepts standa