# Static ip with wpa_supplicant

## elmar283

I'm trying to get a static ip-address with wpa_supplicant. I used to have this, but somehow it is not working anymore. I can't findout what the reason is.

I have set up my computer up as a router. 

eth0

Is the insite network:

address 192.168.0.1 uses a static ip-address

eht1

Is my outsite netork. It used to have a static addres, now it's only working with dhcpcd.

address 192.168.178.28 now uses dhcp.

If it might not be possible to have a static addres with wpa_supplicant I would like that /etc/resolv.conf isn't alterted.

I tried to do this by setting dhcp_eth1="nodns" but it didn't work.

Can anyone tell me how to make wpa_supplicant work with a static addres or option B to make nodns possible?

I will post some config files here:

```

elmarotter@masterserver ~ $ 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 /usr/share/doc/openrc/net.example and save your configuration

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

dns_domain_lo="eotter1979.xs4all.nl"

config_eth0="192.168.0.1 netmask 255.255.255.0 brd 192.168.0.255"

#routes_eth0="default via 192.168.0.1"

dns_servers_eth0="192.168.0.1"

associate_timeout_eth0=60

gateways_eth1="192.168.178.1"

modules="wpa_supplicant"

wpa_supplicant_eth1="-Dwext -c /etc/wpa_supplicant/wpa_supplicant.conf"

wpa_timeout_eth1=60

associate_timeout_eth1=60

config_Earth_eth1="192.168.178.28 netmask 255.255.255.0 brd 192.168.178.255"

dns_servers_Earth_eth1="192.168.0.1"

routes_Earth_eth1="default via 192.168.0.1"

dhcp_Earth_eth1="release nodns"

#config_routes_eth1="192.168.178.28/24 netmask 255.255.255.0 brd 192.168.178.255"

#dns_servers_routes_eth1="192.168.0.1"

#routes_routes_eth1="default via 192.168.0.1"

fallback_eth1="dhcp"

iwconfig_eth1="mode managed"

```

```

elmarotter@masterserver ~ $ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf 

Wachtwoord: 

# The below line not be changed otherwise we refuse to work

update_config=1

ctrl_interface_group=0

ctrl_interface=/var/run/wpa_supplicant

eapol_version=1

ap_scan=1

country=nl_NL

network={

  ssid="Earth"

  proto=WPA

  key_mgmt=WPA-PSK

  pairwise=CCMP TKIP

  group=CCMP TKIP

  psk="*********************"

  priority=5

}

```

```

elmarotter@masterserver ~ $ sudo rc-update

                acpid | battery      default                 

              amavisd |              default                 

              apache2 | battery      default                 

         avahi-daemon | battery      default                 

             bootmisc |         boot                         

                clamd |              default                 

        courier-imapd |              default                 

    courier-imapd-ssl |              default                 

    courier-pop3d-ssl |              default                 

                cupsd | battery      default                 

                 dbus | battery      default                 

                devfs |                               sysinit

               dhcpcd |              default                 

                dhcpd |              default                 

                dmesg |                               sysinit

                 fsck |         boot                         

             hostname |         boot                         

              hwclock |         boot                         

             iptables | battery      default                 

              keymaps |         boot                         

            killprocs |                      shutdown        

                local | battery      default                 

           localmount |         boot                         

              mailman |              default                 

              modules |         boot                         

             mount-ro |                      shutdown        

                 mtab |         boot                         

                mysql | battery      default                 

                named |              default                 

             net.eth0 | battery      default                 

             net.eth1 | battery      default                 

               net.lo |         boot                         

             netmount | battery      default                 

           ntp-client | battery      default                 

                 ntpd | battery      default                 

              postfix |              default                 

             postgrey |              default                 

               procfs |         boot                         

            pure-ftpd | battery      default                 

                 root |         boot                         

                samba | battery      default                 

            saslauthd |              default                 

            savecache |                      shutdown        

                squid | battery      default                 

                 sshd | battery      default                 

                 swap |         boot                         

               sysctl |         boot                         

            syslog-ng | battery      default                 

         termencoding |         boot                         

                 udev |                               sysinit

       udev-postmount | battery      default                 

              urandom |         boot                         

           vixie-cron | battery      default                 

elmarotter@masterserver ~ $ 

```

----------

## gerdesj

I've been doing this for ages.  The only config needed for this is in /etc/conf.d/net.

You seem to have eth0 and eth1.  Which is your WiFi interface?  I think eth1 but your description is a bit confused.

In wpa_supplicant you set keys etc but the IP address (DHCP) is only set in conf.d/net

Cheers

Jon

----------

## elmar283

eth1 is my wifi. 

I tried static ip in /etc/conf.d/net

But I do not get an ip when I try that. And I don't want to use DHCP.

----------

## swimmer

Did you also try 

```
config_Earth
```

 instead of 

```
config_Earth_eth1
```

?

Works for me ...  :Wink: 

HTH

swimmer

----------

## elmar283

This is a follow-up from: https://forums.gentoo.org/viewtopic-t-890978.html

I can't seem to reply to that forum thread anymore. Sorry if this is not the way to do this.

config_Earth did not work. 

swimmer: could you send me your config of /etc/conf.d/net and /etc/wpa_supplicant/wpa_supplicant.conf?

Merged by NeddySeagoon as OP was having problems with Replies

----------

## swimmer

 *elmar283 wrote:*   

> This is a follow-up from: https://forums.gentoo.org/viewtopic-t-890978.html
> 
> I can't seem to reply to that forum thread anymore. Sorry if this is not the way to do this.
> 
> config_Earth did not work. 
> ...

 

Sure  :Cool: 

/etc/conf.d/net

```

### WIRED ###

config_eth0="dhcp"

### WIRELESS ###

modules_wlan0="wpa_supplicant"

wpa_supplicant_wlan0="-Dwext -c/etc/wpa_supplicant/wpa_supplicant.conf"

## Thuis

config_<my_essid>="192.168.1.15/24"

routes_<my_essid>="default via 192.168.1.1"

dns_servers_<my_essid>="192.168.1.1"

dns_domain_<my_essid>="xmsnet.nl"

```

/etc/wpa_supplicant/wpa_supplicant.conf

```

ctrl_interface=/var/run/wpa_supplicant

ctrl_interface_group=wheel

update_config=1

network={

        ssid="<my_essid>"

        psk="<my_password>"

        proto=RSN

        key_mgmt=WPA-PSK

        pairwise=CCMP

        group=CCMP TKIP

}

```

HTH

swimmer

----------

## morb77

swimmer: thank you, sir!

That example of yours helped to fix same issue in my environments. Indeed, it is documented in the example file, but I did not think it must be followed exactly. You simply showed us path!

----------

## swimmer

Glad I could help  :Smile:  Doesn't happen that often  :Wink: 

----------

## majoron

Thank you too, swimmer. I was trying to get a solution for the same problem, and somehow I managed to skip the instrucctions in "net.example" until now.

Regards

----------

