# how to setup static ip? [solved]

## Gh0str1d3r

Hi,

I am fully failing in setting up my wired network interface to use static ip. My /etc/conf.d/net looks like

```
# cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

#modules="dhcpcd"

ifplugd_eth0="134.34.143.182 netmask 255.255.255.1289"

routes_eth0="default via 134.34.143.129"

dns_servers_eth0="134.34.3.2 134.34.3.3"

# Prefer wpa_supplicant over wireless-tools

modules="wpa_supplicant"

# It's important that we tell wpa_supplicant which driver we should

# be using as it's not very good at guessing yet

wpa_supplicant_wlan1="-Dwext"

```

where I also tried ifconfig instead of ifplugd, with the same effect. The static ip I gave there is simply ignored, as well as the netmask and the gateway. The dns-servers in /etc/resolv.conf are overridden to empty.

here is the output of ifconfig after starting net.eth0 with the above given /etc/conf.d/net:

```
# ifconfig eth0

eth0      Protokoll:Ethernet  Hardware Adresse 00:1e:33:24:9c:34  

          inet Adresse:134.34.143.182  Bcast:134.34.143.255  Maske:255.255.255.128

          inet6 Adresse: fe80::21e:33ff:fe24:9c34/64 Gültigkeitsbereich:Verbindung

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:3802 errors:424 dropped:0 overruns:0 frame:159

          TX packets:2877 errors:0 dropped:0 overruns:0 carrier:1

          Kollisionen:572 Sendewarteschlangenlänge:1000 

          RX bytes:1981594 (1.8 MiB)  TX bytes:459558 (448.7 KiB)

          Interrupt:30 

```

Setting the correct values manually with

```
# ifconfig eth0 134.34.143.182 netmask 255.255.255.128 up
```

works fine, but its annoying to setup the network by hand every reboot. Can it be so difficult to correctly configure a network in linux or am I just to stupid?Last edited by Gh0str1d3r on Wed May 19, 2010 7:39 am; edited 1 time in total

----------

## Ant P.

 *Gh0str1d3r wrote:*   

> 
> 
> ```
> ifplugd_eth0="134.34.143.182 netmask 255.255.255.1289"
> ```
> ...

 

1289?

----------

## John R. Graham

Have you looked in /etc/conf.d/net.example (or, if you're using openrc, /usr/share/doc/openrc*/net.example)?  The examples in there are pretty easy to understand.

- John

----------

## Gh0str1d3r

 *Ant_P wrote:*   

>  *Gh0str1d3r wrote:*   
> 
> ```
> ifplugd_eth0="134.34.143.182 netmask 255.255.255.1289"
> ```
> ...

 

you are right, that was a typo, but without it still does not work (same output of ifconfig).

I checked that example, and set up the config as I understood it. I dont see the error.

----------

## cst

```
config_eth0=( "134.34.143.182/25" )
```

you only should need this in your /etc/conf.d/net

----------

## Gh0str1d3r

 *cst wrote:*   

> 
> 
> ```
> config_eth0=( "134.34.143.182/25" )
> ```
> ...

 

I am using openrc. according to /usr/share/doc/openrc-0.6.1-r1/net.example, there shouldn't be brackets, or am I wrong?

----------

## cst

 *Gh0str1d3r wrote:*   

> 
> 
> I am using openrc. according to /usr/share/doc/openrc-0.6.1-r1/net.example, there shouldn't be brackets, or am I wrong?

 

I also have openrc , although I dont have static ip and I have brackets, did you try it?

----------

## Gh0str1d3r

there is no difference, same result with brackets. I found out that the problem is ifplugd. If I unmerge it, and change the config to

```
# cat /etc/conf.d/net

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

#modules="dhcpcd"

config_eth0="134.34.143.182 netmask 255.255.255.128"

routes_eth0="default via 134.34.143.129"

dns_servers_eth0="134.34.3.2 134.34.3.3"

# Prefer wpa_supplicant over wireless-tools

modules="wpa_supplicant"

# It's important that we tell wpa_supplicant which driver we should

# be using as it's not very good at guessing yet

wpa_supplicant_wlan1="-Dwext"

```

then it works. Any ideas how to make it work with ifplugd? (I know that ifplugd doesnt make sense in that particular case, but I don't want to emerge and unmerge it always when changing my computer location)

----------

## py-ro

Just install ifplugd, it will be used automagical.

Py

----------

## Hu

If you are moving your system around, why are you using a static IP address?  If you are not moving the system around, why do you need ifplugd?

----------

## Gh0str1d3r

 *Hu wrote:*   

> If you are moving your system around, why are you using a static IP address?  If you are not moving the system around, why do you need ifplugd?

 

I need a static ip at some place that doesnt provide dhcp. In all other places, I am using dhcp and ifplugd. Now after unmerging and reemerging ifplugd, it works with that config:

```
$ cat /etc/conf.d/net                          

# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

#modules="dhcpcd"

config_eth0="134.34.143.182 netmask 255.255.255.128"

routes_eth0="default via 134.34.143.129"

dns_servers_eth0="134.34.3.2 134.34.3.3"

# Prefer wpa_supplicant over wireless-tools

modules="wpa_supplicant"

# It's important that we tell wpa_supplicant which driver we should

# be using as it's not very good at guessing yet

wpa_supplicant_wlan1="-Dwext"

```

It definitely does not work with the ifplugd_eth0=.... that is suggested in the ifplugd-howto and also not with ifconfig_eth0=...

But anyway, now it works. So thank you all for your help.

----------

