- Home
- Categories
- FreeBSD Notes
- Openvpn client Freebsd
Openvpn client Freebsd
-
Basic openvpn client Freebsd
pkg install openvpn
sysrc openvpn_enable="YES"
sysrc openvpn_if="tun"
Place your openvpn config file in a location unavailable to other users.
Insure your .conf contains the proper tunnel name, in this case I’ll use ‘tun’
This guide is basic! For simplicity of getting started; As well, service openvpn start is not required or needed in this situation!
service openvpn start
cd into the directory of your config file
then:
openvpn config.conf
Output:
Fri Nov 10 04:45:43 2017 library versions: OpenSSL 1.0.2k-freebsd 26 Jan 2017, LZO 2.10 Enter Auth Username: Enter Auth Password: Fri Nov 10 04:45:50 2017 TCP/UDP: Preserving recently used remote address: [AF_INET]<ip and port will print here> Fri Nov 10 04:45:50 2017 UDP link local (bound): [AF_INET][undef]:0 Fri Nov 10 04:45:50 2017 UDP link remote: [AF_INET]<ip and port will print here> Fri Nov 10 04:45:50 2017 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this Fri Nov 10 04:45:50 2017 [rick] Peer Connection Initiated with [AF_INET]<ip and port will print here> Fri Nov 10 04:45:51 2017 TUN/TAP device /dev/tun0 opened Fri Nov 10 04:45:51 2017 do_ifconfig, tt->did_ifconfig_ipv6_setup=0 Fri Nov 10 04:45:51 2017 /sbin/ifconfig tun0 10.10.2.10 10.10.2.9 mtu 1500 netmask 255.255.255.255 up add net <ip will print here>: gateway 10.10.5.1 add net 0.0.0.0: gateway 10.10.2.9 add net 128.0.0.0: gateway 10.10.2.9 add net 10.10.1.0: gateway 10.10.2.9 add net 10.10.2.1: gateway 10.10.2.9 Fri Nov 10 04:45:51 2017 Initialization Sequence Completed
As you can see there is a prompt for username and password. This can be circumvented, as well as starting the connection at boot. However this is just to get you going.
There is much more to learn!
-
Print command name running on port osx
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes osx0 Votes1 Posts356 Views -
Format USB FreeBSD gpart
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes gpart format usb0 Votes1 Posts886 Views -
zpool destroy /dev/ada0 operation not permitted
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes permitted operation freebsd zfs not ada00 Votes2 Posts1k Views -
Format USB device under FreeBSD
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes camcontrol format usb command line freebsd newfs+0
0 Votes2 Posts1k Views -
List block devices FreeBSD
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes list hard drive command line freebsd+0
0 Votes1 Posts822 Views -
Bhyve Hypervisor Freebsd ZFS
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes hypervisor freebsd bhyve vm zfs+0
0 Votes2 Posts2k Views -
FreeBSD Basic Commands
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes0 Votes1 Posts1k Views -
rc.conf read only
Watching Ignoring Scheduled Pinned Locked Moved FreeBSD Notes fbsd rc.conf read only freebsd0 Votes1 Posts2k Views
-
-
Print command name running on port
sudo lsof -iTCP -sTCP:LISTEN -n -P | awk 'NR>1 {print $9, $1, $2}' | sed 's/.*://' | while read port process pid; do echo "Port $port: $(ps -p $pid -o command= | sed 's/^-//') (PID: $pid)"; done | sort -n
-
Locate devices:
camcontrol devlistOutput; in this case only:
<ST3500418AS CC35> at scbus3 target 0 lun 0 (pass0,ada0) <ST500DM002-1BD142 KC45> at scbus5 target 0 lun 0 (pass1,ada1) <AHCI SGPIO Enclosure 1.00 0001> at scbus9 target 0 lun 0 (ses0,pass2) <Generic STORAGE DEVICE 1532> at scbus10 target 0 lun 0 (da0,pass3) <Generic STORAGE DEVICE 1532> at scbus10 target 0 lun 1 (da1,pass4)Where ada0 and ada1 are mechanical drives, da0 is a miniSD card in a USB enclosure da1
Or to print all partitions:
gpart showOutput (after formatting USB device):
=> 63 976773105 ada0 MBR (466G) 63 1 - free - (512B) 64 976773096 1 freebsd [active] (466G) 976773160 8 - free - (4.0K) => 0 976773096 ada0s1 BSD (466G) 0 4194304 1 freebsd-zfs (2.0G) 4194304 4194304 2 freebsd-swap (2.0G) 8388608 968384480 4 freebsd-zfs (462G) 976773088 8 - free - (4.0K) => 63 976773105 ada1 MBR (466G) 63 1 - free - (512B) 64 976773096 1 freebsd [active] (466G) 976773160 8 - free - (4.0K) => 0 976773096 ada1s1 BSD (466G) 0 4194304 1 freebsd-zfs (2.0G) 4194304 4194304 2 freebsd-swap (2.0G) 8388608 968384480 4 freebsd-zfs (462G) 976773088 8 - free - (4.0K) => 32 2012128 da0 MBR (983M) 32 2012128 1 fat32 (982M)List partitions on dev da0:
gpart show da0Delete existing partitions:
gpart delete -i da0Destroy label:
gpart destroy da0Create new mbr spanning entire disk:
gpart create -s mbr da0Create new fat32 partition spanning entire disk:
gpart add -t fat32 da0Initialize fat32 file system:
newfs_msdos -F32 /dev/da0s1Lets break something!
Don’t do any of this unless you are prepared to break it all, or better yet, you read the man pages and find out what they actually do, very useful tools however.
I’m just making notes from other notes, various resources on the net.
gpart destroy -F da0Zero out the drive === !!!Don’t do this jazz regularly on any USB!!! The type of memory has a finite read/write number===
dd if=/dev/zero of=/dev/da0 bs=2m count=1Format the drive
newfs_msdos -F32 /dev/da0s1
-
Alternatively or in addition to the above to install bhyve:
pkg install vm-bhyve bhyve-firmware bhyve-rc-3 grub2-bhyveOutput:
To ensure binaries built with this toolchain find appropriate versions of the necessary run-time libraries, you may want to link using
-Wl,-rpath=/usr/local/lib/gcc48
For ports leveraging USE_GCC, USES=compiler, or USES=fortran this happens transparently.
===> NOTICE:
This port is deprecated; you may wish to reconsider installing it:
Unsupported by upstream. Use GCC 6 or newer instead… Message from vm-bhyve-1.1.8_1:
To enable vm-bhyve, please add the following lines to /etc/rc.conf, depending on whether you are using ZFS storage or not. Please note that the directory or dataset specified should already exist.
vm_enable="YES" vm_dir="zfs:pool/dataset"OR
vm_enable="YES" vm_dir="/directory/path"Then run :
vm initIf upgrading from 1.0 or earlier, please note that the ‘guest’ configuration option is no longer used.
Guests that are not using UEFI boot will need either loader=“grub” or loader=“bhyveload” in their configuration in order to make sure the correct loader is used.
Message from bhyve-rc-3:
Configuration is done completely though rc.conf. The rc script won’t touch any devices for you (neither disk, nor tap) so you need to make sure all of those have been initialized properly.
General setup:
kldload vmm net.link.tap.up_on_open=1Make it persistent:
echo "net.link.tap.up_on_open=1" >> /etc/sysctl.conf cat >> /boot/loader.conf << EOF vmm_load="YES" EOFMinimal example:
cat >> /etc/rc.conf << EOF cloned_interfaces="tap0 bridge0" bhyve_enable="YES" bhyve_diskdev="/dev/zvol/anything/bhyve/virt" EOF ifconfig tap0 create ifconfig bridge0 create service bhyve start tmux list-sessions tmux attach -t bhyve service bhyve status service bhyve stopMulti profile configuration example:
cat >> /etc/rc.conf << EOF cloned_interfaces="tap0 tap1 bridge0" bhyve_enable="YES" bhyve_profiles="virt1 virt2" bhyve_virt1_diskdev="/dev/zvol/anything/bhyve/virt1" bhyve_virt2_tapdev="tap1" bhyve_virt2_diskdev="/dev/zvol/anything/bhyve/virt2" bhyve_virt2_memsize="8192" bhyve_virt2_ncpu="4" EOF ifconfig tap0 create ifconfig tap1 create ifconfig bridge0 create service bhyve start # start all service bhyve start virt2 # start individual tmux attach -t bhyve_virt1 tmux attach -t bhyve_virt1 service bhyve stop virt2 # stop individual service bhyve stop # stop all(by default ctrl-b d detaches from tmux).
-
If attempting to install FreeBSD on a disk which previously belongs to a ZFS, and you get this error: Before installing, select the option ‘shell’
Once in the shell, remove geom protections by running:
sysctl kern.geom.debugflags=0x10When your finished, type exit and return to the install / configure screen.
-
Which means geom is protecting the disk.
Running the following clears the protection:
sysctl kern.geom.debugflags=0x10Output:
kern.geom.debugflags: 0 -> 16Clearing MBR and partitions:
dd if=/dev/zero of=/dev/ada0 bs=512 count=1 conv=notrunc