Operating System - Linux
1829265 Members
1623 Online
109988 Solutions
New Discussion

Re: distinct hostname per nic on same server

 
Andrew Kaplan
Super Advisor

distinct hostname per nic on same server

Hi there --

I am running SuSE 9.3 on a system that has two NIC's. The eth0 NIC is on one subnet, 132.183.220.x, and eth1 is on a completely separate subnet which in its case is 192.168.0.x. There is no IP-fowarding enabled.

What I am trying to accomplish is to have a hostname associated with the address that eth0 has on its subnet and a completely different hostname for the address that eth1 is using on its subnet. How can I accomplish this? Thanks.
A Journey In The Quest Of Knowledge
4 REPLIES 4
Antonio Cardoso_1
Trusted Contributor

Re: distinct hostname per nic on same server

You can alias in /etc/hosts :
132.183.220.x
192.168.0.x

but what is your purpose?
Stuart Browne
Honored Contributor

Re: distinct hostname per nic on same server

Hosts files, as above, and DNS. That is their purpose.

A physical system can only have one 'hostname', but it can have multiple IP addresses with different DNS names.
One long-haired git at your service...
Ivan Ferreira
Honored Contributor

Re: distinct hostname per nic on same server

A different hostname for each ip address is a must. Using /etc/hosts, configure as described above.

The /etc/sysconfig/network should also contain a host name that is related to one of the interfaces.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Manuel Wolfshant
Trusted Contributor

Re: distinct hostname per nic on same server

If you want the hostnames to be available only on that system, you can go with /etc/hosts, as was already suggested.
However if you want those hostnames to be available in you LAN, you will need to edit the DNS entries. Assuming you are using bind, you will need to edit the zone file that corresponds to your internal domain and add something similar to:

hostname1. A 132.183.220.x
hostname2. A 192.168.0.x

Do not forget to increase the serial number of the zone before reloading it.