# USB Wireless device Tp-Link TL-WN822N rtl8192cu

## hasansahin

Hello mates,

I have a wireless usb device that is using rlt8192cu kernel module. My security profile is WEP for my wifi network.

When I have a look for my device name

```
ls -al /sys/class/net
```

 *Quote:*   

> lo wlp0218s2u2

 

I use following commands to connect my wifi network

```
iwconfig wlp0218s2u2 essid <my_essid>

iwconfig wlp0218s2u2 key s:<my_WEP_key>

dhcpcd wlp0218s2u2
```

it works but sometimes dhcp service stop to working when I changed the user or chroot. and I have to apply again the above-mentioned commands.

Question 1 : iwconfig or wpa_supplicant - I could not decide which is the best? does wpa_supplicant stop to working on sometimes?

Question 2 : how can I automate the wifi-connection command as a system or boot service? or should I use networkmanager?

P.S. : I read gentoo handbook doc. and it does not explain how can I automate wifi connection (iwconfig or wpa_supplicant) as a system or boot service. Or I could not see  :Smile: 

----------

## MechanicalBear

If you using systemd you can create service file in /etc/systemd/system like wifi.service and place your commands with full path to binary in it.

```
[Unit]

Description=WIFI connectivity

[Service]

Type=simple

ExecStart=/sbin/iwconfig wlp0218s2u2 essid <my_essid> 

ExecStart=/sbin/iwconfig wlp0218s2u2 key s:<my_WEP_key> 

ExecStart=/sbin/dhcpcd wlp0218s2u2
```

then you must reload services

```
systemctl daemon-reload
```

and then enable your service to run on boot

```
systemctl enable.wifi
```

after reboot service will start wifi connectivity automatically

but the better way (if you using X) to install wicd - it is a tray application to manage both wireless and wired networks for Linux.

----------

