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

Can CBSD support a dynamic host IP? #61

Closed
rodyaj opened this issue Feb 11, 2016 · 8 comments
Closed

Can CBSD support a dynamic host IP? #61

rodyaj opened this issue Feb 11, 2016 · 8 comments
Assignees

Comments

@rodyaj
Copy link

rodyaj commented Feb 11, 2016

Hi. The documentation says that the nodeip should be the:

Working and static IP address of a node. It shouldn't be an alias

This is fine for most use cases, but not for mine, as I travel a lot with my laptop, and connect to many different wifi hotspots (work, home, hotel). This breaks the connectivity of my jails. So is it possible to use DHCP assigned IP with cbsd rather than static? That would save me the time of editing static IP in /etc/rc.conf and NAT rules (ipfw/pf) each time.

Or perhaps the nodeip is not essential to the jail management? Could I leave it blank, and just edit the NAT rules to use the wlan0 interface IP, rather than a static IP? I remember ipfw rules support the to me syntax to get the DHCP assigned IP of the interface.

If this is not possible, would you consider adding a feature to cbsd to support roaming between locations through wifi with jails?

Thanks. I realise my use case is unusual, but I can't be the only one that uses jails on the move to test and develop. I'm sure some people could benefit from a roaming jail setup.

@olevole olevole self-assigned this Feb 11, 2016
@olevole
Copy link
Member

olevole commented Feb 11, 2016

Hi!

"nodeip" must be static and it plays a role only if you have added one CBSD node to the other node ( via cbsd node mode=add ... )

in other cases (eg, local jails management) it is not essential.

So, if your jail have private (rfc1918) IP, but your laptop often gets a new address, all you have to do - is to enter a new IP address of node for NAT - rules forming and apply automatically:

This is two commands:

% cbsd natcfg     ( enter new IP )
% cbsd naton

Do I understand correctly that you're talking about the last example - you work only with local jail (and jails have private IP). And you want to IP NAT was taked from specified interface automatically, instead of fixed/hardcoded IP?

@olevole olevole closed this as completed Feb 11, 2016
@olevole olevole reopened this Feb 11, 2016
@rodyaj
Copy link
Author

rodyaj commented Feb 11, 2016

Yes, you have correctly understood my issue. Using 'natcfg' and 'naton', I will make a script to set the natip from my DHCP assigned IP automatically. Or maybe I will just rewrite /usr/jails/etc/ipfw.conf to use 'to me' syntax.

Thanks.

@olevole
Copy link
Member

olevole commented Feb 12, 2016

it seems easy to implement: olevole@09c4a25

natcfg can now be not only IPv4 but also as network interface (re0, vtnet0, ..).
The algorithm in this case is simple - on naton stage, first IPv4 was taken on the interface as natip ( This means that the IP must be initialized before CBSD starting)

At this point I'm assuming that a dynamic IP does not change during ONE system boot.

In other words, if you move the running laptop between WiFi/hotspot networks or switch ethernet cable and issued a new IP address - you'll have to run the command cbsd naton every time.

You can test new changes by swithing from port version to github CBSD-current:

  1. get git:
pkg install git
  1. remove installed version of CBSD ( it is safe for jail data):
% pkg remove cbsd
  1. If some files exist after removing in /usr/local/cbsd, remove it by hands:
rm -rf /usr/local/cbsd
  1. Clone develop-version from GH:
git clone https://github.com/olevole/cbsd.git /usr/local/cbsd
  1. Restore symlinks for bsdconfig module:
mkdir /usr/local/libexec/bsdconfig
ln -sf /usr/local/cbsd/share/bsdconfig/cbsd /usr/local/libexec/bsdconfig/cbsd
  1. Restore rc.d script via symlink:
ln -sf /usr/jails/rc.d/cbsdrsyncd /usr/local/etc/rc.d/cbsdrsyncd
ln -sf /usr/jails/rc.d/cbsdd /usr/local/etc/rc.d/cbsdd

(where /usr/jails is workdir)

  1. Upgrade CBSD code in your workdir from /usr/local/cbsd:
cbsd initenv
  1. Clean object files in /usr/local/cbsd:
make -C /usr/local/cbsd clean

@rodyaj
Copy link
Author

rodyaj commented Feb 12, 2016

Thanks for taking the time to do this. I will test it tomorrow, as I am away from a computer right now. Your changes seem reasonable though.

@rodyaj
Copy link
Author

rodyaj commented Feb 16, 2016

Hi. I am trying to test this on a fresh freebsd install without cbsd, but cannot find the cbsd executable after cloning into /usr/local/cbsd and running 'make' with the required dependencies.

@olevole
Copy link
Member

olevole commented Feb 16, 2016

For fresh install you need repeat steps with initenv:

% env workdir="/usr/jails" /usr/local/cbsd/sudoexec/initenv

See: http://www.bsdstore.ru/en/installing_cbsd.html#preparing ( 1b) Installing experimental (development) version of CBSD from github )

@rodyaj
Copy link
Author

rodyaj commented Feb 17, 2016

Yes sorry only just noticed the docs. Tested it and new nat feature works fine from bootup. Good work.

@olevole
Copy link
Member

olevole commented Feb 17, 2016

Excellent! I'll take it in the CBSD 10.3.0 release ( waiting for FreeBSD 10.3-RELEASE )

@olevole olevole closed this as completed Feb 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants