# How to restart a single network interface properly?



## disi (Mar 12, 2011)

I know I can run

```
# /etc/rc.d/netif restart
```
which restarts ALL network interfaces and kicks me out of ssh and if something goes wrong I am screwed.

Is there a way to only restart wlan0?

At the moment I do it like this:

```
# ifconfig wlan0 down
# ifconfig wlan0 up
# wpa_supplicant -B -c /etc/wpa_supplicant.conf -i wlan0
# route add default 192.168.1.254
```

It would be nice to have a netif script that takes the interface as a parameter or something. For example in Gentoo Linux you can link all interfaces to net.lo (if you want to, otherwise udev does that for you):

```
# ln -s /etc/init.d/net.lo /etc/init.d/net.wlan0
```
This enables you to control the interface wlan0 directly.

Looking into the script itself, it looks rather complicated and I don't want to break things... of course there must be a better way?


----------



## tingo (Mar 12, 2011)

Hmm, doesn't `# /etc/rc.d/netif restart wlan0` work?


----------



## disi (Mar 12, 2011)

Jesus, I knew there must be an easy way 
I really searched my a** off for this...

Thanks!


----------



## nORKy (Mar 12, 2011)

And  [cmd=]/etc/rc.d/routing start[/cmd]
?


----------



## wblock@ (Mar 12, 2011)

service(8) is nice.
`# service netif restart wlan0`


----------



## phoenix (Mar 17, 2011)

When in doubt, read the source:
`$ more /etc/rc.d/netif`


----------



## evansv2 (Sep 1, 2013)

*This feature is just a must*

`netif restart` is cool*.*


----------

