Thom van der Boon
2005-Jun-23 22:34 UTC
Betr.: [CentOS] Multiple IP Addresses in a single NIC
Hi, You need to issue two commands: /sbin/ifconfig eth0:0 xxx.xxx.xxx.xxx /sbin/route add -host xxx.xxx.xxx.xxx dev eth0 For example: /sbin/ifconfig eth0:0 172.16.1.199 /sbin/route add -host 172.16.1.199 dev eth0 You can even assign multiple aliases to one NIC (One of my servers has about 10 ip addresses): For example: /sbin/ifconfig eth0:0 172.16.1.199 /sbin/route add -host 172.16.1.199 dev eth0 /sbin/ifconfig eth0:1 172.16.1.198 /sbin/route add -host 172.16.1.198 dev eth0 /sbin/ifconfig eth0:2 172.16.1.197 /sbin/route add -host 172.16.1.197 dev eth0 and so on..... You should write an startup script to execute these commands at boot time, because after a reboot the aliases are forgotten. Thom van der Boon E-Mail: Thom.van.der.Boon at vdb.nl ==== Thom.H. van der Boon b.v. Havens 563 Jan Evertsenweg 2-4 NL-3115 JA Schiedam Tel.: +31 (0)10 4272727 Fax: +31 (0)10 4736620 E-Mail: info at vdb.nl Home Page: http://www.vdb.nl/>>> joao.c.medeiros at gmail.com 24.06.2005 00:28:01 >>>Hi all, I've been trying to add a second ip address to one of my network cards in my CentOS box. I've defined the alias on top of eth1 which has become eth1:1 with a different ip address. I can ping the new ip address both from my linux box as well as from my Windoze desktop, however I can only access my Apache web server setup as a virtual host from within the Linux box. If I try to access it from the desktop I get an "Operation Timeout..." error. I'm sure I missed out something really basic. Browsed Google and the CentOS mailing list (plus RH) and can't figure it out. Networking is not one of my best subjects... Someone care to shed some light or point me to a fairly decent link out there which covers this topic? TIA, --JM Jo?o Medeiros Linux User 381318 _______________________________________________ CentOS mailing list CentOS at centos.org http://lists.centos.org/mailman/listinfo/centos -------------- next part -------------- A non-text attachment was scrubbed... Name: Thom van der Boon.vcf Type: text/x-vcard Size: 147 bytes Desc: not available URL: <http://lists.centos.org/pipermail/centos/attachments/20050624/ee31a6c3/attachment-0003.vcf>
Alexander Dalloz
2005-Jun-23 22:55 UTC
Betr.: [CentOS] Multiple IP Addresses in a single NIC
Am Fr, den 24.06.2005 schrieb Thom van der Boon um 0:34:> You need to issue two commands: > > /sbin/ifconfig eth0:0 xxx.xxx.xxx.xxx > /sbin/route add -host xxx.xxx.xxx.xxx dev eth0 > > For example: > > /sbin/ifconfig eth0:0 172.16.1.199 > /sbin/route add -host 172.16.1.199 dev eth0No route setting needed. The aliased device is anyway handled over the real device.> You can even assign multiple aliases to one NIC (One of my servers has about 10 ip addresses): > > For example: > > /sbin/ifconfig eth0:0 172.16.1.199 > /sbin/route add -host 172.16.1.199 dev eth0 > > /sbin/ifconfig eth0:1 172.16.1.198 > /sbin/route add -host 172.16.1.198 dev eth0 > > /sbin/ifconfig eth0:2 172.16.1.197 > /sbin/route add -host 172.16.1.197 dev eth0 > > and so on..... > > You should write an startup script to execute these commands at boot time, because after a reboot the aliases are forgotten.This isn't recommended this way.> Thom van der BoonCentOS has native configuration ways to handle aliased devices. Either by running redhat-config-network (3.5) or system-config-network (4.1) and then choosing an aliased device or by hand: copying /etc/sysconfig/network-scripts/ifcfg-eth1 as ifcfg-eth1:0 ... ifcfg-eth1:1 ... and then changing the content of the ifcfg-eth0:X file regarding DEVICE name, IP data and HWADDR (MAC). A "service network restart" will bring up the new aliased device(s) together with the real ones. "ifconfig" shows eth0:X (X0number) and "ip addr ls" will show the additional IP(s) as part of the real device. Alexander -- Alexander Dalloz | Enger, Germany | GPG http://pgp.mit.edu 0xB366A773 legal statement: http://www.uni-x.org/legal.html Fedora Core 2 GNU/Linux on Athlon with kernel 2.6.11-1.27_FC2smp Serendipity 00:40:31 up 2 days, 8:54, load average: 0.44, 0.45, 0.35 -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: Dies ist ein digital signierter Nachrichtenteil URL: <http://lists.centos.org/pipermail/centos/attachments/20050624/19160b44/attachment-0003.sig>
I found what the problem is... I have Firestarter installed and If I turn it off I can access the web site with the ip alias. I wouldn't like to have to turn the firewall off. Any thoughts? TIA, --JM -----Original Message----- From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On Behalf Of Alexander Dalloz Sent: 23 June 2005 23:56 To: CentOS mailing list Subject: Re: Betr.: [CentOS] Multiple IP Addresses in a single NIC Am Fr, den 24.06.2005 schrieb Thom van der Boon um 0:34:> You need to issue two commands: > > /sbin/ifconfig eth0:0 xxx.xxx.xxx.xxx > /sbin/route add -host xxx.xxx.xxx.xxx dev eth0 > > For example: > > /sbin/ifconfig eth0:0 172.16.1.199 > /sbin/route add -host 172.16.1.199 dev eth0No route setting needed. The aliased device is anyway handled over the real device.> You can even assign multiple aliases to one NIC (One of my servers hasabout 10 ip addresses):> > For example: > > /sbin/ifconfig eth0:0 172.16.1.199 > /sbin/route add -host 172.16.1.199 dev eth0 > > /sbin/ifconfig eth0:1 172.16.1.198 > /sbin/route add -host 172.16.1.198 dev eth0 > > /sbin/ifconfig eth0:2 172.16.1.197 > /sbin/route add -host 172.16.1.197 dev eth0 > > and so on..... > > You should write an startup script to execute these commands at boot time,because after a reboot the aliases are forgotten. This isn't recommended this way.> Thom van der BoonCentOS has native configuration ways to handle aliased devices. Either by running redhat-config-network (3.5) or system-config-network (4.1) and then choosing an aliased device or by hand: copying /etc/sysconfig/network-scripts/ifcfg-eth1 as ifcfg-eth1:0 ... ifcfg-eth1:1 ... and then changing the content of the ifcfg-eth0:X file regarding DEVICE name, IP data and HWADDR (MAC). A "service network restart" will bring up the new aliased device(s) together with the real ones. "ifconfig" shows eth0:X (X0number) and "ip addr ls" will show the additional IP(s) as part of the real device. Alexander -- Alexander Dalloz | Enger, Germany | GPG http://pgp.mit.edu 0xB366A773 legal statement: http://www.uni-x.org/legal.html Fedora Core 2 GNU/Linux on Athlon with kernel 2.6.11-1.27_FC2smp Serendipity 00:40:31 up 2 days, 8:54, load average: 0.44, 0.45, 0.35