Sunday, May 17, 2020

How to join ZeroTier network from Windows XP on VirtualBox

How to join ZeroTier network from Windows XP on VM

My goal is to be on ZeroTier network using Windows XP.   I want to connect my roadwarrior laptops (win10 or ubuntu) and Virtualbox (WinXP) to a home server (win10 or ubuntu) using ZeroTier.  Virtualbox WinXP can not install ZeroTier client.  It will piggy back on the laptop host's ZeroTier client. 

You will need 

  1. a ZeroTier network 
  2. a server on ZeroTier client
  3. a host (win10 or ubuntu/mint) on ZeroTier client  
  4. a guest (virtualbox windows XP)
  5. The laptop host and server are on ZT pool (10.147.18.0/24) 
  6. home network (192.168.1.0/24).  
Zerotier network setup:  my.zerotier.com
Install by going here

HOW TO CONFIGURE THE SERVER
            
        join ZT as 10.147.18.10
        create SHARED directory  md SHARED
        share SHARED directory as SHARED (properties > sharing > Share > add users with read/write)


JOIN THE vm HOST ON ZEROTIER CENTRAL (MY.ZEROTIER.COM)
            
            
join a host ZT as 10.147.18.20
In ZT central: allow Ethernet Bridging 
 



HOW TO CONFIGURE THE HOST
 
Adapter 1:
Settings > Network > Adapter 1 is NAT  (you can choose bridged adapter > physical adapter)
        NAT will give you 10.0.2.15 > 255.255.255.0 > 10.0.2.2 gateway.  
        You can access host from VM, but host can not access VM in NAT.
        You can not pick the vm guest.   

        If you need the vm guest to see each other choose Bridged Adapter
        vm guest will get IP from the host's router DHCP server. 
        vm guest IP will be on 192.168.1.0/24
        You can ping other vm guests.

        I chose NAT for my purpose.  It seem more secure.

VirtualBox Setting

Settings > Network > Adapter 1 is Bridged Adapter to NAT
 

=====NOT USED ANYMORE
Settings > Network > Adapter 2 is Bridged Adapter to ZeroTier
 

In Virtualbox:  Activate adapter2 as while the session is powered off otherwise the adapter 2 will be grayed out
=====NOT USED ANYMORE


HOW TO CONFIGURE THE VM GUEST (winXP)
=====NOT USED ANYMORE
Configure the LAN connection 2 (ZT) manually



 
            control panel > network connection > local area connection 2 >  properties > Internet Protocol (TCP/IP) >  properties > IP address 10.147.18.102 
subnet 255.255.255.0
default gateway empty
DNS server: empty

It's important to leave default gateway fields empty.  Otherwise you will get this error.  See here 
  
if you do IPCONFIG, you will get NAT and ZT IP address:







Installation Verification Test:  

ping 10.147.18.10 from laptop VM (10.147.18.21)
remote desktop to 10.147.18.30 from laptop vm
map to server net use x: \\10.147.18.10\SHARED from laptop vm
            ping yahoo.com  (should not work)

Problems:  

  1. can't ping?  It's the firewall issue.  See here
  2. system error 64?  It's the SMBv1 issue.  See here


=======================RESOURCES==========================





This might be useful to connect e.g. Windows XP to ZeroTier network or other machines which you can't or don't want to install ZeroTier client to.

  1. Create ZeroTier network in control panel and join it on your host

  2. Allow Ethernet bridging for your host in control panel

    ZeroTier Control panel: Allow bridging

  3. In VM network settings, add second network adapter: bridge.

    Connect it to your ZeroTier network interface (e.g. zt0)

    VM network: ZeroTier bridge

  4. In your VM, configure network manually (e.g. if your ZeroTier network is 10.147.17.0/24, set IP in that range)

  5. Done! It won't show up in Control panel, but now your VM is part of your ZeroTier network.

 

Easy way of bridging lan for remote access

I've read a bunch of posts on how to bridge lans and I find it stupid that they want you to have two interfaces, create a bridge with brctl, setup routes in every router, etc and it never seems to work or be intuitive.

So, here's how to do it simply. You need one nic on the box you want to bridge your lan with. This is from a fresh network, you'll go in and add your two boxes and then go and set a route in the zerotier web config for your bridged lan -> the ip zerotier gives you on the lan bridge box.

For example, I have a zerotier box of 10.0.0.10 as my laptop, and another of 10.0.0.20. I've authorized both and validated they can ping each other. The lan network at my home is 192.168.1.0/24. So on the configuration page in the top right I add '192.168.1.0/24' as the 'network/bits' and '10.0.0.20' where it says (LAN).

You need to ensure that your bridge box has ip forwarding enabled. You can add net.ipv4.ip_forward = 1 to /etc/sysctl.conf on ubuntu and other systems and then run sysctl -p to reload the config.

You should now be able to ping the local, non-zerotier, IP of your bridge box but not the rest of your network. This is because the rest of your network still sees the packets as originating from something other than your lan which it doesn't know how to route to. To fix this you use an iptables masquerade rule.

On the bridge box you'll need your zerotier nic name and your local lan's nic name. Run ifconfig to see both.

My lan nic is named ens18 and my zerotier nic is named zt2lr2wzdx. Replace your two nics with what I have and run the following commands on your bridge box.

iptables -t nat -A POSTROUTING -o ens18 -j MASQUERADE
iptables -A FORWARD -i ens18 -o zt2lr2wzdx -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i zt2lr2wzdx -o ens18 -j ACCEPT

If you run a tcpdump -i ens18 icmp replacing your lan nic on any other box you have inside your lan you'll now see the pings originating from your bridge box and handling the nat for you.

You should now be able to access everything in your home lan and have the routes pushed to your zerotier clients. If the routes do not show up with a netstat -rn make sure you have allowManaged=1 in your /var/lib/zerotier-one/networks.d/###.local.conf file or whatever is respective to your system. In OSX/Windows you can select that in the GUI.

You can rinse and repeat this for any other networks you want to add as well.



https://www.reddit.com/r/zerotier/comments/a24w4p/how_to_create_lan_bridge_for_someone_not_network/


https://gist.github.com/laduke/98406c2eb86644901c24a453736e4014


This guide should help you out. I do something similar to this. I have a VM that runs on my home network, and I run a zerotier "router" in that VM. Whenever I need access to my full network, this is what I use.

https://www.digitalocean.com/community/tutorials/getting-started-software-defined-networking-creating-vpn-zerotier-one

More information here too.

https://www.reddit.com/r/zerotier/comments/9714a2/easy_way_of_bridging_lan_for_remote_access/






I was listening to a recent Packet Pushers Priority Queue podcast called Meet ZeroTier – Open Source Networking and decided to give ZeroTier a go, to see if it really worked as described. TL;DR: Yes it really does work as described! If you’re unfamiliar with ZeroTier I highly recommend listening to this podcast to understand why, what and how. If you’re unsure on the why, what and how, this blog post probably isn’t for you (yet!).

One of the obvious issues with ZeroTier is that for devices to talk to each other, they need a ZeroTier client installed. For laptops, mobile devices and even some NAS devices this isn’t a problem because there are clients in existence already. But what about using ZeroTier to extend an entire Layer 2 network? This is what the ZeroTier Edge device will do but it is entirely possible to configure a Linux host as an edge gateway device to do exactly this.

The following notes are based on a Linux host running Debian 8 and some of the notes will be specific to Debian and other such derivatives (e.g. Ubuntu).

If you’ve not done so already start by installing the Linux ZeroTier client. ZeroTier have also made this stupidly easy to do (ensure you have curl and gpg installed):

curl -s 'https://pgp.mit.edu/pks/lookup?op=get&search=0x1657198823E52A61' | gpg --import && \ if z=$(curl -s 'https://install.zerotier.com/' | gpg); then echo "$z" | sudo bash; fi

 

Now install the Linux bridge utilities:

apt-get install bridge-utils

 

Edit the network configuration (/etc/network/interfaces ) to bridge the Ethernet adapter and ZeroTier adapter together, giving the bridge interface (br0) the IP configuration from the Ethernet adapter. For example:

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address 192.168.0.3
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255
        gateway 192.168.0.254
        dns-nameservers 127.0.0.1
        dns-search home.lan
        bridge_ports eth0 zt0
        bridge_fd 0
        bridge_maxage 0
        post-up echo 1 > /proc/sys/net/ipv4/ip_forward

Note: The post-up directive is only required if you have other Layer 3 routable networks on your LAN. If you don’t, you don’t need this.

 

One gotchya is that the network service will start before the ZeroTier service meaning that the zt0 interface will not be present when the bridge interface is formed. A quick and dirty way around this is to add an entry to root’s crontab (sudo crontab -e  or edit you could edit /etc/crontab ) to restart networking after a reboot:

@reboot /etc/init.d/networking restart

 

Next move on to your ZeroTier network. Login to ZeroTier Central. If you’ve not done so already create a new network. Your ZeroTier network wants to use the same Layer 3 addressing as the network you’re bridging to. In my example this means the ZeroTier network will use 192.168.0.0/24 because my LAN is 192.168.0.0/24. Add this in to the Managed Routes section of your ZeroTier network and enable the Auto-Assign from Range option. Select Advanced and in the Auto-Assign Pool, set a range of IPs to assign to your ZeroTier clients that’s not used on your Layer 2 network, e.g. a range of IPs outside of your DHCP scope range so that no IP conflicts arise.

Back on the Linux host, use the zerotier-cli  command to request to join the host to your ZeroTier network:

zerotier-cli join <network id>

Note: When the Linux host joins the ZeroTier network it will likely drop off your LAN until all the configuration is completed. Ensure you have console access.

 

Now edit the /var/lib/zerotier-one/networks.d/<network id>.local.conf  file and set allowManaged  to 0.

On ZeroTier Central the host should now appear as a Member of your network and will need to be authorised to join it. In addition you’ll need to edit the properties of this member and enable Allow Ethernet Bridging and Do Not Auto-Assign IPs. Delete any IPs associated with the member and set a manual IP. This should be the same IP as used on the br0 interface on the Linux host (in my example this would be 192.168.0.3).

Reboot the Linux host. After it has rebooted you should see br0 is up with the correct IP configured (ifconfig br0 ) and the bridge should contain your Ethernet adapter (eth0 in this example) and the ZeroTier adapter (zt0). Check using brctl show .

If everything is correct your Linux host will be now be acting as an Ethernet (Layer 2) bridge between your LAN and your  ZeroTier network. Install tcpdump to see what’s happening (e.g. tcpdump -n -i br0 ‘not host 192.168.0.3’ ) and from another ZeroTier client on your ZeroTier network attempt to access a non-ZeroTier client on your LAN (like your toaster, because you know, everything is IoT now).

If you’ve got other Layer 3 (routable) networks on your LAN you can easily make this accessible from your ZeroTier network simply by adding the network to the Managed Routes section of your ZeroTier network via ZeroTier Central. This requires IP forwarding to be enabled on the Linux bridge so if you removed the post-up directive mentioned earlier, you’ll need to add this back in.





According to the Microsoft forums you can enable IP forwarding (routing) using the following steps:

Go to Start and search on cmd or command. Right click on either cmd or command then select Run as administrator. At the command prompt type regedit. Navigate to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\ Services\Tcpip\Parameters\IPEnableRouter setting, right click and select Modify. Change 0 to 1 and exit the editor.

When your back at the command prompt type services.msc and navigate to the Routing and Remote Access service. Right click and select Properties. Change to Automatic and click on Start to start the service.

After this, you will need to set the default gateway of hosts in network A to 10.10.10.34 and the default gateway of hosts in network B to 192.168.0.23. If this isn't doable because you would lose connectivity to the rest of your network (or internet), you can add static routes to hosts in both networks:

For hosts in network B:

route -p ADD 10.0.0.0 MASK 255.0.0.0 192.168.0.23

For hosts in network A:

route -p ADD 192.168.0.0 MASK 255.255.255.0 10.10.10.34

The -p switch is to make them persistent after reboots. You would need to restart after you apply these settings.



https://github.com/zerotier/ZeroTierOne/issues/805


Hi all,

So I've setup ZeroTier on my openwrt router at home. It successfully connects to the network and from the router shell, I can ping every hosts defined in my ZeroTier network topology... But pinging from my computer does not work..

What I would like to achieve is advertise the LAN of my home over my ZeroTier network. From what I understood, zerotier seems to create host-to-host connection but not network-to-network connection.
The all idea would be to:

  • access ZeroTier hosts within my home LAN network (without the need to configure zerotier on my laptop as it is already configured on the router).
  • from any zerotier host, been able to ping every hosts on my LAN network.

I previously managed to get this working with my previous DMVPN stack using iBGP to advertise LAN route prefix on the different hosts, but I have no clue on how to do this with ZeroTier.

In my zerotier central, I try adding a static route to my home router ZeroTier address to advertise the LAN but the ping seems to chop with a protocol unreachable error:

22:27:42.179367 IP 10.147.20.1 > 192.168.2.110: ICMP echo request, id 20033, seq 1, length 64
22:27:42.179435 IP 10.147.20.29 > 10.147.20.1: ICMP 192.168.2.110 protocol 1 port 29247 unreachable, length 92
22:27:43.180790 IP 10.147.20.1 > 192.168.2.110: ICMP echo request, id 20033, seq 2, length 64
22:27:43.180849 IP 10.147.20.29 > 10.147.20.1: ICMP 192.168.2.110 protocol 1 port 567 unreachable, length 92
22:27:44.183919 IP 10.147.20.1 > 192.168.2.110: ICMP echo request, id 20033, seq 3, length 64
22:27:44.183970 IP 10.147.20.29 > 10.147.20.1: ICMP 192.168.2.110 protocol 1 port 31281 unreachable, length 92
22:27:45.185824 IP 10.147.20.1 > 192.168.2.110: ICMP echo request, id 20033, seq 4, length 64
22:27:45.185872 IP 10.147.20.29 > 10.147.20.1: ICMP 192.168.2.110 protocol 1 port 52777 unreachable, length 92

10.147.20.1 -> a node in the my zerotier network trying to ping a host within the LAN.
10.147.20.29 -> my router zerotier address.
192.168.2.110 -> my laptop which is with the LAN that I'm trying to ping.

This is probably a dumb question with I'm lacking of network knowledge to understand under the hood what is going on there.

Thanks in advance :)


laduke commented on Aug 29, 2018

Here's a quick description of how to do it, if anyone stops by
zt router


PeopleSpace International