There are a few ways to do it:
Option A: Make your Linux machine into a router:
Your Wi-Fi will be the WAN side and ethernet LAN
sudo su
# tell the kernel to do routing
echo 1 > /proc/sys/net/ipv4/ip_forward
# make sure that you can route traffic
iptables -P FORWARD ACCEPT
# NAT anything behind your router
iptables -t nat -A POSTROUTING -j MASQUERADE
# Turn off any local DNS resolvers that might interfere
echo nameserver 1.1.1.1 > /etc/resolv.conf
systemctl stop systemd-resolved
killall dnmsasq
# Run a local DHCP server on the LAN side
# change the interface to the right one
ifconfig eth0 192.168.20.1/24
dnsmasq -F 192.168.20.2,192.168.20.254 -i eth0 -d
Now any device you connect to the LAN side eth0
in this case, will get a DHCP address from your linux machine, and it will use the linux machine as the gateway and DNS, which in turn will use whatever you set on your Wi-Fi. If you reboot your machine these settings will disappear.
Option B: Bridge your connection
This option doesn't work with Wi-Fi adapters - that's a bit more complicated, but if you have 2 or more ethernet adapters, it's a great solution. It allows you also to do web filtering, traffic shaping, MitM attacks, etc.
sudo su
apt-get install bridge-utils
brtcl addbr br0
brctl addif br0 eth0
brctl addif br0 eth1
# Change eth0 and eth1 with your interface names
# "ifconfig" or "ip link" will show interface names.
ifconfig eth0 up
ifconfig eth1 up
# only necessary if you want the machine itself to have internet
dhclient -d br0
This is also a temporary setting. You might have to stop any other networking managers you have, before you do this:
systemctl stop network-manager
systemctl stop networkamanger
systemctl stop networking
service network stop
???
If any of the systemctl commands fail, it just means they don't exist or are not necessary on your linux. I am not sure what service manager it uses... but you should have enough now to search for the steps or read the documentation and see how to do it on your machine.
Fun fact: no matter how you do it, under the hood almost all routers and Linux machines do the above behind the curtain.
If you want to make the changes permanent, you will have to figure out what service or network manager your Linux uses, and edit its config files to accomplish the same as the above. Maybe this will work:
Option C: Bridge connection with network manager
ip a # check which devices you need to bridge
sudo nmcli c add type bridge con-name my-bridge ifname eth0
sudo nmcli c add type bridge con-name my-bridge ifname eth1
sudo nmcli c connect my-bridge
This should make it permanent. Although I could never get network manager to really do what I wanted it to despite reading the docs, and always end up just disabling it and creating my own config in /etc/rc.local
.