1

My desktop with Ubuntu 16.04 has no wifi but has an ethernet connection.

My laptop with Ubuntu 17.x has Wifi.

I've bought a crossover cable which has been checked and works.


Router

Has IP address of 192.168.1.254


Desktop with Ethernet

Wired Connection set under Ipv4 Settings with manual connection (method) to: 192.168.1.90/24 with gateway 192.168.1.69. Automatically connect to this network when available is checked.

Interface: name is eth0


Laptop

Wifi connection set to automatic DHCP and assigned 192.168.1.69.

I've tried setting this to "Shared to other computers" but then the interface isn't even assigned an IP. Pinging from desktop fails.

I've tried setting this to manual and entering 192.168.1.88 and then I can ping it once I've reset the network manager but that's it. At least the ethernet connection now has an IP.

Interface: name for ethernet is enp14s0,wifi name is wlp7s0


I've tried following every other question and answer tutorial I can find and none of them work the way they're supposed to. All I wish to do is use the internet connection from a laptop on the desktop via an ethernet crossover.

Any help appreciated

0

First of all, use a different subnet for the LAN.

Desktop: 192.168.2.2 Notebook LAN: 192.168.2.1

On the desktop configure your notebooks LAN ip address to be the default gateway.

On the notebook, enable IP forwarding:

echo 1 > /proc/sys/net/ipv4/ip_forward

You will need to edit /etc/sysctl.conf and change the line that says net.ipv4.ip_forward = 0 to net.ipv4.ip_forward = 1 to make this change permanent.

On the notebook, configure NAT for traffic coming in via the LAN interface (lets call it enp14s0) to go out via the wifi interface (lets call it wlp7s0)

/sbin/iptables -t nat -A POSTROUTING -o wlp7s0 -j MASQUERADE
/sbin/iptables -A FORWARD -i wlp7s0 -o enp14s0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i enp14s0 -o wlp7s0 -j ACCEPT

That should do the trick.

|improve this answer|||||
  • thanks for reply. what should gateway be for notebook in this case? – user3168961 Jul 29 '17 at 12:46
  • the notebook uses the wifi access point (or the router behind it if they are separate) as its default gateway.. don't change that. It should be automatically set when you connect to the wifi. – neuhaus Jul 29 '17 at 13:13
  • sorry i mean the enp14s0 gateway. my wifi is set using DHCP but I'm setting Wired connection manually in the network manager. In IPv4Settings I've added an IP 192..2.1, 24 mask but it disables the save button whenever I try to enter a gateway value either router ip, same ip... in fact any ip. – user3168961 Jul 29 '17 at 13:23
  • there is no default gateway on the LAN interface of the notebook. Just the network route for the subnet 192.168.2.0 with netmask 255.255.255.0 – neuhaus Jul 29 '17 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.