View previous topic :: View next topic |
Author |
Message |
Gladuin n00b
Joined: 25 Jul 2018 Posts: 4
|
Posted: Wed Jul 25, 2018 6:43 pm Post subject: How can I switch between Wireless and Wired on a laptop? |
|
|
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 |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6097 Location: Dallas area
|
Posted: Wed Jul 25, 2018 6:56 pm Post subject: |
|
|
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 |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Jul 25, 2018 8:01 pm Post subject: |
|
|
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 |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
|
Back to top |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6097 Location: Dallas area
|
Posted: Wed Jul 25, 2018 8:49 pm Post subject: |
|
|
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 |
|
|
John R. Graham Administrator
Joined: 08 Mar 2005 Posts: 10587 Location: Somewhere over Atlanta, Georgia
|
Posted: Wed Jul 25, 2018 8:54 pm Post subject: |
|
|
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 |
|
|
UberLord Retired Dev
Joined: 18 Sep 2003 Posts: 6835 Location: Blighty
|
Posted: Wed Jul 25, 2018 9:00 pm Post subject: |
|
|
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 |
|
|
Gladuin n00b
Joined: 25 Jul 2018 Posts: 4
|
Posted: Wed Jul 25, 2018 11:03 pm Post subject: |
|
|
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 |
|
|
Gladuin n00b
Joined: 25 Jul 2018 Posts: 4
|
Posted: Thu Jul 26, 2018 2:20 pm Post subject: |
|
|
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 |
|
|
Anon-E-moose Watchman
Joined: 23 May 2008 Posts: 6097 Location: Dallas area
|
Posted: Thu Jul 26, 2018 2:34 pm Post subject: |
|
|
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 |
|
|
Gladuin n00b
Joined: 25 Jul 2018 Posts: 4
|
Posted: Thu Jul 26, 2018 6:00 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
steveL Watchman
Joined: 13 Sep 2006 Posts: 5153 Location: The Peanut Gallery
|
Posted: Fri Aug 24, 2018 3:12 pm Post subject: |
|
|
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 |
|
|
|