Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to add multiple ip addresses to arch linux server.

Since I have only one network card with interface eth0 I think I need to add virtual interfaces like eth0:1 etc..

I have tried using this following syntax in /etc/rc.conf, but it seems to trow a bunch of errors: (note for this example I have omitted the ips for security)

eth0="eth0 x.x.x.x netmask x.x.x.x broadcast x.x.x.x"
eth0_0="eth0:0 x.x.x.x netmask x.x.x.x broadcast x.x.x.x"
INTERFACES=(lo eth0 eth0_0)
gateway="default gw x.x.x.x"
ROUTES=(gateway)

Any help would be appreciated. Thank you.

share|improve this question
add comment

3 Answers

Basic IP Aliasing with netcfg

With netcfg, IP aliasing is managed by running the same ip commands you would use if you were doing it manually:

POST_UP='ip addr add 72.20.27.234/30 dev eth0 label eth0:1'
PRE_DOWN='ip addr del 72.20.27.234/30 dev eth0 label eth0:1'

That's it. It just works.

Here's a netcfg ethernet profile to start with:

CONNECTION='ethernet'
DESCRIPTION='ifconfig like a boss'
INTERFACE='eth0'
IP='static'
ADDR='192.168.183.118'
NETMASK='255.255.255.252'
GATEWAY='192.168.183.117'
DNS=('8.8.8.8' '208.67.222.222')

Now put that profile in a place like /etc/network.d/staminus. Let's test it.

netcfg staminus

If you still have any network configuration in rc.conf, remove it. It's deprecated. Just add net-profiles in your daemons list. We can tell netcfg to use this profile by default, when the system boots. In /etc/conf.d/netcfg:

NETWORKS=(staminus)

Now append to your ethernet profile some POST_UP and PRE_DOWN commands as described earlier. Then stroke that glorious neckbeard.

share|improve this answer
add comment

Have a look at the archlinux wiki; it has a description of how to do this.

share|improve this answer
    
Yeah, already did. But I was trying to avoid using netcfg is there any other way to do this in rc.conf it self ? –  Tux Jul 20 '12 at 7:59
    
Not that I know of, but I'm not an expert on archlinux. If you do find one, I'm sure they'd appreciate it if you update the wiki. It would have been very helpful if you included in your question that you'd already tried the recommended way - since you didn't, it looked as if you just didn't know it existed. –  Jenny D Jul 20 '12 at 8:04
    
So far I only found references to netcfg but I'm trying to find a simpler way of doing this =) –  Tux Jul 20 '12 at 8:19
    
Also, you can see the post on the forum, bbs.archlinux.org/viewtopic.php?pid=1133151 –  Tux Jul 20 '12 at 8:24
add comment

Can you not use the ip command e.g.

ip addr add 10.9.8.7/32 dev eth0

or whatever you need in a suitable init script ?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.