Sunday, October 4, 2015

Going Full LINUX

This is more of a note for myself, but it may be useful for others.

My MacBook is dead - well, not quite, but there are signs that the logic board is going - and my father gave me a Toshiba laptop (more of ChromeBook) clone, but still useful with Windows 8 on it, plus a native USB3 port.

Firstly, I installed Ubuntu latest and greatest. This was relatively easy - usual problems with burning CDs - but it was set up in a trice, and connected via WiFi. This proved problematic because of the position of my laptop in the house, so I connected it to the router via a TP-Link power line adaptor.

Secondly, I have three NAS storage books on a subnet. This was relatively straight-forward on the Mac with Internet Sharing, but I had no such luxury with Ubuntu. Neither do I know much about networking. I did some google searching.

I took the following steps:

1. Connected my network switch to the laptop via USB3 ethernet adapter. This gave me "eth1", "eth0" being connected to the powerline adapter.

2. Enabled IP forwarding
    1.1 added this line
               net.ipv4.ip_forward=1
         to
               /etc/sysctl.conf
    then did this:
               /etc/init.d/procps restart


3. Installed dhcp3

4. Added the static ip address to eth1 via ip addr

Set back and waited, and nothing happened. zenmap gave me nothing, ifconfig showed me the IP address was attached to the NIC, and, sometimes, the Ubuntu server interface showed the servers I was trying to connect to. Mysteriously, eth1 would lose the ip address I'd assigned it so finally, I gave eth1 a static address via the Ubuntu network tools.

I went through some iptables stuff:

iptables -A FORWARD -o eth0 -i eth1 -s 192.168.2.0/24 -m conntrack --ctstate NEW
 -j ACCEPT
iptables -A FORWARD -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -F POSTROUTING
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

Which would help later but nothing happened immediately.

I also added

# eth1 subnet configuration

subnet 192.168.2.0 netmask 255.255.255.0 {
     range 192.168.2.1 192.168.2.99;
    option routers 192.168.2.1;
    option broadcast-address 192.168.2.255;
 }

to /etc/dhcp/dhcp.conf

 I tried wireshark, but I did not have the patience to work out what was going on. In particular, it told me that I had to run as a normal user when only running it as root gave me "access" to the right interfaces. Anyway, after flailing around some more on google I found this to be helpful

tcpdump -i eth1

which showed me that various MAC addresses were trying to connect to eth1 but the message "oui unknown" was the response.

Eventually, I restarted
/etc/init.d/isc-dhcp-server restart

and packets started flooded to the internet and back.

My QNAP NAS box surprised me by streaming out packets on 6881. Apparently that's "good for the community".

A lot of my pictures were on a USB3 connected external box, but as they had been attached to the Mac, they were formatted in HFS+. The Ubuntu tool hfsprogs is handy. I used the following command to mount the patition:

mount -t hfsplus -o force,rw /dev/sdc2 /media/roger/Pictures/

Whether this (or any of the other steps) survive a reboot of my machine is a moot point. Another adventure!

No comments:

Post a Comment