Skip to main content
Topic: Pass internet through ethernet cable to another computer (Read 254 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Pass internet through ethernet cable to another computer

Hello

I Have a computer which receives an internet connection through Wi-Fi, and another without Wi-Fi

I would like to "pass" internet from the one connected (which has Artix installed) to the other one through an ethernet cable.

When researching, I only find answers for Ubuntu or other distributions, but I can't use any other because pc has very low specs :')

Do anyone know what should I do? Do I need to install any package?

Thank you


Re: Pass internet through ethernet cable to another computer

Reply #2
wifisharing.sh:
Code: [Select]
#! /bin/bash

echo "Run as root, set up wifi sharing through ethernet port"
ip link set eno1 up
ip addr add 10.20.246.234/24 dev eno1
sysctl net.ipv4.ip_forward=1
iptables -t nat -A POSTROUTING -o wlp3s0 -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i eno1 -o wlp3s0 -j ACCEPT
echo "On connected machine:"
echo "copy this to resolv.conf"
cat /etc/resolv.conf
echo "& run: ip link set eth0 up / ip addr add 10.20.246.235/24 dev eth0 / ip route add default via 10.20.246.234 dev eth0"

# using Artix base iso, not sure if all this was required, first did : sudo rc-service netmount stop, & net.lo too.
# sudo ip addr flush dev DEVICE (eth0)   cleared table as per netstat -nr output, so could add new addr & default route.
Run "ip link show" first and change the device names to whatever you have. You could probably turn the last commands for the connected machine into a script as well to save a bit more typing if you were doing this frequently.
Don't know if it affects this, watch out for Network Manager, it sometimes interferes with doing low level networking things if it's installed. Then again, it apparently has settings to do this itself but I haven't done that, my script method is based on the Arch Wiki:

https://wiki.archlinux.org/title/Internet_sharing

https://fedoramagazine.org/internet-connection-sharing-networkmanager/

Re: Pass internet through ethernet cable to another computer

Reply #3
Is usb tethering fine? If yes I can link something.

Re: Pass internet through ethernet cable to another computer

Reply #4
this all have to do with your default gateway and IP assignments.  You assign the gateway to the ip address of the computer you want to go through.  You can also set up various tunnels like VPNs or even SSH proxies.


My routing looks like this, for example

Code: [Select]
 sudo ip ro
default via 10.0.0.41 dev eth0 proto dhcp src 10.0.0.62 metric 1002
10.0.0.0/24 dev eth0 proto dhcp scope link src 10.0.0.62 metric 1002
127.0.0.0/8 via 127.0.0.1 dev lo

Also - see the /etc/conf.d/net     file

See this documentation:
https://wiki.gentoo.org/wiki/Handbook:X86/Full/Networking#Getting_started_with_netifrc