I migrated from Nagios running on BeagleBoneBlack to NEMS on Pi4.
I am now using :
NEMS Platform: Raspberry Pi 4
NEMS Version Running: 1.5.1
On BBB, I was using eth0 which was configured as a trunk port with a native VLAN (192.168.1.0/24) and an additional VLAN (192.168.3.0/24) where other devices need to be monitored.
Basically, I have a switch with two VLAN, and using a trunk port (with the two vlans) on the switch to feed eth0 on Nagios.
The setting was similar to the following :
+++
1)
# First install vlan package
apt-get install vlan
2)
# Second modify network interfaces to add vlan on eth0
cat /etc/network/interfaces
### Native VLAN which is subnet 192.168.1.0/24
### Set static IP 192.168.1.6 for eth0
auto eth0
iface eth0 inet static
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.1
### Add VLAN which is subnet 192.168.3.0/24
### Set static IP 192.168.3.6 for sub-interface eth0.3
### Add a route to reach subnet 192.168.3.0/24 when interface come up
### Delete route to reach subnet 192.168.3.0/24 when interface go down
auto eth0.3
iface eth0.3 inet static
address 192.168.3.6
netmask 255.255.255.0
gateway 192.168.3.1
post-up ip route add 192.168.3.0/24 via 192.168.3.1 dev eth0.3
down ip route del 192.168.3.0/24 dev eth0.3
3)
# Third Modify IPTABLES to accept connection from the network 192.168.3.0/24
cat /etc/iptables/rules.v4
###
-A INPUT -i eth0.3 -p udp -m udp --dport 67 -j DROP
-A INPUT -i eth0.3 -j ACCEPT
###
+++
I would like to do the same thing on NEMS but haven't found any documentation to achieve this. The only thing I saw was a reference to cockpit, but at a very high level. Any help would be appreciated.
Setting eth0 as a Trunk port with VLAN
Setting eth0 as a Trunk port with VLAN
Last edited by stherien on Sat Feb 08, 2020 11:36 am, edited 1 time in total.
RE: Setting eth0 as a Trunk port with VLAN
For those interested in the solution, here are the steps to configure an interface in trunk mode on NEMS.
#First install vlan package
sudo apt-get install vlan
#Second be sure not to lock yourself out. All the steps were made using ssh connection. Verify that wifi is activated.
sudo nmcli radio wifi
#Then list wifi SSID
sudo nmcli device wifi list
#And connect to your SSID and be prompted for Wifi password
sudo nmcli device wifi connect YOUR_SSID -ask
#Now verify that wifi network is up
sudo nmcli connection show
#If you want Fix IP address do the command below, otherwise, wifi connection will be DHCP
sudo nmcli con add type wifi con-name YOUR-SSID dev wlan0 ip4 192.168.11.67/24 gw4 192.168.11.1
#Reconnect using ssh to the Wifi network and continue with the following commands.
#Set VLAN 1 on sub-interface of eth0
sudo nmcli con add type vlan con-name VLAN1 dev eth0 id 1 ip4 192.168.1.6/24 gw4 192.168.1.1
#Verify connection for VLAN1
sudo sudo nmcli connection show VLAN1
#Set VLAN 3 on sub-interface of eth0
sudo nmcli con add type vlan con-name VLAN3 dev eth0 id 3 ip4 192.168.3.6/24 gw4 192.168.3.1
#Verify connection for VLAN3
sudo sudo nmcli connection show VLAN3
#disconnect eth0 so only sub-interfaces eth0.1 & eth0.3 are active
sudo sudo nmcli device disconnect eth0
#Now verify show network connection for eth0
sudo nmcli connection show
+++ OUTPUT WILL BE AS BELOW +++
NAME UUID TYPE DEVICE
YOUR_SSID 94dfd6d4-4251-4991-b4c1-e8f2b0d57452 wifi wlan0
VLAN11 585694ff-e96c-43fe-b7a7-42149184807e vlan eth0.1
VLAN13 df0bcaf6-ae13-42f9-b6db-f02cb0cfac64 vlan eth0.13
Wired connection 2 4c392595-78bb-30a6-9e23-ba7639a0c991 ethernet eth0
+++
#Now edit eth0 by specifying UUID and disable autoconnect, so at next reboot eth0 will still be inactive
sudo nmcli con edit 4c392595-78bb-30a6-9e23-ba7639a0c991
nmcli>
set connection.autoconnect no
save
quit
#Verivy that eth0 is set to autoconnect no
sudo nmcli con show 4c392595-78bb-30a6-9e23-ba7639a0c991
You should see in the output a line like below:
connection.autoconnect: no
#Verify that eth0 is really not set to autoconnect
sudo nmcli -f name,autoconnect c s
+++ OUTPUT WILL BE AS BELOW +++
NAME AUTOCONNECT
YOUR_SSID yes
VLAN11 yes
VLAN13 yes
Wired connection 2 no
+++
That's it, you now have eth0 configured with two sub-interfaces and a VLAN on each of them.
Hope this can help someone with similar requirements.
#First install vlan package
sudo apt-get install vlan
#Second be sure not to lock yourself out. All the steps were made using ssh connection. Verify that wifi is activated.
sudo nmcli radio wifi
#Then list wifi SSID
sudo nmcli device wifi list
#And connect to your SSID and be prompted for Wifi password
sudo nmcli device wifi connect YOUR_SSID -ask
#Now verify that wifi network is up
sudo nmcli connection show
#If you want Fix IP address do the command below, otherwise, wifi connection will be DHCP
sudo nmcli con add type wifi con-name YOUR-SSID dev wlan0 ip4 192.168.11.67/24 gw4 192.168.11.1
#Reconnect using ssh to the Wifi network and continue with the following commands.
#Set VLAN 1 on sub-interface of eth0
sudo nmcli con add type vlan con-name VLAN1 dev eth0 id 1 ip4 192.168.1.6/24 gw4 192.168.1.1
#Verify connection for VLAN1
sudo sudo nmcli connection show VLAN1
#Set VLAN 3 on sub-interface of eth0
sudo nmcli con add type vlan con-name VLAN3 dev eth0 id 3 ip4 192.168.3.6/24 gw4 192.168.3.1
#Verify connection for VLAN3
sudo sudo nmcli connection show VLAN3
#disconnect eth0 so only sub-interfaces eth0.1 & eth0.3 are active
sudo sudo nmcli device disconnect eth0
#Now verify show network connection for eth0
sudo nmcli connection show
+++ OUTPUT WILL BE AS BELOW +++
NAME UUID TYPE DEVICE
YOUR_SSID 94dfd6d4-4251-4991-b4c1-e8f2b0d57452 wifi wlan0
VLAN11 585694ff-e96c-43fe-b7a7-42149184807e vlan eth0.1
VLAN13 df0bcaf6-ae13-42f9-b6db-f02cb0cfac64 vlan eth0.13
Wired connection 2 4c392595-78bb-30a6-9e23-ba7639a0c991 ethernet eth0
+++
#Now edit eth0 by specifying UUID and disable autoconnect, so at next reboot eth0 will still be inactive
sudo nmcli con edit 4c392595-78bb-30a6-9e23-ba7639a0c991
nmcli>
set connection.autoconnect no
save
quit
#Verivy that eth0 is set to autoconnect no
sudo nmcli con show 4c392595-78bb-30a6-9e23-ba7639a0c991
You should see in the output a line like below:
connection.autoconnect: no
#Verify that eth0 is really not set to autoconnect
sudo nmcli -f name,autoconnect c s
+++ OUTPUT WILL BE AS BELOW +++
NAME AUTOCONNECT
YOUR_SSID yes
VLAN11 yes
VLAN13 yes
Wired connection 2 no
+++
That's it, you now have eth0 configured with two sub-interfaces and a VLAN on each of them.
Hope this can help someone with similar requirements.