There are two ways to accomplish this. I'm not sure how to go about this using a GUI, but here's the standard way on Ubuntu. I will use the UFW and netplan tools which come with later versions of Ubuntu, as an example. One of these options should be applied on the laptop.
Setup a NAT
The reason your current setup isn't working is that you haven't setup a NAT, or Network Address Translation. A NAT is what is responsible for changing the device's IP as packets enter and leave your NAT gateway. A wireless router does this, and this is the reason devices have private IP addresses, but can still contact the outside internet.
In Ubuntu, setting up a NAT is fairly straightforward because of the built-in UFW utility. In the file /etc/ufw/sysctl.conf
, comment out the line net.ipv4.ip_forward=1
.
Also, set this line in /etc/default/ufw
DEFAULT_FORWARD_POLICY="ACCEPT"
Now, in the file /etc/ufw/before.rules
, add these lines just before the filter rules:
*nat
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o <WIRELESS INTERFACE> -j MASQUERADE
COMMIT
Change <WIRELESS INTERFACE>
to the name of your wireless interface, found using ip link
. Once you have made these changes, restart ufw to apply changes sudo systemctl restart ufw
, and also make sure the firewall is enabled by running sudo ufw enable
.
Your current configuration with static IPs on the ethernet interface will work fine, and your secondary device should now be able to contact the outside.
Setup a Bridge
Another option is to bridge your ethernet interface and your wireless interface, essentially turning your laptop into a network switch. This is the best option if you want your device to act as a normal device on your network (as in as far as the other devices in your network is concerned, this is just another wireless client). You can configure your interfaces in the file /etc/netplan/01-netcfg.yaml
or /etc/netplan/50-cloud-init.yaml
. Whichever file you have. This example assumed DHCP is provided from your wireless interface. If it is not, you can find other examples for netplan here.
network:
version: 2
renderer: networkd
ethernets:
<ETHERNET INTERFACE>:
dhcp4: no
<WIRELESS INTERFACE>:
dhcp4: no
bridges:
br0:
dhcp4: yes
interfaces:
- <ETHERNET INTERFACE>
- <WIRELESS INTERFACE>
Change to the interface your secondary device is connected to.
Then, run sudo netplan apply
to apply those changes. If you run ip a
you can confirm that the bridge interface br0
exists. Now, once you connect the secondary device and enable DHCP on that device, it will obtain an IP address from the wireless router and act as any other wireless device does on the network.
The bridge is now your primary interface from your wireless router, meaning if you wanted to assign a static ip on your laptop, for example, you would need to assign it on the bridge interface, not the wireless interface.