# How to permanently add IP adresses to my dev eth0 ?

## yarek

Hello: 

I have a dedicated server on OVH hosting with 8 Ip fails overs IPs.

I use to add these IPs with that command

ip addr add 137.74.80.16/32 dev eth0;

ip addr add 137.74.80.17/32 dev eth0;

(...)

These are not permanent and once server rebooted, it lost all configurations.

How to permanently add IP adresses to my dev eth0 ?

(I read that: https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking but I was unable to complete the task)

regards

----------

## joanandk

 *yarek wrote:*   

> (I read that: https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking but I was unable to complete the task)

 

I doubt that. Did you read the "Advanced configuration" and seen the "/etc/conf.d/net" ??

----------

## yarek

I did read it.

But I am not a linux guru and was unable to add an IP

regards

----------

## chiefbag

You would use the following and note the "/24" instead of "/32" if you want netmask 255.255.255.0

In "/etc/conf.d/net"

```

config_eth0="137.74.80.16/24

137.74.80.17/24"
```

----------

## NeddySeagoon

yarek,

OVH Gentoo Release 2 ... yuck!

You may have a file /etc/conf.d/net but Gentoo will work without it.  You will get a single dynamically assigned IP address if this file is missing.

You must create this file.  If you mess up, you will need to use the rescue system to fix it because you may end up with no network connectivity.

The file needs to contain.

```
config_eth0="192.168.100.20/24 brd 192.168.100.255"

routes_eth0="default via 192.168.100.253"
```

 Those are my addresses. You need to change them for your IP address and default route that OVH gave you. 

So far this is just the default setup - no extra IPs.

Test it - be prepared to use the rescue console to rename  /etc/conf.d/net if you can no longer connect once eth0 is restarted.

Once it works, you can add more addresses to the config_eth0= statement.  See /usr/share/doc/netifrc-0.5.1/net.example.bz2 for worked examples.

Note that netifrc-0.5.1 is the version I have.  Yours may be older.

----------

## yarek

so I  should add : 

```
config_eth0="137.74.80.16/24 

137.74.80.17/24"

config_eth0="137.74.80.17/24 

137.74.80.17/24"
```

...

Regards

----------

## joanandk

 *yarek wrote:*   

> I did read it.
> 
> But I am not a linux guru and was unable to add an IP
> 
> regards

 

Then, could you tell us where you have failed?

a) Did you edit the /etc/conf.d/net

b) Can you execute (after editing /etc/conf.d/net) 

```
/etc/init.d/net.eth0 restart
```

 and send us the output

c) What is the output of 

```
ifconfig eth0
```

BR

----------

## joanandk

 *yarek wrote:*   

> so I  should add : 
> 
> ```
> config_eth0="137.74.80.16/24 
> 
> ...

 

It depends! What is the IP given from your provider? Where is the default gateway for that Subnet and where is the broadcast address?

BR

----------

## NeddySeagoon

yarek,

Close but not correct.

You should have only a single config_eth0= statement listing all the IPs.

With multiple config_eth0= statements, only the last one will have any effect.

You must have a routes_eth0= statement to set your default route.

Without that, you don't have any network other than the local subnet - no internet!

Is the /24 correct?  What did OVH tell you?

Its a long time since I had an OVH server.

----------

