mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 01:26:11 -08:00
📚Docs
This commit is contained in:
150
docs/SUBNETS.md
150
docs/SUBNETS.md
@@ -1,108 +1,112 @@
|
|||||||
# Subnets configuration
|
# Subnets Configuration
|
||||||
|
|
||||||
You need to specify the network interface and the network mask. You can also configure multiple subnets and specify VLANS (see exceptions below).
|
You need to specify the network interface and the network mask. You can also configure multiple subnets and specify VLANs (see VLAN exceptions below).
|
||||||
|
|
||||||
> [!TIP]
|
`ARPSCAN` can scan multiple networks if the network allows it. To scan networks directly, the subnets must be accessible from the network where NetAlertX is running. You can verify this by running the following command in the container:
|
||||||
> You may need to increase the time between scans `ARPSCAN_RUN_SCHD` and the timeout `ARPSCAN_RUN_TIMEOUT` (and similar setting on related plugins) when adding more subnets. If the timeout setting is exceeded, the scan is cancelled to prevent application hanging from rogue plugins. Check [debugging plugins](/docs/DEBUG_PLUGINS.md) for more tips.
|
|
||||||
|
|
||||||
## Examples
|
`sudo arp-scan --interface=eth0 192.168.1.0/24`
|
||||||
|
|
||||||
|
In this example, `--interface=eth0 192.168.1.0/24` represents a neighboring subnet. If this command returns no results, the network is not accessible due to your network or firewall restrictions.
|
||||||
|
|
||||||
|
If direct scans are not possible, you can use [supplementing plugins](https://github.com/jokob-sk/NetAlertX/blob/main/front/plugins/README.md) that use alternate methods. Protocols used by the `SNMPDSC` or `DHCPLSS` plugins have good support and usually can be used as a workaround.
|
||||||
|
|
||||||
|
Alternatively, you can set up separate NetAlertX instances running on the subnets and synchronize the results into one instance with the [`SYNC` plugin](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins/sync).
|
||||||
|
|
||||||
|
> [!TIP]
|
||||||
|
> You may need to increase the time between scans `ARPSCAN_RUN_SCHD` and the timeout `ARPSCAN_RUN_TIMEOUT` (and similar settings for related plugins) when adding more subnets. If the timeout setting is exceeded, the scan is canceled to prevent the application from hanging due to rogue plugins.
|
||||||
|
> Check [debugging plugins](/docs/DEBUG_PLUGINS.md) for more tips.
|
||||||
|
|
||||||
|
## Example Values
|
||||||
|
|
||||||
> [!NOTE]
|
> [!NOTE]
|
||||||
> Please use the UI to configure settings as that ensures that the config file is in the correct format. Edit `app.conf` directly only when really necessary.
|
> Please use the UI to configure settings as it ensures the config file is in the correct format. Edit `app.conf` directly only when really necessary.
|
||||||
> 
|
> 
|
||||||
|
|
||||||
* Examples for one and two subnets (❗ Note the `['...','...']` format):
|
* **Examples for one and two subnets:**
|
||||||
* One subnet: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
|
* One subnet: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0']`
|
||||||
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0','192.168.1.0/24 --interface=eth1 -vlan=107']`
|
* Two subnets: `SCAN_SUBNETS = ['192.168.1.0/24 --interface=eth0','192.168.1.0/24 --interface=eth1 -vlan=107']`
|
||||||
|
|
||||||
If you get timeout messages, decrease the network mask (e.g.: from a `/16` to `/24`) or increase the `TIMEOUT` setting (e.g.: `ARPSCAN_RUN_TIMEOUT` to `300` (a timeout of 5min)) for the plugin and the interval between scans (e.g.: `ARPSCAN_RUN_SCHD` to `*/10 * * * *` (scans every 10 min)).
|
If you get timeout messages, decrease the network mask (e.g.: from `/16` to `/24`) or increase the `TIMEOUT` setting (e.g.: `ARPSCAN_RUN_TIMEOUT` to `300` (5-minute timeout)) for the plugin and the interval between scans (e.g.: `ARPSCAN_RUN_SCHD` to `*/10 * * * *` (scans every 10 minutes)).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## Explanation
|
## Explanation
|
||||||
|
|
||||||
### Network mask
|
### Network Mask
|
||||||
|
|
||||||
**Example value: `192.168.1.0/24`**
|
**Example value:** `192.168.1.0/24`
|
||||||
|
|
||||||
The arp-scan time itself depends on the number of IP addresses to check.
|
The `arp-scan` time itself depends on the number of IP addresses to check.
|
||||||
|
|
||||||
> The number of IPs to check depends on the [network mask](https://www.calculator.net/ip-subnet-calculator.html) you set on the `SCAN_SUBNETS` setting.
|
> The number of IPs to check depends on the [network mask](https://www.calculator.net/ip-subnet-calculator.html) you set in the `SCAN_SUBNETS` setting.
|
||||||
> For example, a `/24` mask results in 256 IPs to check, whereas a `/16` mask checks around 65,536. Every IP takes a couple of seconds. This means that with an incorrect configuration, the arp-scan will take hours to complete instead of seconds.
|
> For example, a `/24` mask results in 256 IPs to check, whereas a `/16` mask checks around 65,536 IPs. Each IP takes a couple of seconds, so an incorrect configuration could make `arp-scan` take hours instead of seconds.
|
||||||
|
|
||||||
Specify the network filter (which **significantly** speeds up the scan process). For example, the filter `192.168.1.0/24` covers IP ranges `192.168.1.0` to `192.168.1.255`.
|
Specify the network filter, which **significantly** speeds up the scan process. For example, the filter `192.168.1.0/24` covers IP ranges from `192.168.1.0` to `192.168.1.255`.
|
||||||
|
|
||||||
### Network interface (adapter)
|
### Network Interface (Adapter)
|
||||||
|
|
||||||
**Example value: `--interface=eth0`**
|
**Example value:** `--interface=eth0`
|
||||||
|
|
||||||
The adapter will probably be `eth0` or `eth1`. (Check `System info` > `Network Hardware` or run `iwconfig` in the container to find your interface name(s))
|
The adapter will probably be `eth0` or `eth1`. (Check `System Info` > `Network Hardware` or run `iwconfig` in the container to find your interface name(s)).
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Alterantive to `iwconfig` run `ip -o link show | awk -F': ' '!/lo|vir|docker/ {print $2}'` in your container to find your interface name(s) (e.g.: `eth0`, `eth1`).
|
> As an alternative to `iwconfig`, run `ip -o link show | awk -F': ' '!/lo|vir|docker/ {print $2}'` in your container to find your interface name(s) (e.g.: `eth0`, `eth1`).
|
||||||
|
|
||||||
### VLANs
|
### VLANs
|
||||||
|
|
||||||
**Example value: `-vlan=107`**
|
**Example value:** `-vlan=107`
|
||||||
|
|
||||||
- Append e.g.: ` -vlan=107` to the interface field (e.g.: `eth0 -vlan=107`) for multiple vlans. More details in this [comment in this issue](https://github.com/jokob-sk/NetAlertX/issues/170#issuecomment-1419902988)
|
- Append `-vlan=107` to the interface field (e.g.: `eth0 -vlan=107`) for multiple VLANs. More details are available in this [comment](https://github.com/jokob-sk/NetAlertX/issues/170#issuecomment-1419902988).
|
||||||
|
|
||||||
|
#### VLANs on a Hyper-V Setup
|
||||||
|
|
||||||
|
> Community-sourced content by [mscreations](https://github.com/mscreations) from this [discussion](https://github.com/jokob-sk/NetAlertX/discussions/404).
|
||||||
|
|
||||||
|
**Tested Setup:** Bare Metal → Hyper-V on Win Server 2019 → Ubuntu 22.04 VM → Docker → NetAlertX.
|
||||||
|
|
||||||
|
**Approach 1 (may cause issues):**
|
||||||
|
Configure multiple network adapters in Hyper-V with distinct VLANs connected to each one using Hyper-V's network setup. However, this action can potentially lead to the Docker host's inability to handle network traffic correctly. This might interfere with other applications such as Authentik.
|
||||||
|
|
||||||
|
**Approach 2 (working example):**
|
||||||
|
|
||||||
|
Network connections to switches are configured as trunk and allow all VLANs access to the server.
|
||||||
|
|
||||||
|
By default, Hyper-V only allows untagged packets through to the VM interface, blocking VLAN-tagged packets. To fix this, follow these steps:
|
||||||
|
|
||||||
|
1. Run the following command in PowerShell on the Hyper-V machine:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
Set-VMNetworkAdapterVlan -VMName <Docker VM Name> -Trunk -NativeVlanId 0 -AllowedVlanIdList "<comma separated list of vlans>"
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
#### VLANs on a Hyper-V setup
|
2. Within the VM, set up sub-interfaces for each VLAN to enable scanning. On Ubuntu 22.04, Netplan can be used. In /etc/netplan/00-installer-config.yaml, add VLAN definitions:
|
||||||
|
|
||||||
> Community sourced content by [mscreations](https://github.com/mscreations) from this [discussion](https://github.com/jokob-sk/NetAlertX/discussions/404).
|
```yaml
|
||||||
|
|
||||||
> [!NOTE]
|
network:
|
||||||
> The setup this was tested on: Bare Metal -> Hyper-V on Win Server 2019 -> Ubuntu 22.04 VM -> Docker -> NetAlertX.
|
ethernets:
|
||||||
|
eth0:
|
||||||
|
dhcp4: yes
|
||||||
|
vlans:
|
||||||
|
eth0.2:
|
||||||
|
id: 2
|
||||||
|
link: eth0
|
||||||
|
addresses: [ "192.168.2.2/24" ]
|
||||||
|
routes:
|
||||||
|
- to: 192.168.2.0/24
|
||||||
|
via: 192.168.1.1
|
||||||
|
```
|
||||||
|
|
||||||
**Approach 1 (may cause issues):**
|
3. Run `sudo netplan apply` to activate the interfaces for scanning in NetAlertX.
|
||||||
|
|
||||||
Configure multiple network adapters in Hyper-V with distinct VLANs connected to each one using Hyper-V's network setup. However, this action can potentially lead to the Docker host's inability to handle network traffic correctly. The issue may stem from the creation of routes for network time servers or domain controllers on every interface, thereby preventing proper synchronization of the underlying Ubuntu VM. This interference can affect the performance of other applications such as Authentik.
|
In this case, use `192.168.2.0/24 --interface=eth0.2` in NetAlertX.
|
||||||
|
|
||||||
**Approach 2 (working example)**
|
#### VLAN Support & Exceptions
|
||||||
|
|
||||||
Network connections to switches are configured as trunk and allow all VLANs access to the server.
|
Please note the accessibility of macvlans when configured on the same computer. This is a general networking behavior, but feel free to clarify via a PR/issue.
|
||||||
|
|
||||||
By default Hyper-V only allows untagged packets through to the VM interface and no VLAN tagged packets get through. In order to fix this follow these steps:
|
|
||||||
|
|
||||||
1) Run the following command in Powershell on the Hyper-V machine:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
Set-VMNetworkAdapterVlan -VMName <Docker VM Name> -Trunk -NativeVlanId 0 -AllowedVlanIdList "<comma separated list of vlans>"
|
|
||||||
```
|
|
||||||
|
|
||||||
(There might be other ways how adjust this.)
|
|
||||||
|
|
||||||
2) Within the VM, set up sub-interfaces for each of the VLANs so they can be scanned. On Ubuntu 22.04 Netplan can be used.
|
|
||||||
|
|
||||||
In /etc/netplan/00-installer-config.yaml, add vlan definitions:
|
|
||||||
|
|
||||||
```
|
|
||||||
network:
|
|
||||||
ethernets:
|
|
||||||
eth0:
|
|
||||||
dhcp4: yes
|
|
||||||
vlans:
|
|
||||||
eth0.2:
|
|
||||||
id: 2
|
|
||||||
link: eth0
|
|
||||||
addresses: [ "192.168.2.2/24" ]
|
|
||||||
routes:
|
|
||||||
- to: 192.168.2.0/24
|
|
||||||
via: 192.168.1.1
|
|
||||||
```
|
|
||||||
|
|
||||||
3) Run `sudo netplan apply` and the interfaces are then available to scan in NetAlertX.
|
|
||||||
4) In this case, use `192.168.2.0/24 --interface=eth0.2` in NetAlertX
|
|
||||||
|
|
||||||
#### VLAN 🔍Example:
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
#### Support for VLANS (& exceptions)
|
|
||||||
|
|
||||||
Please note the accessibility of the macvlans when they are configured on the same computer. My understanding this is a general networking behavior, but feel free to clarify via a PR/issue.
|
|
||||||
|
|
||||||
- NetAlertX does not detect the macvlan container when it is running on the same computer.
|
- NetAlertX does not detect the macvlan container when it is running on the same computer.
|
||||||
- NetAlertX recognizes the macvlan container when it is running on a different computer.
|
- NetAlertX recognizes the macvlan container when it is running on a different computer.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user