# [SOLVED] No internet connection with Wireless & Static IP?

## pmam

Hi,

Long time I have been trying configure wireless interface -

I read many Gentoo's Handbook, WIKI etc, however, at the moment quite lost - 

Do not understand what I am doing and what suppose to do...   :Sad: 

In general, Gentoo's documentations are of high level: Accurate and updated, but concerning Network/Wireless - 

 *Quote:*   

> Wireless networking on Linux is usually pretty straightforward.

  (https://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=4&chap=4) - 

it is not so - at least, according my experience and some others, as may see in this Forum - 

Maybe it is due to many approaches, methods, achieving the same result.

If someone would make some order - welcomed   :Smile: 

My requirements are quite simple:

Static IP, WEP, open, one password.

Priority to Wired connection - If no wired, then automatically WIFI connection.

At the moment, my configuration is with DHCP - If there is another way, configuring STATIC IP with /etc/conf.d/net, please let me know.

Seems every thing is OK - I can connect with WPA_GUI and assign the right IP, 

However, can not connect to Internet, no ping.

Do I need symbolic link to wlp3s0?

wpa_supplicant should be in runlevel?

Here is /etc/conf.d/net:

```
dns_domain_lo="lan"

config_enp2s0="10.0.0.6 netmask 255.255.255.0 brd 10.0.0.255"

routes_enp2s0="default via 10.0.0.138"

modules_wlp3s0="wpa_supplicant"

config_wlp3s0="dhcp"
```

kwrite /etc/resolv.conf:

```
# Generated by dhcpcd from enp2s0, wlp3s0

# /etc/resolv.conf.head can replace this line

nameserver 10.0.0.138

# /etc/resolv.conf.tail can replace this line
```

/etc/dhcpcd.conf:   

```
# A sample configuration for dhcpcd.

# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.

#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.

hostname

# Use the hardware address of the interface for the Client ID.

#clientid

# or

# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.

duid

# Persist interface configuration when dhcpcd exits.

persistent

# Rapid commit support.

# Safe to enable by default because it requires the equivalent option set

# on the server to actually work.

option rapid_commit

# A list of options to request from the DHCP server.

option domain_name_servers, domain_name, domain_search, host_name

option classless_static_routes

# Most distributions have NTP support.

option ntp_servers

# Respect the network MTU.

# Some interface drivers reset when changing the MTU so disabled by default.

#option interface_mtu

# A ServerID is required by RFC2131.

require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones

slaac private

# A hook script is provided to lookup the hostname if not set by the DHCP

# server, but it should not be run by default.

nohook lookup-hostname

#Here is an example which configures a static address, routes and dns.

interface wlp3s0

  static ip_address=10.0.0.8/24

  static routers=10.0.0.138

  static domain_name_servers=10.0.0.138
```

/etc/wpa_supplicant/wpa_supplicant.conf - Made by WPA_GUI: 

```
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

update_config=1

network={

   ssid="AFMBZPD7"

   key_mgmt=NONE

   auth_alg=OPEN

   wep_key0="%aX"6"

}
```

----------

## charles17

Would searching for https://forums.gentoo.org/viewtopic-t-890978.html help?

----------

## pmam

charles17, 

Yes, I already have seen this topic - 

There is an extra line in his /etc/conf.d/net: 

```
dns_domain_<my_essid>="xmsnet.nl" 
```

 - 

I need it or not?

They use 

```
modules_wlan0="wpa_supplicant"
```

 or 

```
modules="wpa_supplicant"
```

  - 

What is right or both are OK? (I have tried both ways)

In his case, the configuration of Static IP is in /etc/conf.d/net - 

Mine is in /etc/dhcpcd.conf... Do not know what is right - May be both ways are OK, but how to do it right?

Thanks

----------

## charles17

 *pmam wrote:*   

> In his case, the configuration of Static IP is in /etc/conf.d/net - 
> 
> Mine is in /etc/dhcpcd.conf... Do not know what is right - May be both ways are OK, but how to do it right?

 /etc/conf.d/net  is used by the Gentoo net.* scripts solution. The dhcpcd solution uses /etc/dhcpcd.conf.  You'd better decide for the one or the other, not mixing them.

https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD  Sorry for not being clear enough in the previous topic.

----------

## NeddySeagoon

pmam,

Wireless is similar to wired.  There is an extra step for wireless.  You need to get the wireless link up so that eveything else works as you know and love from wired.

First, make up your mind if you want interfaces to use kernel names or 'persistant device names'.  The latter means that udev renames all your devices for you.

Both systems havu their failings. Choose one method and stick to it, unless you hit a failing.

```
# Generated by dhcpcd from enp2s0, wlp3s0 
```

 thells taht you are using persistant device names.

Your wired interface is enp2s0 and wireless is wlp3s0.  Everywhere you have wlan0, you need wlp3s0.

wpa_supplicant should not be in a runlevel.  It will be started by the net file.  There should be a line there that binds wpa_supplicant to the driver for wlp3s0.

I don't have WiFi on this box, so I can't check.

The first step is to check that dmesg tells that  wlp3s0 has authenticated and that it has authenticated with the AP you expected it to.

If you are on nekt doors wifi network, it happens, your static setup won't work.

Until you can authenticate, nothing else matters.

----------

## pmam

Dear NeddySeagoon,

 *Quote:*   

> Everywhere you have wlan0, you need wlp3s0.

 

Thanks for your nice explanation regarding 'persistent device names', 

It gives me deeper insight of the system. In my case it is OK -

'wlan0' is belong to the example of the link that charles17 pointing me to - I am using only 'wlp3s0'.

 *Quote:*   

> wpa_supplicant should not be in a runlevel.

 

I have done this now.

 *Quote:*   

>  There should be a line there that binds wpa_supplicant to the driver for wlp3s0. 

 

I added this line (hope it is the right driver -Dnl80211) to /etc/conf.d/net (I assume we meant to this file) as following:

```
dns_domain_lo="lan"

config_enp2s0="10.0.0.6 netmask 255.255.255.0 brd 10.0.0.255"

routes_enp2s0="default via 10.0.0.138"

modules_wlp3s0="wpa_supplicant"

wpa_supplicant_wlp3s0="-Dnl80211"

config_wlp3s0="dhcp"
```

After done all above I restart and here is last part of dmesg|less - seems wlp3s0 has authenticated.

Now - I disconnected the wired network and still can not connect internet by WIFI - Please advise! 

```
[    3.569492] systemd-udevd[1165]: starting version 216

[    3.674458] udevadm (1173) used greatest stack depth: 4200 bytes left

[    4.459184] systemd-udevd[1192]: renamed network interface wlan0 to wlp3s0

[    4.522191] systemd-udevd[1184]: renamed network interface eth0 to enp2s0

[    6.323020] EXT4-fs (sda8): re-mounted. Opts: (null)

[    6.498396] Adding 2097148k swap on /dev/sda7.  Priority:-1 extents:1 across:2097148k 

[    6.554112] EXT4-fs (sda6): mounted filesystem with ordered data mode. Opts: (null)

[    8.785581] IPv6: ADDRCONF(NETDEV_UP): wlp3s0: link is not ready

[    8.827675] r8169 0000:02:00.0 enp2s0: link down

[    8.827702] r8169 0000:02:00.0 enp2s0: link down

[    8.827789] IPv6: ADDRCONF(NETDEV_UP): enp2s0: link is not ready

[    9.596587] wlp3s0: authenticate with 00:26:5a:12:36:60

[    9.604699] wlp3s0: direct probe to 00:26:5a:12:36:60 (try 1/3)

[    9.805028] wlp3s0: send auth to 00:26:5a:12:36:60 (try 2/3)

[    9.806490] wlp3s0: authenticated

[    9.806648] ath5k 0000:03:00.0 wlp3s0: disabling HT/VHT due to WEP/TKIP use

[    9.807044] wlp3s0: associate with 00:26:5a:12:36:60 (try 1/3)

[    9.809204] wlp3s0: RX AssocResp from 00:26:5a:12:36:60 (capab=0x411 status=0 aid=1)

[    9.809473] wlp3s0: associated

[    9.809517] IPv6: ADDRCONF(NETDEV_CHANGE): wlp3s0: link becomes ready

[   10.491392] r8169 0000:02:00.0 enp2s0: link up

[   10.491410] IPv6: ADDRCONF(NETDEV_CHANGE): enp2s0: link becomes ready

[   11.272309] NFSD: Using /var/lib/nfs/v4recovery as the NFSv4 state recovery directory

[   11.283113] NFSD: starting 90-second grace period (net ffffffff81e93d40)

[   19.050411] uhci_hcd 0000:00:1d.0: reserve dev 2 ep81-INT, period 8, phase 4, 93 us
```

Dear charles17,

 *Quote:*   

> . You'd better decide for the one or the other, not mixing them. 

 

As I wrote before - I am using dhcpcd solution so configure with /etc/dhcpcd.conf as posted here.

If something is missing please let me know.

Thanks

----------

## charles17

 *pmam wrote:*   

> As I wrote before - I am using dhcpcd solution so configure with /etc/dhcpcd.conf as posted here.

 In that case /etc/conf.d/net will not be used and whole netifrc can be deleted. 

Refer to https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD

But, I just see you are using systemd and I dont know if it al all would work with this approach.  I've only tested with openrc.

You might check with https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD/Testing

----------

## NeddySeagoon

pmam,

That looks good.  What does 

```
route -n
```

show now?

----------

## pmam

NeddySeagoon,

Wired is connected:

```
route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    2      0        0 enp2s0

0.0.0.0         10.0.0.138      0.0.0.0         UG    202    0        0 enp2s0

0.0.0.0         10.0.0.138      0.0.0.0         UG    303    0        0 wlp3s0

10.0.0.0        0.0.0.0         255.255.255.0   U     202    0        0 enp2s0

10.0.0.0        0.0.0.0         255.255.255.0   U     303    0        0 wlp3s0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
```

wired disconnected:

```
route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    2      0        0 enp2s0

0.0.0.0         10.0.0.138      0.0.0.0         UG    303    0        0 wlp3s0

10.0.0.0        0.0.0.0         255.255.255.0   U     303    0        0 wlp3s0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
```

charles17,

 *Quote:*   

> In that case /etc/conf.d/net will not be used and whole netifrc can be deleted.

 

Are you sure? My wired interface configured with /etc/conf.d/net....

 *Quote:*   

> But, I just see you are using systemd

 

I am using openRC - maybe there are remains from the past - I tried systemd for a while - or it is normal, I do not know...

I forgot the command ps ... that shows what init system in use? 

Thanks

----------

## NeddySeagoon

pmam,

That looks mostly harmless but two links in the same subnet usually ends in tears.

```
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    2      0        0 enp2s0

0.0.0.0         10.0.0.138      0.0.0.0         UG    202    0        0 enp2s0

0.0.0.0         10.0.0.138      0.0.0.0         UG    303    0        0 wlp3s0 
```

This is your default gateway.  There should be at most, one default gateway, you have three.  Routing rules are applied from the bottos of the table, working towads the top, so if this works, its using wireless as wlp3s0 is the first rule encountered.  Ahh but they have different metrics ... the one wint the lowest metric is preferred, thats tho top rule ,so the wired interface is used.

```
10.0.0.0        0.0.0.0         255.255.255.0   U     202    0        0 enp2s0

10.0.0.0        0.0.0.0         255.255.255.0   U     303    0        0 wlp3s0 
```

 Its the same for the 10.0.0.0/24 subnet.

```
Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    2      0        0 enp2s0

0.0.0.0         10.0.0.138      0.0.0.0         UG    303    0        0 wlp3s0

10.0.0.0        0.0.0.0         255.255.255.0   U     303    0        0 wlp3s0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
```

Is broken because of the 

```
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    2      0        0 enp2s0
```

That routing rule has a metric of 2, so the kernel will try to use it even though  its not connected.

If you stop enp2s0, does it work then ?

----------

## pmam

Dear NeddySeagoon,

Beautiful analyzing... I am not understanding everything but I will try harder later on...

OK - I stopped enp2s0 with this: 

```
/etc/init.d/net.enp2s0 stop
```

and now here is the output:

```
route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    303    0        0 wlp3s0

10.0.0.0        0.0.0.0         255.255.255.0   U     303    0        0 wlp3s0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
```

Yes - now wireless is working... This message sent wirelessly   :Very Happy: 

Please let me know how to go a head...

EDIT: May be the problem is because I use conf.d/net for wired and dhcp for wireless?

Should I use the same way to both of them?

Thanks

----------

## charles17

 *pmam wrote:*   

>  *Quote:*   In that case /etc/conf.d/net will not be used and whole netifrc can be deleted. 
> 
> Are you sure? My wired interface configured with /etc/conf.d/net....

 Sorry for not being more clear at the beginning. 

Having net.* in a runlevel means you're still using the Gentoo net.* scripts solution, so you still need  /etc/conf.d/net.

With "dhcpcd solution" I mean you would have worked through https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD including the Migration... section.  Removing all net.* from the runlevels is essential there.

----------

## pmam

Dear charles17,

 *Quote:*   

> Removing all net.* from the runlevels is essential there.

 

So this means that I need to configure wired interface in /etc/dhcpcd.conf, as I have done for wireless?

May be the mixture I did with net.* and dhcpcd, is the reason for the 'metric' issue, 

that disabled wireless Internet connection... I am waiting for NeddySeagoon comment - 

I think there is  a way to change metric parameter, but your suggestion to work through dhcpcd seems the right way.

Dear NeddySeagoon,

 *Quote:*   

> That looks mostly harmless but two links in the same subnet usually ends in tears. 

 

When the machine is not close to a wired connector (disconnected), 

I want to switch automatically to wireless - There is any other choice regarding my case? 

BTW: When I am not going to use wireless for long time - How to turn off WIFI interface - 

in order to reduce radiation, save electrical power? 

Thanks

----------

## charles17

 *pmam wrote:*   

> So this means that I need to configure wired interface in /etc/dhcpcd.conf, as I have done for wireless?
> 
> May be the mixture I did with net.* and dhcpcd, is the reason for the 'metric' issue, 

 For a more verbous explanation see loc cit 4 https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD#cite_note-4 and search for "metric".

----------

## pmam

Dear charles17,

I added wired configuration to /etc/dhcpcd.conf and did the 'Migration' from net.* scripts to dhcpcd -

Now wired & wireless is working OK    :Smile: 

I did not change metric parameter - As you said, I need to choose one solution - so now I am using dhcpcd - 

it does not make sense to work with both of them!

Here wired is connected:

```
route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    202    0        0 enp2s0

0.0.0.0         10.0.0.138      0.0.0.0         UG    303    0        0 wlp3s0

10.0.0.0        0.0.0.0         255.255.255.0   U     202    0        0 enp2s0

10.0.0.0        0.0.0.0         255.255.255.0   U     303    0        0 wlp3s0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
```

Here wired disconnected:

```
route -n

Kernel IP routing table

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

0.0.0.0         10.0.0.138      0.0.0.0         UG    303    0        0 wlp3s0

10.0.0.0        0.0.0.0         255.255.255.0   U     303    0        0 wlp3s0

127.0.0.0       127.0.0.1       255.0.0.0       UG    0      0        0 lo
```

I also found out how to stop or start WIFI: Can do it with WPA_GUI or by command:

```
ifconfig -v wlp3s0 up/down
```

Many Thanks to you and to NeddySeagoon - Nice having you in neighbourhood...   :Very Happy: 

----------

## charles17

 *pmam wrote:*   

> I added wired configuration to /etc/dhcpcd.conf and did the 'Migration' from net.* scripts to dhcpcd -
> 
> Now wired & wireless is working OK    

 So you are using fixed IP for both wireless and wired?

Do you think it's worth adding your configuration experience to the wiki? Feel free to improve it.

----------

## pmam

 *Quote:*   

> So you are using fixed IP for both wireless and wired? 

 

Yes - Both are Static IP.

 *Quote:*   

> Do you think it's worth adding your configuration experience to the wiki?

 

I want to implement it on another machine, and work a little to see if everything is OK - 

Yes - It worth - During this installation I had some mistakes of my own, 

However,  some details and aspects should be added and emphasized.

I can and willing to do it - Not sure I am experienced enough to do it -

If I allowed doing it, consider it is my first time, so please inform me howto,   

and double-checking my work, by seniors, is needed, obviously...   :Wink: 

----------

## charles17

 *pmam wrote:*   

> However,  some details and aspects should be added and emphasized.
> 
> I can and willing to do it - Not sure I am experienced enough to do it -
> 
> If I allowed doing it, consider it is my first time, so please inform me howto,

 Just log in the wiki and start editing.  It's almost self explanatory.

----------

## NeddySeagoon

pmam,

You can mix and match a static IP on ohe interface with a dhcp provided setup on another.

In fact, most people use a dynamically assigned address on wireless to make it portable to airports, coffee shops and so on.

You can also cheat with dhcp and make it assign fixed addresses by MAC address, so everything looks dynamic but its not really.

You should not have two addresses in the same subnet at the same time.  It can be made to work but its a bad idea,

Look at the package called plugd.  It brings the wired interface up and down depending on if the wired interface is connected.

There are other packages for this too.

Look at /etc/rc.conf, in particular, the commets above  

```
#rc_depend_strict="YES"
```

If you use thing that depend on the net service, like sshd, you might want to change this to NO. Don't forget to uncomment. it.

Practice in the wiki sandpit.  Use the discussion tab if you like too.

What you write need not be 100%, its a guide to others that come after you. In their turn, they will improve upon what you leave behind.

----------

## charles17

 *NeddySeagoon wrote:*   

> Look at the package called plugd.  It brings the wired interface up and down depending on if the wired interface is connected.
> 
> There are other packages for this too.
> 
> Look at /etc/rc.conf, in particular, the commets above  
> ...

 These are in fact very important when using netifrc (Gentoo net.* scripts) as network manager. 

But they turn regardless for dhcpcd as network manager.

----------

