Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
How can I switch between Wireless and Wired on a laptop?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Gladuin
n00b
n00b


Joined: 25 Jul 2018
Posts: 4

PostPosted: Wed Jul 25, 2018 6:43 pm    Post subject: How can I switch between Wireless and Wired on a laptop? Reply with quote

Hello,

My laptop has two networking interfaces, Wired (enp8s0) and Wireless (wlp9s0). I got those both to work but the problem is that when I plug in my ethernet cable, wlp9s0 is still up so I have two IP adresses. My question is, How can I bring wlp9s0 down when I plug in my ethernet cable?

Thanks for the help!
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
Location: Dallas area

PostPosted: Wed Jul 25, 2018 6:56 pm    Post subject: Reply with quote

I've set mine up so neither comes up automatically.

then I have aliases for bringing wpa up and down, and the ethernet up and down.

I don't have the laptop turned on at the moment, when I do later I'll see exactly how I've set it up.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Jul 25, 2018 8:01 pm    Post subject: Reply with quote

See sys-apps/ifplugd. Does exactly what you're asking for and works like a charm. :)

(Just pay no attention to the name of the author. ;) )

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Wed Jul 25, 2018 8:46 pm    Post subject: Reply with quote

Why not go one better and have both up? That way, wireless takes over instantly when the ethernet is unplugged.
You also get the option of sharing the same IP address on both interfaces if you're so inclined.

https://wiki.gentoo.org/wiki/Network_management_using_DHCPCD
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
Location: Dallas area

PostPosted: Wed Jul 25, 2018 8:49 pm    Post subject: Reply with quote

UberLord wrote:
Why not go one better and have both up? That way, wireless takes over instantly when the ethernet is unplugged.
You also get the option of sharing the same IP address on both interfaces if you're so inclined.

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


Sweet!!! I didn't know it could share the IP.

Thanks.
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
John R. Graham
Administrator
Administrator


Joined: 08 Mar 2005
Posts: 10587
Location: Somewhere over Atlanta, Georgia

PostPosted: Wed Jul 25, 2018 8:54 pm    Post subject: Reply with quote

UberLord wrote:
Why not go one better and have both up? That way, wireless takes over instantly when the ethernet is unplugged.
Well, personally, I don't want my WiFi radio on if I'm not using it.

- John
_________________
I can confirm that I have received between 0 and 499 National Security Letters.
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Wed Jul 25, 2018 9:00 pm    Post subject: Reply with quote

Well, that's why you have a nice toggle for wireless on/off (assuming a decent laptop).
But that's a hardware thing - software side you just set all go.

If you want a software switch you still set all go but just bring up or down the wireles interface:
ifconfig wlan0 down
ifconfig wan0 up

You could even script that as a dhcpcd exit hook if you wanted something portable across a variety of OS's

Simplez :)
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Gladuin
n00b
n00b


Joined: 25 Jul 2018
Posts: 4

PostPosted: Wed Jul 25, 2018 11:03 pm    Post subject: Reply with quote

John R. Graham wrote:
See sys-apps/ifplugd. Does exactly what you're asking for and works like a charm. :)

(Just pay no attention to the name of the author. ;) )

- John


Well I know about ifplugd and I searched around on how to use it but I still really dont know how :(
Back to top
View user's profile Send private message
Gladuin
n00b
n00b


Joined: 25 Jul 2018
Posts: 4

PostPosted: Thu Jul 26, 2018 2:20 pm    Post subject: Reply with quote

Anon-E-moose wrote:
I've set mine up so neither comes up automatically.

then I have aliases for bringing wpa up and down, and the ethernet up and down.

I don't have the laptop turned on at the moment, when I do later I'll see exactly how I've set it up.


Please do
Back to top
View user's profile Send private message
Anon-E-moose
Watchman
Watchman


Joined: 23 May 2008
Posts: 6097
Location: Dallas area

PostPosted: Thu Jul 26, 2018 2:34 pm    Post subject: Reply with quote

I do not have net.eth0, net.wlan0 or wpa_supplicant set to boot as services.

Code:
acer-linux:/home/me 1001) rc-update -v
...
             net.eth0 |
               net.lo | boot
            net.wlan0 |
             netmount |
...
       wpa_supplicant |


I then have these aliases in my .bashrc file
Code:

# network stuff
alias eth-up="sudo /etc/init.d/net.eth0 start"
alias eth-down="sudo /etc/init.d/net.eth0 stop"
alias wpa-up="sudo /etc/init.d/net.wlan0 start"
alias wpa-down="sudo /etc/init.d/net.wlan0 stop"


Because there are times that I simply don't want the network up or don't care if it's up.

"man rc-update" for how to add/remove services from boot
rc-update del net.eth0 as root for example

"man sudo" for adding user to be able to execute /etc/init.d scripts for example.
This is a little more complicated for just adding the ability for a user to use specific commands but not that difficult, and you can set it up so you don't need a password for that particular section. (not really recommended in general, but mine is a single use computer and I know what I'm doing)
_________________
PRIME x570-pro, 3700x, 6.1 zen kernel
gcc 13, profile 17.0 (custom bare multilib), openrc, wayland
Back to top
View user's profile Send private message
Gladuin
n00b
n00b


Joined: 25 Jul 2018
Posts: 4

PostPosted: Thu Jul 26, 2018 6:00 pm    Post subject: Reply with quote

I have come up with something myself.

I disabled all interfaces from starting up and I removed wpa_supplicant from boot. I only left dhcpcd to start on boot because then the IP adresses get assigned automatically when I bring an interface up.

I also made these scripts:
for starting my wireless interface
for starting my wired interface

If I can improve something on them, please tell me :wink:
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Fri Aug 24, 2018 3:12 pm    Post subject: Reply with quote

UberLord wrote:
Well, that's why you have a nice toggle for wireless on/off (assuming a decent laptop).
But that's a hardware thing - software side you just set all go.

If you want a software switch you still set all go but just bring up or down the wireless interface:
ifconfig wlan0 down
ifconfig wan0 up

You could even script that as a dhcpcd exit hook if you wanted something portable across a variety of OS's

Simplez :)
Indeed :) Just to add that acpid handles the toggle-switch on the laptop, and has done so reliably for at least fifteen years, that I know about.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum