Archive

Archive for September, 2020

Freebsd Wireless Networking Static and Dynamic IP Configuration

September 15, 2020 Leave a comment

FreeBSD documentation pretty much explains everything but there are still some missing steps if you get into trouble and not used to FreeBSD.

Also most of “supposed to work” parameters might not work just like my laptop.

So this write up is to summarize and simplify necessary steps.

Test system is Thinkpad x120e running FreeBSD 12.1-RELEASE-p9 pretty old laptop but still requires some work on freebsd.

Wireless card: Realtek RTL8188CE 1×1 11b/g/n 

Step 1:

Load Realtek drivers at boot time, add following lines to /boot/loader.conf

if_rtwn_pci_load="YES"
if_rtwn_usb_load="YES"

For list of  Realtek cards supported by rtwn driver:

root@iphone:~ # man rtwn

Reboot the system or load modules manually with kldload.

After the reboot you will still not see wlan interface but check if your wifi card recognized by FreeBSD

root@iphone:~ # sysctl net.wlan.devices
net.wlan.devices: rtwn0

Now you need to create the wlan device:

ifconfig wlan create wlandev rtwn0

Step 2:

DHCP Setup:

Edit /etc/rc.conf and add following :

wlans_rtwn0="wlan0"
ifconfig_wlan0="WPA SYNCDHCP"

Edit /etc/wpa_supplicant.conf  add your ssid and pw

network={ 
    ssid="freebsdap"
    psk="freebsdmall"
}

Now restart networking service:

root@iphone:~ # service netif restart

check your connections with ifconfig and look for wlan0 interface

wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether xx:xx:xx:xx:xx:xx
inet 192.168.11.11 netmask 0xffffff00 broadcast 192.168.11.255
groups: wlan
ssid yourssidhere channel 6 (2437 MHz 11g ht/20) bssid xx:xx:xx:xx:xx:xx
regdomain FCC country US authmode WPA2/802.11i privacy ON
deftxkey UNDEF AES-CCM 2:128-bit AES-CCM 3:128-bit txpower 30 bmiss 7
scanvalid 60 protmode CTS ht20 ampdulimit 64k ampdudensity 8 shortgi
-stbc -ldpc wme roaming MANUAL
media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
status: associated
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>

If everything work fine you are good to go.

Now once you restart your bsd box if you are unlucky like me your wlan interface will be gone and you wont be able to connect your AP.

A lot of folks say their setting remains the same but im not one of them so here is the solution:

Solution 1:

We’ll create a shell script and place it under rc.d this way when the box reboots FreeBSD will run our script and we’ll connect to AP automaticaly.

root@iphone:~ # vim /usr/local/etc/rc.d/wifi.sh

and add below lines:

#!/bin/sh
ifconfig wlan create wlandev rtwn0
service netif restart

Now make it executable:

chmod +x /usr/local/etc/rc.d/wifi.sh

Solution 2:

This time we will use crontab instead of rc.d, move wifi.sh to /root/ directory.

root@iphone:~ # crontab -e

and add following entry:

@reboot /root/wifi.sh

Now a reminder dont try to edit crontab with a text editor such as

root@iphone:~ # vim /etc/crontab

That is Freebsds global crontab file and format is different

Restart you bsd box and enjoy wifi connection with dhcp

Static IP

We will keep eveything same as dhcp configuration but edit 3 files /etc/rc.conf, /etc/resolv.conf and wifi.sh

in /etc/rc.conf change this line:

ifconfig_wlan0="WPA SYNCDHCP"

with this one:

ifconfig_wlan0="WPA inet 192.168.11.11 netmask 255.255.255.0"
defaultrouter="192.168.11.1"

Add below line to /etc/resolv.conf

nameserver 8.8.8.8

Add below line to wifi.sh file

service routing restart

Basically we change dhcp configuration with our static ip, add a name server since we are not using dhcp and restart routing service

One last tip if you gonna use window manager you might want to install wifimgr a GUI-based tool to manage WiFi network configuration.

root@iphone:~ # pkg install wifimgr

 

Tmux Usage

September 8, 2020 Leave a comment

[root@m ~]#  tmux show-options -g

Change options in run time

[root@m ~]# tmux set-option status-bg blue

[root@m ~]# tmux set-option status-fg white

[root@m ~]# tmux set-option pane-active-border-fg blue

In Tmux Session

Add Panel:

Ctrl + b then ” (add panel horizontal)

Ctrl + b then % (add panel vertical)

Remove Panel:

type exit or press ctrl + d to close panel

Move through panels:

Ctrl +b then ⬆ ⬇ ⬅ ➡

Change Panel Size:

Ctrl + b then press :

in the status bar (bottom of screen)  type

resize-pane -L (can be L,R,U,D) 2 (unit for resize, can be any number)

or

Ctrl + b then Alt + ⬆ ⬇ ⬅ ➡

Detach – Attach Session:

Ctrl + b then press :

type detach

[root@m ~]# tmux attach