Unix Technical Forum

SEO

vBulletin Search Engine Optimization


Go Back   Unix Technical Forum > Unix Operating Systems > Linux Operating System

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-18-2008, 05:12 AM
Richard TU
 
Posts: n/a
Default Can linux box support 2 host names / 2 ip addresses

If yes, could you guys advise how to do it?

thanks
Richard


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-18-2008, 05:12 AM
Paul Lutus
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

Richard TU wrote:

> If yes, could you guys advise how to do it?


1. Install two NICs.

2. Create configurations for the NICs with different IP addresses. That is
the normal configuration anyway.

3. Make entries into /etc/hosts that map different host names to the IP
addresses.

But this suggestion will not work in all ways. Logging onto the server and
issuing --

$ hostname

-- will not produce two hostnames, depending on which NIC you have accessed
the system by.

Why not simply state the problem, not your idea of a solution?

--
Paul Lutus
http://www.arachnoid.com

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-18-2008, 05:12 AM
Lew Pitcher
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Richard TU wrote:
> If yes, could you guys advise how to do it?


Yes, a linux system can have two host names and two IP addresses. Most already do.

For hostnames, you have to determine what sort of hostname you are interested in.

- - If it is the name returned by the hostname(1) utility, then you only get one
name. Sorry.
- - If it is the name used by Samba as your systemname within a workgroup or
domain, then again, you only get one. Sorry.
- - However, if it is the name associated to your IP address, then you get as
many names as you can assign to your IP address. You can use the /etc/hosts
file (see hosts(5)) to assign as many names as you want to your static IP
addresses. You can also use your DNS server to assign the names. You already
have at least /one/ host name for your system: IP address 127.0.0.1 is, by
convention, named as "localhost" (or "localhost.localnet") by the /etc/hosts
file.

As for IP addresses, if your system is connected to a network, then it already
has at least two IP addresses. Run the ifconfig(8) command, and it will list
each interface you have. Most interfaces will be assigned an IP address,
including the "lo" interface (which is assigned the IP address 127.0.0.1). You
get as many IP addresses as you have network interfaces for. (And, btw, each
IP address can have a host name, assigned either through /etc/hosts or through
DNS; you already have the hostname of "localhost" assigned this way, for
instance.)

To get more than one working /network/ IP address, you have to have more than
one working network adaptor. You either install multiple NICs into your
system, or you use Linux "logical" networking interface. This permits you to
have (for instance) an eth0 /and/ an eth0:0 device; two logical interfaces
each with it's own IP address, but on one physical NIC. See the ifconfig(8)
manual page for details.

- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBXKNQagVFX4UWr64RAr4NAJ9KWArmOM1lyghT8X2MeQ U5+OuTDwCfcO66
o3PKTmGP8uevZaSFb50zn+4=
=BR6x
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 01-18-2008, 05:12 AM
___cliff rayman___
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses


Paul Lutus wrote:

>Richard TU wrote:
>
>
>
>>If yes, could you guys advise how to do it?
>>
>>

>
>1. Install two NICs.
>
>

1) You can have multiple IP addresses bound to a single NIC. You only
need different NIC's if you are going to hook them physically to
different networks.
2) You can have multiple names for a machine, even when they point to
the same IP address. I do this all the time in order to call machines
by their roll name. This allows me to change what servers handle
various requests by just changing the IP address for the name in the
DNS. Here are some examples:
ns.domain.com -> main name server for the domain
mail.domain.com -> main mail exhanger for the domain
fileserver.domain.com -> main file server for the domain

etc..

Of courese, as others have stated, typing hostname will only give you
the primary hostname, and looking up the name via an IP address will
generally only return the primary hostname.

Cliff

--
_____cliff_rayman_____cliff_@_rayman_._com_____

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 01-18-2008, 05:12 AM
Ratiu Petru
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

Lew Pitcher wrote:

> Yes, a linux system can have two host names and two IP addresses.

Most already do.
>
> For hostnames, you have to determine what sort of hostname you are

interested in.

>
> - - If it is the name returned by the hostname(1) utility, then you

only get one
> name. Sorry.

At least with the stock kernel. There is the vserver patch which, among
others, can assign different hostnames for every context. I doubt the
original poster is interested in it, but there IS a way.

> - - If it is the name used by Samba as your systemname within a

workgroup or
> domain, then again, you only get one. Sorry.

That is a lot simpler, you can have multiple Samba installs, bound to
different network interfaces. Each one can have their own hostname.

There ARE some things you can't do in Linux, but these are not among
them

--
Petre.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-18-2008, 05:12 AM
Jean-David Beyer
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

Richard TU wrote:
> If yes, could you guys advise how to do it?
>

I see most people assume you mean one thing by a Linux box. And they
probably assume correctly what you mean.

But there is another way of looking at things.

When I have a dual boot machine (e.g., Linux and Windows), I give it a
different but similar IP address. E.g. 192.168.100.1 for Windows and
192.168.100.101 for Linux.

Then my other machines on the LAN can impose stricter requirements on the
Windows box and the Linux box, even if we are talking about the same box,
just one with different OS running at the time -- which is different from
my point of view.

So my main machine, the one connected to the Internet directly, perceives
two machines out on the LAN, a Windows machine and a Linux machine, even
though there is only one box there. It might make inferences from the fact
that only one is active at a time, but that is about it.

--
.~. Jean-David Beyer Registered Linux User 85642.
/V\ Registered Machine 241939.
/( )\ Shrewsbury, New Jersey http://counter.li.org
^^-^^ 08:30:00 up 8 days, 19:34, 3 users, load average: 4.30, 4.22, 4.19

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 01-18-2008, 05:12 AM
Lew Pitcher
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ratiu Petru wrote:
> Lew Pitcher wrote:
>
>
>>Yes, a linux system can have two host names and two IP addresses.

>
> Most already do.
>
>>For hostnames, you have to determine what sort of hostname you are

>
> interested in.
>
>
>>- - If it is the name returned by the hostname(1) utility, then you

>
> only get one
>
>> name. Sorry.

>
> At least with the stock kernel. There is the vserver patch which, among
> others, can assign different hostnames for every context. I doubt the
> original poster is interested in it, but there IS a way.


I did not know that. Thanks for the info.

>
>>- - If it is the name used by Samba as your systemname within a

>
> workgroup or
>
>> domain, then again, you only get one. Sorry.

>
> That is a lot simpler, you can have multiple Samba installs, bound to
> different network interfaces. Each one can have their own hostname.


Aha! That's the key; they have to be bound to different interfaces.
Again, I did not know that. Thanks again

> There ARE some things you can't do in Linux, but these are not among
> them
>


The thing I find with Linux is that there's always more to learn. I
/love/ this OS. <grin>

- --

Lew Pitcher, IT Consultant, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBXU6/agVFX4UWr64RAvk7AKDjEGBVTBua5pPXGNMXOX7o1xadVQCggV Z7
257XqjmBjIcsD3dafXTDhHU=
=6Jgp
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 01-18-2008, 05:13 AM
Richard TU
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

Thanks a lot for your replies.
I understand a lot now after you explained it.

Here is my problem:
I have two linux boxes, each with its own IP and hostname. Now I want to
combine these two into one linux box, but still keep the two sets of IP
addresses and hostnames. For example, when I go to the web page, both
hostnames should lead me to the same linux box after the combination.
I prefer to use one NIC to listen to two IP addresses like setting eth0 and
eth0:0 to different IP address. What I have to do is to add the hostname in
the hosts file, is that right?

thanks
Richard

"Lew Pitcher" <lpitcher@sympatico.ca> wrote in message
news:1r17d.28494$tT2.1526581@news20.bellglobal.com ...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Richard TU wrote:
> > If yes, could you guys advise how to do it?

>
> Yes, a linux system can have two host names and two IP addresses. Most

already do.
>
> For hostnames, you have to determine what sort of hostname you are

interested in.
>
> - - If it is the name returned by the hostname(1) utility, then you only

get one
> name. Sorry.
> - - If it is the name used by Samba as your systemname within a workgroup

or
> domain, then again, you only get one. Sorry.
> - - However, if it is the name associated to your IP address, then you get

as
> many names as you can assign to your IP address. You can use the

/etc/hosts
> file (see hosts(5)) to assign as many names as you want to your static

IP
> addresses. You can also use your DNS server to assign the names. You

already
> have at least /one/ host name for your system: IP address 127.0.0.1 is,

by
> convention, named as "localhost" (or "localhost.localnet") by the

/etc/hosts
> file.
>
> As for IP addresses, if your system is connected to a network, then it

already
> has at least two IP addresses. Run the ifconfig(8) command, and it will

list
> each interface you have. Most interfaces will be assigned an IP address,
> including the "lo" interface (which is assigned the IP address 127.0.0.1).

You
> get as many IP addresses as you have network interfaces for. (And, btw,

each
> IP address can have a host name, assigned either through /etc/hosts or

through
> DNS; you already have the hostname of "localhost" assigned this way, for
> instance.)
>
> To get more than one working /network/ IP address, you have to have more

than
> one working network adaptor. You either install multiple NICs into your
> system, or you use Linux "logical" networking interface. This permits you

to
> have (for instance) an eth0 /and/ an eth0:0 device; two logical interfaces
> each with it's own IP address, but on one physical NIC. See the

ifconfig(8)
> manual page for details.
>
> - --
> Lew Pitcher
>
> Master Codewright & JOAT-in-training | GPG public key available on request
> Registered Linux User #112576 (http://counter.li.org/)
> Slackware - Because I know what I'm doing.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.4 (GNU/Linux)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFBXKNQagVFX4UWr64RAr4NAJ9KWArmOM1lyghT8X2MeQ U5+OuTDwCfcO66
> o3PKTmGP8uevZaSFb50zn+4=
> =BR6x
> -----END PGP SIGNATURE-----



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 01-18-2008, 05:13 AM
Lew Pitcher
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Richard TU wrote:
> Thanks a lot for your replies.
> I understand a lot now after you explained it.
>
> Here is my problem:
> I have two linux boxes, each with its own IP and hostname. Now I want to
> combine these two into one linux box, but still keep the two sets of IP
> addresses and hostnames. For example, when I go to the web page, both
> hostnames should lead me to the same linux box after the combination.
> I prefer to use one NIC to listen to two IP addresses like setting eth0 and
> eth0:0 to different IP address. What I have to do is to add the hostname in
> the hosts file, is that right?


Remember that /etc/hosts only affects the system on which it resides.
So, each system that will access the new 'combined' system will need
corresponding changes to its own /etc/hosts file.

If you don't have control over these outside systems, then you should
make a change at the DNS level.


Assuming (for the purposes of this illustration) that your two sites are
currently named foo.bar.com (at IP address 10.0.0.1) and rosanne.bar.com
(at 10.0.0.2) here's what I would do with the combined system...

In your network config scripts
ifconfig eth0 10.0.0.1 broadcast 10.255.255.255 netmask 255.0.0.0
ifconfig eth0:0 10.0.0.2 broadcast 10.255.255.255 netmask 255.0.0.0

In your various /etc/hosts file
10.0.0.1 foo.bar.com foo
10.0.0.2 rosanne.bar.com rosanne
(alternatly, update your DNS to point these domain names to the proper
IP addresses).

In your Apache httpd.conf file
<VirtualHost foo.bar.com>
ServerAdmin webmaster@foo.bar.com
DocumentRoot /var/www/foo.bar.com
ServerName foo.bar.com
ErrorLog logs/foo.bar.com-error_log
CustomLog logs/foo.bar.com-access_log common
</VirtualHost>
<VirtualHost rosanne.bar.com>
ServerAdmin webmaster@rosanne.bar.com
DocumentRoot /var/www/rosanne.bar.com
ServerName foo.bar.com
ErrorLog logs/rosanne.bar.com-error_log
CustomLog logs/rosanne.bar.com-access_log common
</VirtualHost>

In directory /var/www/foo.bar.com
place the web pages for web domain foo.bar.com

In directory /var/www/rosanne.bar.com
place the web pages for the web domain rosanne.bar.com




- --

Lew Pitcher, IT Consultant, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBXbAvagVFX4UWr64RAjMDAJsHHy3vleqfV2AlOaCL7q TQ3W9RkQCgutRD
W6vA7v9F8HRk958EVxlzpzI=
=gB2x
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 01-18-2008, 05:13 AM
Lew Pitcher
 
Posts: n/a
Default Re: Can linux box support 2 host names / 2 ip addresses

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Lew Pitcher wrote:
[snip]

Correction... See below

> In your Apache httpd.conf file
> <VirtualHost foo.bar.com>
> ServerAdmin webmaster@foo.bar.com
> DocumentRoot /var/www/foo.bar.com
> ServerName foo.bar.com
> ErrorLog logs/foo.bar.com-error_log
> CustomLog logs/foo.bar.com-access_log common
> </VirtualHost>
> <VirtualHost rosanne.bar.com>
> ServerAdmin webmaster@rosanne.bar.com
> DocumentRoot /var/www/rosanne.bar.com

ServerName rosanne.bar.com
> ErrorLog logs/rosanne.bar.com-error_log
> CustomLog logs/rosanne.bar.com-access_log common
> </VirtualHost>
>
> In directory /var/www/foo.bar.com
> place the web pages for web domain foo.bar.com
>
> In directory /var/www/rosanne.bar.com
> place the web pages for the web domain rosanne.bar.com


- --

Lew Pitcher, IT Consultant, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFBXbCHagVFX4UWr64RAnAtAKCN3jVYkrbqWTWL7ca4Io rGbORs2ACgpScF
46A03rzhE6y/HnQS1zpgSKU=
=AD+d
-----END PGP SIGNATURE-----
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:21 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
UnixAdminTalk.com

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512