# Ifconfig alias



## aiiR7 (Mar 18, 2011)

Hello there,

Well, I have a simple question about networking. I have several servers in a European datacenter, each server has only one network card. Few servers run as application, one of these servers is a database server. I donÂ´t want to waste traffic, so all servers must communicate in a localhost to the database server.

Is it enough, if I do [cmd=]# ifconfig em0 192.168.1.x netmask 255.255.255.255 alias[/cmd] on all servers?

Maybe this way:

App servers:

```
Server 1 "ifconfig em0 192.168.1.5 netmask 255.255.255.255 alias"
Server 2 "ifconfig em0 192.168.1.6 netmask 255.255.255.255 alias"
Server 3 "ifconfig em0 192.168.1.7 netmask 255.255.255.255 alias"
```
Database server:

```
Server "ifconfig em0 192.168.1.10 netmask 255.255.255.255 alias"
```

Thanks in advance,
aiiR7


----------



## sixtydoses (Mar 18, 2011)

Yes, you can do it that way. You have to include the alias entries to /etc/rc.conf to make it permanent.

Something like this:

```
ifconfig_igb0_alias0="inet 192.168.30.10 netmask 255.255.255.0"
ifconfig_igb0_alias1="inet 192.168.30.20 netmask 255.255.255.255"
ifconfig_igb0_alias2="inet 192.168.30.30 netmask 255.255.255.255
```

Or, the cleaner way:

```
ipv4_addrs_igb0="xx.xx.xx.xx/26 192.168.30.81/24 192.168.30.82/24
```


----------



## aiiR7 (Mar 18, 2011)

Hi,

Yes, I know that with the rc.conf. I'll take the cleaner way, I thought so, too, but I have never tested it. Is it important to have a pf or any other packet filter to route traffic on the local network? 

Thanks.


----------



## sixtydoses (Mar 18, 2011)

I'm using pf, because all of my servers have one NIC on each, and all of my jails are using private IP addresses. The host gets a public IP, so pf does all the routing between the host and the jails. As for the database which also resides in a jail, I only open up the database port for the web jails to access it. If all run locally, and you don't need to access the database from outside the network, then I don't think any routing is necessary.


----------



## aiiR7 (Mar 18, 2011)

Well, I need access from outside the network. Every server has a public IP address and an internal/local IP address. Each server will communicate via the internal/local IP address, because I can save a lot of traffic this way. Of course I need access from outside to the network, too, but that is not a problem.

So you think pf is important? If you want to know more, send me a PM.

That's my first step setting up a local network, sorry.

aiiR7


----------



## SirDice (Mar 18, 2011)

aiiR7 said:
			
		

> I donÂ´t want to waste traffic, so all servers must communicate in a localhost to the database server.


You mean local network. Localhost is 127.0.0.1/8.


----------



## aiiR7 (Mar 18, 2011)

SirDice said:
			
		

> You mean local network. Localhost is 127.0.0.1/8.



Yes, that is right, sorry, my mistake, it was a long night.


----------



## SirDice (Mar 18, 2011)

No problem, I wasn't sure if you understood the difference :e


----------



## aiiR7 (Mar 18, 2011)

SirDice said:
			
		

> No problem, I wasn't sure if you understood the difference :e



Hehe, sure 

I had the same running via a switch in our old rack, but this is another way.


----------



## aiiR7 (Mar 18, 2011)

Hi again,

Well, I asked my hoster about this, because you don't want to rent a switch for the first time.

Hoster:

"Doing so would mean we still have to make an extra virtual lan in our network. Not using a second nic would mean internal data traffic would be billed if it exceeds your traffic limit"

Is that right?


----------



## SirDice (Mar 18, 2011)

That's possible, it depends on how and where they actually measure your bandwidth usage. It's possible they do this on the switchport. In that case it won't matter what network addresses you use, it always passes the same switch port, hence it always gets measured.

If those servers are in the same rack just add an interface and buy a simple switch to connect them. If the hoster allows it that is.


----------



## osman (Mar 21, 2011)

Advise your host to use some better approach to count traffic, for example netflow .


----------

