LINUX – Network Manager – How to get network adapter information

Here is short info how to get network adapter info for systems with network manager:
nmcli dev list iface wlan0

example output:

GENERAL.DEVICE:                         wlan0
GENERAL.TYPE:                           802-11-wireless
GENERAL.VENDOR:                         Broadcom Corporation
GENERAL.PRODUCT:                        BCM4313 802.11b/g/n Wireless LAN Controller
GENERAL.DRIVER:                         brcmsmac
GENERAL.DRIVER-VERSION:                 3.16.0-38-generic
GENERAL.FIRMWARE-VERSION:               N/A
GENERAL.HWADDR:                         00:26:82:9e:AF:11
GENERAL.STATE:                          100 (connected)
GENERAL.REASON:                         0 (No reason given)
GENERAL.UDI:                            /sys/devices/pci0000:00/0000:00:1c.3/0000:44:00.0/bcma0:0/net/wlan0
GENERAL.IP-IFACE:                       wlan0
GENERAL.NM-MANAGED:                     yes
GENERAL.AUTOCONNECT:                    yes
GENERAL.FIRMWARE-MISSING:               no
GENERAL.CONNECTION:                     /org/freedesktop/NetworkManager/ActiveConnection/0
CAPABILITIES.CARRIER-DETECT:            no
CAPABILITIES.SPEED:                     65 Mb/s
CONNECTIONS.AVAILABLE-CONNECTION-PATHS: /org/freedesktop/NetworkManager/Settings/{1}
CONNECTIONS.AVAILABLE-CONNECTIONS[1]:   26d879c4-0d6f-4000-bf02-43c687416e1e | Auto IntoTheWild
WIFI-PROPERTIES.WEP:                    yes
WIFI-PROPERTIES.WPA:                    yes
WIFI-PROPERTIES.WPA2:                   yes
WIFI-PROPERTIES.TKIP:                   yes
WIFI-PROPERTIES.CCMP:                   yes
WIFI-PROPERTIES.AP:                     yes
WIFI-PROPERTIES.ADHOC:                  yes
AP[1].SSID:                             'WiFI-NamE'
AP[1].BSSID:                            CC:AB:BB:12:33:33
AP[1].MODE:                             Infrastructure
AP[1].FREQ:                             2412 MHz
AP[1].RATE:                             54 MB/s
AP[1].SIGNAL:                           37
AP[1].SECURITY:                         WPA WPA2
AP[1].ACTIVE:                           no
AP[2].SSID:                             'AnothErWiFi'
AP[2].BSSID:                            34:3E:1F:33:E2:33
AP[2].MODE:                             Infrastructure
AP[2].FREQ:                             2437 MHz
AP[2].RATE:                             54 MB/s
AP[2].SIGNAL:                           52
AP[2].SECURITY:                         WPA2
AP[2].ACTIVE:                           yes
IP4.ADDRESS[1]:                         ip = 10.0.1.99/24, gw = 192.168.1.254
IP4.DNS[1]:                             10.0.1.60
IP4.DOMAIN[1]:                          home
DHCP4.OPTION[1]:                        domain_name = home
DHCP4.OPTION[2]:                        expiry = 1451147274
DHCP4.OPTION[3]:                        broadcast_address = 10.0.1.255
DHCP4.OPTION[4]:                        dhcp_message_type = 5
DHCP4.OPTION[5]:                        dhcp_lease_time = 604800
DHCP4.OPTION[6]:                        ip_address = 10.0.1.99
DHCP4.OPTION[7]:                        routers = 10.0.1.254
DHCP4.OPTION[8]:                        subnet_mask = 255.255.255.0
DHCP4.OPTION[9]:                        domain_name_servers = 10.0.1.60
DHCP4.OPTION[10]:                       network_number = 10.0.1.0
DHCP4.OPTION[11]:                       dhcp_server_identifier = 10.0.1.60

LINUX – IP aliasing

To quote mighty Wikipedia: “IP aliasing is associating more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose”

Debian, Ubuntu

To perform IP aliasing in Debian based system (assuming you’re using eth0), edit /etc/network/interfaces as follows:

auto eth0:1
iface eth0:1 inet static
address 10.0.0.10
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1

auto eth0:2
iface eth0:2 inet static
address 10.0.0.11
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1

In the above example we create two virtual NICs out of eth0: eth0:1 10.0.0.10) and eth0:2 (10.0.0.11).

CentOS, RHEL, Fedora and similar

In CentOS, rename /etc/sysconfig/network-scripts/ifcfg-enp0s3 as ifcfg-enp0s3:1 and make a copy as ifcfg-enp0s3:2, and then just change the following lines, respectively:

DEVICE="enp0s3:1"
IPADDR=10.0.0.10

and

DEVICE="enp0s3:2"
IPADDR=10.0.0.11

Once done, restart the network service:

systemctl restart networking

Install LibreOffice 5.0 in Linux Mint via PPA

To be able to update LibreOffice to version 5.0 via PPA, you need to create a file called “libreoffice-libreoffice-5-0.pref” under /etc/apt/preferences.d/ – to do this automatically, use the following command:

nano /etc/apt/preferences.d/libreoffice-libreoffice-5-0.pref

and in this file, paste this:

Package: *
Pin: release o=LP-PPA-libreoffice-libreoffice-5-0
Pin-Priority: 701

than

sudo add-apt-repository ppa:libreoffice/libreoffice-5-0
sudo apt-get update
sudo apt-get dist-upgrade

Lastly start Mint Software Manager and install LibreOffice

Debian – setting up iptables

Iptables is installed by default on many modern linux distros.

A good starting point is to list the current rules that are configured for iptables. It is done with the -L flag:

sudo iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

 

Setting it up

I am going to start with the rule that explicitly accepts current SSH connection:

sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

then I will allow SSH

sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT

 

meaning of the options:

-A INPUT: The -A flag appends a rule to the end of a chain. This is the portion of the command that tells iptables that we wish to add a new rule, that we want that rule added to the end of the chain, and that the chain we want to operate on is the INPUT chain

-p tcp: This option matches packets if the protocol being used is TCP. This is a connection-based protocol that will be used by most applications because it allows for reliable communication.

–dport: This option is available if the -p tcp flag is given. It gives a further requirement of matching the destination port for the matching packet. The first rule matches for TCP packets destined for port 22, while the second rule matches TCP traffic pointed towards port 80.

-j ACCEPT: This specifies the target of matching packets. Here, we tell iptables that packets that match the preceding criteria should be accepted and allowed through.

 

There is one more accept rule that we need to ensure that our server can function correctly. Often, services on the computer communicate with each other by sending network packets to each other. They do this by utilizing a pseudo network interface called the loopback device, which directs traffic back to itself rather than to other computers:

sudo iptables -I INPUT 1 -i lo -j ACCEPT

-I INPUT 1: The -I flag tells iptables to insert a rule. This is different than the -A flag which appends a rule to the end. The -I flag takes a chain and the rule position where you want to insert the new rule.

To see my current rules, I use the -S flag. This is because the -L flag doesn’t include some information, like the interface that a rule is tied to:
sudo iptables -S

-P INPUT ACCEPT
 -P FORWARD ACCEPT
 -P OUTPUT ACCEPT
 -A INPUT -i lo -j ACCEPT
 -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
 -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT

With my current setup the firewall isn’t actually blocking anything so one last thing to implement is the Drop Rule:
sudo iptables -P INPUT DROP

This will catch any packets that fall through our INPUT chain, and drop them. This is what we call a default drop policy.

In case I need to add more rules:

iptables -L --line-numbers

that will give you output listing line numbers – so if for example I have 20 existing rules and I want to add this rule at the end I would type:

iptables -I INPUT 21 ...........

for example:

iptables -I INPUT 21 -p tcp -m tcp --dport 25 -j ACCEPT

Saving it all

 

To keep the config we need to save it. First install the bits we will need:

apt-get install iptables-persistent

that will install and setup iptables-persistent service

the iptables config will be saved to:

/etc/iptables/rules.v4

the command to save the config is:

iptables-save > /etc/iptables/rules.v4

 

Job Done

Quad Core UDOO – Debian – compiling kernel 4.0.8

U-Boot 2015 http://www.igorpecovnik.com/2015/02/20/udoo-quad-debian-sd-image/

Download the software:

wget http://mirror.igorpecovnik.com/kernel/4.0.8-udoo-next.tar

extract it and only install the u-boot package:

dpkg -i linux-u-boot-4.0.8-udoo_1.8_armhf.deb

 

Kernel based on https://github.com/patrykk/linux-udoo

Install prerequisites:

apt-get install lzop kernel-package u-boot-tools dblatex docbook-utils \
 kernel-common libsgmls-perl libsp1c2 libtinfo-dev sgmlspl sp texlive \
 texlive-bibtex-extra texlive-math-extra xmlto xsltproc libncurses5-dev

Getting the kernel:

cd /tmp
mkdir kernel4.0.8
cd kernel4.0.8
wget https://github.com/patrykk/linux-udoo/archive/4.0.8.zip
unzip 4.0.8.zip

now change directory to the kernel folder and configure it:

make menuconfig

compile it – in my case it took approx 2 hours:

make uImage LOADADDR=0x10008000  modules

install the modules:

make modules_install

copy the kernel to /boot folder

cp arch/arm/boot/uImage /boot/
 cp arch/arm/boot/zImage /boot/

compile the dtb file:

make imx6q-udoo.dtb

copy dtb file
cp arch/arm/boot/dts/imx6q-udoo.dtb /boot/dts/
copy firmware
cp firmware/imx/sdma/sdma-imx6q.bin /lib/firmware/sdma/
configure your uboot
nano /boot/boot.cmd
then copy and paste this
setenv bootargs root=/dev/mmcblk0p1 rootfstype=ext4 rootwait console=ttymxc1,115200
ext2load mmc 0 0x18000000 /boot/dtb/imx6q-udoo.dtb
ext2load mmc 0 0x12000000 /boot/zImage
bootz 0x12000000 - 0x18000000

if you use graphical interface you will probably want to replace the first line with:

setenv bootargs root=/dev/mmcblk0p1 rootfstype=ext4 rootwait console=tty1 video=mxcfb0:dev=hdmi,1920x1080M@60,if=RGB24,bpp=32 ahci_imx.hotplug=1 quiet

then convert it to uboot format
mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr

Now cross fingers, connect console cable and restart the device

 

U-Boot 2015.04-dirty (Jul 13 2015 - 12:27:45)
CPU:   Freescale i.MX6Q rev1.2 at 792 MHz
 Reset cause: WDOG
 Board: Udoo
 DRAM:  1 GiB
 MMC:   FSL_SDHC: 0
 *** Warning - bad CRC, using default environment
In:    serial
 Out:   serial
 Err:   serial
 Net:   using phy at 6
 FEC [PRIME]
 Hit any key to stop autoboot:  0
 switch to partitions #0, OK
 mmc0 is current device
 295 bytes read in 63 ms (3.9 KiB/s)
 Running bootscript from mmc ...
 ## Executing script at 12000000
 35681 bytes read in 138 ms (252 KiB/s)
 6491688 bytes read in 374 ms (16.6 MiB/s)
 Kernel image @ 0x12000000 [ 0x000000 - 0x630e28 ]
 ## Flattened Device Tree blob at 18000000
 Booting using the fdt blob at 0x18000000
 Using Device Tree in place at 18000000, end 1800bb60
Starting kernel ...
Booting Linux on physical CPU 0x0
 Linux version 4.0.8 (root@UDOO) (gcc version 4.9.2 (Debian 4.9.2-10) ) #3 SMP Fri
 Jul 31 19:05:40 BST 2015
 CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c5387d
 CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
 Machine model: Udoo i.MX6 Quad Board
 cma: Reserved 256 MiB at 0x40000000
 Memory policy: Data cache writealloc
 PERCPU: Embedded 11 pages/cpu @af731000 s12480 r8192 d24384 u45056
 Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 260096
 Kernel command line: root=/dev/mmcblk0p1 rootfstype=ext4 rootwait console=ttymxc
 1,115200 ahci_imx.hotplug=1
 PID hash table entries: 4096 (order: 2, 16384 bytes)
 Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
 Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
 Memory: 764764K/1048576K available (8251K kernel code, 298K rwdata, 2472K rodata
 , 352K init, 440K bss, 21668K reserved, 262144K cma-reserved, 0K highmem)
 Virtual kernel memory layout:
 vector  : 0xffff0000 - 0xffff1000   (   4 kB)
 fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
 vmalloc : 0xc0800000 - 0xff000000   (1000 MB)
 lowmem  : 0x80000000 - 0xc0000000   (1024 MB)
 pkmap   : 0x7fe00000 - 0x80000000   (   2 MB)
 modules : 0x7f000000 - 0x7fe00000   (  14 MB)
 .text : 0x80008000 - 0x80a811a8   (10725 kB)
 .init : 0x80a82000 - 0x80ada000   ( 352 kB)
 .data : 0x80ada000 - 0x80b24860   ( 299 kB)
 .bss : 0x80b24860 - 0x80b92b48   ( 441 kB)
 SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
 Hierarchical RCU implementation.
 NR_IRQS:16 nr_irqs:16 16
 L2C-310 erratum 769419 enabled
 L2C-310 enabling early BRESP for Cortex-A9
 L2C-310 full line of zeros enabled for Cortex-A9
 L2C-310 ID prefetch enabled, offset 1 lines
 L2C-310 dynamic clock gating enabled, standby mode enabled
 L2C-310 cache controller enabled, 16 ways, 1024 kB
 L2C-310: CACHE_ID 0x410000c7, AUX_CTRL 0x76070001
 VPU 352M is enabled!
 Switching to timer-based delay loop, resolution 333ns
 sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655765682ns
 Console: colour dummy device 80x30
 Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00
 BogoMIPS (lpj=30000)
 pid_max: default: 32768 minimum: 301
 Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
 Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
 Initializing cgroup subsys net_cls
 CPU: Testing write buffer coherency: ok
 CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
 Setting up static identity map for 0x107da3e8 - 0x107da440
 CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
 CPU2: thread -1, cpu 2, socket 0, mpidr 80000002
 CPU3: thread -1, cpu 3, socket 0, mpidr 80000003
 Brought up 4 CPUs
 SMP: Total of 4 processors activated (24.00 BogoMIPS).
 CPU: All CPU(s) started in SVC mode.
[......]

 

Job Done.