LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-11-2018, 02:45 PM   #1
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,650

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Operate eth0 and wlan0 interchangeably


I tried to make WiFi on my notebook work by following the instructions at https://docs.slackware.com/slackbook:wifi. Of course, it does not work.
The problem seems to be that I am trying to operate the WiFi card AND the ethernet card interchangeably. Here is an excerpt of my rc.inet1.conf

Code:
IPADDR[0]="192.168.1.10"
NETMASK[0]="255.255.255.0"
...
IFNAME[1]="wlan0"
IPADDR[1]="192.168.1.15"
NETMASK[1]="255.255.255.0"
...
GATEWAY=192.168.1.1
Everything is working as long as the ethernet cable is plugged in. If I unplug then the network does not work, even though I can see at my router that wlan0 has registered correctly. Running route -n reveals
Code:
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth0
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
...
Is there a way to route to the gateway via wlan0? The only disadvantageous solution I have so far is to configure only wlan0, e.g.,
Code:
IFNAME[0]="wlan0"
IPADDR[0]="192.168.1.15"
NETMASK[0]="255.255.255.0"
...
GATEWAY=192.168.1.1
but then I still have to reboot and if I do not need WiFi then eth0 will not work and I have to reconfigure again. There must be a better, smarter and faster way to reassign the gateway route, right?


PS: Please do not suggest any kind of network manager, like wicd or NetworkManager etc. Thanks.

Last edited by crts; 09-11-2018 at 02:53 PM.
 
Old 09-11-2018, 03:02 PM   #2
abga
Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 702

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
This might interesting for your scenario:
https://www.linuxquestions.org/quest...er-4175637284/
 
Old 09-11-2018, 03:17 PM   #3
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,650

Original Poster
Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
No, I actually want the interfaces to have different addresses. I was thinking of a solution like

Code:
route add default gw 192.168.1.1 eth0
to switch back to eth0, but this just returns an error:

Code:
SIOCADDRT: Network is unreachable
I further noticed, that if I configure eth0 after wlan0 in rc.inet1.conf then eth0 does not get configured at all, not sure what the reasoning behind this behaviour is.
 
Old 09-11-2018, 04:05 PM   #4
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,650

Original Poster
Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
As it turns out it is just as easy as simply running

Code:
route add default gw 192.168.1.1 [eth0|wlan0]
It did not work previously because while fiddling with rc.inet1.conf I misconfigured it accidently.

Follow up question: What is the equivalent 'ip' command for above 'route add ...'?
 
Old 09-11-2018, 04:11 PM   #5
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 5,374

Rep: Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141Reputation: 3141
Quote:
Originally Posted by crts View Post
Follow up question: What is the equivalent 'ip' command for above 'route add ...'?
I'd imagine:

Code:
ip route add default via 192.168.1.1 dev eth0
But this is just after looking at this cheatsheet, which doesn't cover specifying devices with that particular command.
 
1 members found this post helpful.
Old 09-11-2018, 04:16 PM   #6
abga
Member
 
Registered: Jul 2017
Location: EU
Distribution: Slackware
Posts: 702

Rep: Reputation: 389Reputation: 389Reputation: 389Reputation: 389
It'll be useful if you could specify what version of Slackware you're on.
Then, can you please provide the output of the following commands before you unplug the eth0 cable and afterwards?
Code:
/usr/sbin/ip link show
/usr/sbin/ip addres show
/usr/sbin/ip route
I'm not using the rc.inet* scripts Slackware is providing but my own (personal preference) and I don't know them very well (how they are configuring the interfaces) but from a networking POV, after you unplug the eth0 you'll also loose the default gateway. The commands from above will show that.

If you don't like the bonding/fail-over solution that I suggested in my previous post, there is another way to achieve what you're looking after, but some manual steps would be required. You need to define two default routes for your two adapters (eth0,wlan0) with different metrics.
Again, not really knowing how rc.inet1 is doing the config (too tired now to parse it), you might have the possibility to leave the GATEWAY= empty in rc.inet1.conf and insert these lines in the rc.inet1 script, where the default GW is defined:
Code:
/usr/sbin/ip route add default via 192.168.1.1 metric 1 dev eth0
/usr/sbin/ip route add default via 192.168.1.1 metric 11 dev wlan0
You could also put these two lines in rc.local, but that script is executed very late and you might need connectivity before that.

P.S. While I was writing my post you already discovered ip route

Last edited by abga; 09-11-2018 at 04:21 PM. Reason: P.S.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
eth0 and wlan0 vs wlan0 problem player107 Linux - Wireless Networking 3 02-25-2013 09:54 AM
Arch Does Not See wlan0 or eth0 theW Linux - Newbie 1 08-12-2011 06:51 PM
[SOLVED] bonding wlan0 and eth0 dimm0k Slackware 4 07-09-2011 02:54 PM
Eth0 to WLAN0 how do i rename it? XeoNoX Linux - Wireless Networking 5 02-22-2004 05:54 AM
Starting wlan0 instead of eth0 eo697 Linux - Networking 2 10-12-2003 05:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration