1

I'm trying to share my wireless connection (wlp1s0b1) on my Ubuntu 16.04 headless laptop to my Windows 10 PC via ethernet (enp0s9).

This is a diagram of my network:

Router (198.168.0.1)---(wifi)---> Laptop(192.168.0.169) ---(eth)---> PC(192.168.127.2)

I have been researching for a while now on the methods to do so. I followed this tutorial here. I have a WiFi connection to my router after following this quick guide and my result is an IP address assigned to my Windows 10 PC (192.168.127.2, good so far) as well as the netmask and gateway (as described in the guide, 192.168.127.1 & 255.255.255.0 respectively).

Now, I am unable to ping between either computer at the known IP addresses. Neither does the Windows 10 PC have any external connection recognized.

Relevant outputs (Laptop):

ifconfig
enp0s9 Link encap:Ethernet HWaddr 70:cd:60:44:47:ba 
inet addr: 192.168.127.1 Bcast 192.168.127.255 Mask:255.255.255.0

wlp1s0b1 Link encap:Ethernet Hwaddr 10:9a:dd:b7:ba:b7
inet addr: 192.168.0.169 Bcast:192.168.0.255 Mask:255.255.255.0

route -n
Destination     Gateway    Genmask  Flags  Metric  Ref  Use Iface
0.0.0.0    192.168.0.1     0.0.0.0      UG     600  0     0 wlp1s0b1
192.168.0.0   0.0.0.0     255.255.255.0 U    600    0     0 wlp1s0b1
192.168.127.0   0.0.0.0   255.255.255.0  U     0    0     0 enp0s9
192.168.200.0   0.0.0.0     255.255.255.0    U    0   0   0 enp0s9

UFW is disabled:

UFW status
Status: inactive

Then the relevant entries from the /etc/network/interfaces file:

auto enp0s9 
allow-hotplug enp0s9
iface enp0s9 inet static
address 192.168.200.0
netmask 255.255.255.0
broadcast 192.168.200.255
gateway 192.168.0.1

iface enp0s9 inet6 auto

Then the nmcli output:

nmcli connection 
NAME           UUID TYPE            DEVICE
mynetworkname  UUID 802-11-wireless wlps0b1

In addition, running isc-dhcp-server as described in the first tutorial/guide.

So what am I missing? I suspect it has something to do with my gateway assignment, but I just can't place it or figure out what else to check research.

All I'm trying to do is implement the "share to other computers" setting available in the GUI.

I have already read the following questions. My question pertains to this being debugged. This question is similar, but mine is for headless. This question is also similar, but still GUI.

How can I do this?

Edit: I am running a headless server addition, I have no GUI options.

  • 1
    Any reason that you just can't wire the PC to your router with an ethernet cable? Or PC wireless to router? I can't imagine that performance would be good with what you're trying to do. – heynnema Feb 09 '19 at 14:58
  • Check your /etc/network/interfaces file you have address 192.168.200.0 - it is reserved for network itself. Also check the gateway it is in another subnet – MrSnowMan Feb 09 '19 at 16:54
  • @heynnema at the moment, I am unable to hookup directly to the router via etherernet & I have no wireless adapter on the PC. Of course it would be so much better if I could! – theQuantumMechanic Feb 09 '19 at 23:59
  • @Gravemind I did notice this while posting, but it wasn't like that in a previous test. However, I was under the impression to do what I'm doing I had to setup the ethernet connection a different subnet? – theQuantumMechanic Feb 10 '19 at 00:00

1 Answers1

0

SOLVED: Ok so after some more digging around I ended up solving this myself thanks to a handy VM I quickly setup with Oracle VirtualBox.

Quick solution:

You need to create a new connection using nmcli for ethernet. Then edit the relevant config file, like so:

>$ nmcli connection add type ethernet ifname enp0s9 && nmcli connection

Name output should be equivalent: type-iface (in my case ethernet-enp0s9). Interchange nano with your editor of choice.

>$ cd /etc/NetworkManager/system-connections
>$ sudo nano ethernet-enp0s9

Now change the method from auto to shared!! Under the [ipv4] config tab:

[ipv4]
dns-search=
method=shared # should be auto by default

Save and then restart network manager with a simple systemctl restart NetworkManager


Long explanation:

So, my Mint VirtualBox VM helped a lot here. After doing the usual GUI method to share the internet, checked the config (screenshot) & found the option for methods. Now jump back to my headless system and uncomment of all my iface configs in /etc/network/interfaces (excluding lo), save & exit. Create the new ethernet connection with nmcli, ethernet-enp0s9, jump to its config in /etc/NetworkManager/system-connections/ & simply edit the method to shared from auto like above.

Now issue a shutdown -r command, unplug & replug the ethernet cable & finally restart the PC for completeness! I would also recommend double checking the UFW status after all this of course!

A final note:

Now in my case, I was messing around with the iptables beforehand and so forth, so I have a handy little script to reset the iptables which I run:

#!/bin/sh
#
# flush-iptables script.
#

# First delete all rules in the tables
iptables -F
iptables -t nat -F
iptables -t mangle -F

# Add default rules to the filter, nat & mangle tables:
iptables -P OUTPUT ACCEPT
iptables -P PREROUTING ACCEPT
iptables -P POSTROUTING ACCEPT

iptables -t nat -P INPUT ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT

iptables -P INPUT ACCEPT
iptables -P INPUT ACCEPT
iptables -P INPUT ACCEPT

# Remove all non-default chains in filter, nat & mangle tables. Usually what UFW adds
iptables -X
iptables -t nat -X
iptables -t mangle -X

# Finally restart network manager
systemctl restart NetworkManager && echo systemctl status NetworkManager
echo "__________________________________________DONE_________________________"

Hope this helps some other people! For some reason, this (I'll admit niche) topic is actually annoyingly hard to research for the CLI unless you were to really dig into. Which I would argue is a major point to using Linux! Even now that I know this solution, I have tried "reverse Googling" to try to find an official or even community solution to this problem & cannot find any relevant pages (correct me if I'm wrong of course!).