Connect to both WiFi and Ethernet simultaneously in Ubuntu 16.04
To explain the comment here a little more, basically what you need to do is
- connect to both ethernet and wifi, you should now have 2 interfaces showing in
ifconfig -a
.
Let's assume the wifi IP is 192.168.0.11
and the ethernet is 10.1.1.45
. Wifi gateway is 192.168.0.1
and the ethernet gateway is 10.1.1.1
- now you need to setup the routing table to send some traffic via ethernet and the rest via wifi. Lets say traffic destined for a couple of ethernet internal subnets - all
10.0.0.0/8
addresses (and for some strange reason)149.9.1.0/24
should go via ethernet and everything else can go to wifi
Disclaimer - I dont have an ubuntu vm handy to test, these are the commands I use on a Mac to do the same thing
$ route add 10.0.0.0/8 10.1.1.1
$ route add 149.9.1.0/24 10.1.1.1
netstat -rn
will show the routing table:
$ netstat -rn
Destination Gateway Genmask Flags MSS Window irtt Iface
10.0.0.0 10.1.1.1 255.0.0.0 UG 0 0 0 eth1
149.9.1.0 10.1.1.1 255.255.255.0 UG 0 0 0 eth1
0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0
169.254.169.254 0.0.0.0 255.255.255.255 UH 0 0 0 eth0
192.168.0.1 0.0.0.0 255.255.0.0 U 0 0 0 eth0
you might need to muck around with the ordering of the interfaces to make it work. netstat
and ip
will be your friends here.
Related videos on Youtube
AronAtVW
Updated on September 18, 2022Comments
-
AronAtVW over 1 year
I'm working on a project for school that uses an Ubuntu machine connected to a Raspberry Pi through Ethernet with no internet connection (none needed). I also need a wireless connection to a separate local network which I am doing with a USB wireless adapter. I have little experience with Ubuntu and am not fully aware of what settings were put in place prior to me working on the system.
Both the Wifi and Ethernet are static with different IPs. Both connections work fine, but only one or the other. I need to have a wireless connection because I'm trying to send commands from Android to Apache on Ubuntu locally.
-
davidgo about 5 yearsSimply remove the gateway from the wireless connection, and make sure that the networks for each interface (ie the IP address ranges) do not overlap.
-
monx over 2 years
-
-
AronAtVW about 5 yearsThank you so much, this information was surprisingly difficult to find. I kept finding bridging connections, sharing WiFi internet through Ethernet and people recommending not doing this thinking it's on the same network and causing a loop. Again thank you this makes a lot of sense now.
-
stringy05 about 5 yearsit's easy, when you know how to do it! Like brain surgery I guess..
-
AronAtVW about 5 yearsLol indeed! That's the next goal after this!