Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to setup DHCP in n2n network #629

Closed
maaarcus opened this issue Feb 7, 2021 · 5 comments
Closed

Failed to setup DHCP in n2n network #629

maaarcus opened this issue Feb 7, 2021 · 5 comments
Labels

Comments

@maaarcus
Copy link

maaarcus commented Feb 7, 2021

Hi all,

I've been using n2n and it worked wonderfully. I like how I can broadcast UDP even with cloud VMs using n2n.

To scale out my application, I will need DHCP to be working on n2n. However, there are little documentation. So I tried my best to get it working and I failed. I've put the details of my DHCP setup in the below post:
https://stackoverflow.com/questions/64403178/n2n-cannot-setup-dhcp-server-on-n2n-vpn-network

n2n version: n2n v.2.8.0.r540.53afd3c

Basically, I

  • started the superNode(ubuntu 20) on AWS
  • on the superNode, started a edge and join itself
  • set up DHCP on the targeted network interface on my superNode
  • DHCP server log showed that it was active
  • join the superNode on another machine(debian buster, raspberry pi), using -a dhcp:0.0.0.0

Result:
DHCP didn't assign any ip on my edge

~$ ip a

5: A5TAP: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1290 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether ce:be:21:a5:35:da brd ff:ff:ff:ff:ff:ff
    inet6 fe80::ccbe:21ff:fea5:35da/64 scope link 
       valid_lft forever preferred_lft forever

Anything I did wrong to setup DHCP on n2n?

@Logan007
Copy link
Collaborator

Logan007 commented Feb 7, 2021

I never tried DHCP at large scale, so I am a bit guessing here. But doesn't DHCP setup usually also require a DHCP client such as dhpcd?

As far as I can see, n2n itself does not include a DHCP client portion. By giving the dhcp: prefix and -r, n2n only paves the way to handle DHCP protocol on the line.

P. S. You could try the integrated auto IP address feature as of current 2.9 – you will not find it in 2.8; but keep in mind that it is still developing dev branch.

@maaarcus
Copy link
Author

maaarcus commented Feb 7, 2021

Thank you so much @Logan007 . You filled my missing puzzle and it worked... but not entirely...

So I once again joined my superNode on my pi:
sudo edge -r -d A5TAP -c a5 -k mykey -a dhcp:0.0.0.0 -l my-super-node-ip:1234

You mentioned I need to setup my client side dhcp. I found that I need to define the A5TAP interface, and set it to use dhcp.
so I went to /etc/network/interfaces on my edge and added:

auto  A5TAP
iface A5TAP inet dhcp

then I did :
sudo systemctl restart networking

and then I can see my edge has its ip assigned by my DHCP server!

ip a

4: A5TAP: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1290 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 02:8c:4c:9b:d4:67 brd ff:ff:ff:ff:ff:ff
    inet 192.168.233.2/24 brd 192.168.233.255 scope global dynamic A5TAP
       valid_lft 505sec preferred_lft 505sec
    inet6 fe80::8c:4cff:fe9b:d467/64 scope link 
       valid_lft forever preferred_lft forever

However, if I have the below setting on /etc/network/interfaces before A5TAP was available, I will not be able to reach the Internet at all. I have to add it after I've connected to the superNode, and then restart the network in order for it to work. Any ideas on how should I handle this? Seems like if the interface A5TAP is not created and I defined it in the config file, the network breaks.

auto  A5TAP
iface A5TAP inet dhcp

My /etc/network/interfaces FYR:

source-directory /etc/network/interfaces.d

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

#auto  A5TAP <- if added before A5TAP is created, cannot reach the Internet
#iface A5TAP inet dhcp

@Logan007
Copy link
Collaborator

Logan007 commented Feb 7, 2021

I hope there is a way to have DHCP client working on a specified interface only. Arch Wiki shows how to start dhcpcd service on a specific interface only, so you could first start the edge (which creates the interface) and then start the dhcpcd service on that interface (only) afterwards; hints are that command line /usr/bin/dhcpcd -w -t 0 <interface> might do as well.

If you run edge as a service, ExecStartPost might come in handy. Perhaps, as the involved dhcpcd itself is a service, there might be a solution involving the Wants/Requires/Befire/After/... entries in the .service file.

Can anyone with a working DHCP-over-n2n setup provide more details?

@maaarcus
Copy link
Author

maaarcus commented Feb 7, 2021

I played around a bit and found a solution that is working potentially:

I changed the line:
auto A5TAP
to
allow-hotplug A5TAP

After this, it won't block my pi from accessing the Internet on reboot, or when A5TAP interface has not been created yet. I can run the edge command at any point, and I will get my dhcp ip.

Please let me know if we have better approaches.

Thank you again @Logan007. I was stuck for so long!

@Logan007
Copy link
Collaborator

Logan007 commented Feb 7, 2021

Thank you for bringing this up. I might add it to our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants