Friday, February 3, 2012

CentOS: Bind multiple IP-Adresses to a Network Interface

First thing is to define a single IP address for your host.

1) CentOS(RedHat) uses the file /etc/sysconfig/network to read the saved hostname at system boot. This is set using the init script /etc/rc.d/rc.sysinit
GATEWAY=192.168.0.254
HOSTNAME=www.mydomain.it
NETWORKING=yes
FORWARD_IPV6=yes
2) We define the nameserver for this system /etc/resolv.conf
search mydomain.it
nameserver 10.10.14.1
nameserver 10.10.14.2
3) Locally resolve node names to IP addresses /etc/hosts
127.0.0.1       localhost.localdomain   localhost       name        name.mydomain.it
::1             localhost6.localdomain6 localhost6      name        name.mydomain.it

16.18.24.241     name.mydomain.it          name
16.18.24.244     name.mydomain.it          name
4) Define the first ethernet connector /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
NETMASK=255.255.255.128
IPADDR=192.168.0.241
PEERDNS=no

check_link_down() {
    return 1;
}
TYPE=Ethernet
IPV6INIT=no
5) Copy this configuration file to a virtual one, which could be for example eth0:0
cp ifcfg-eth0 ifcfg-eth0:0
6) And than change the settings in the newly created file /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
NETMASK=255.255.255.128
IPADDR=192.168.0.242
PEERDNS=no

check_link_down() {
    return 1;
}
TYPE=Ethernet
IPV6INIT=no
7) Restart the network to put it to work
service network restart

No comments:

Post a Comment

Golang setup PATH

Quite recently we startet in the company to use and write some Go programs. I love Go. It's easy to learn, read and modify. One of the m...