Not knowing your system, I would say you created the VLAN attached to the wireless interface as a parent device and not to cabled interface, as it should.
How to use nmcli in terminal, to add and delete devices, you can consult the manual:
OK but i dont know how i must create as you write me…
I want use this wificard WLP2S0 to connect it to wifi VLAN1 where is Samsung TV. But i can no create connection without defined GATEWAY. Home Assistant can not do it.
but if i connect next interface LAN RJ45 by USB to my HP Terminal i can configure it with this command line ? And whet command type to configure it withou gateway as you write me ?
And i see that i must set gateway ? But you write that no set gawteway…
(I will at some point review the tutorial to update it)
Why would you want to add a third interface? Like I told you before, stick to cable rj45 whenever possible.
If nmcli does not allow you to create an interface without a gateway, just make sure that the default gateway is the one interface you want, in your case, that would be enp1s0, as far as I could see from your screenshot.
You can do the following to any other interface (I use in the example your new vlan1 created in the cabled interface enp1s0.1, using nmcli
#nmcli con add type vlan con-name enp1s0@vlan1 dev enp1s0 id 1 ip4 192.168.4.x/24 ipv4.dns 192.168.4.1 gw4 192.168.4.1
#nmcli con modify enp1s0@vlan1 ipv4.never-default yes
This is a more up-to-date version of this tutorial, taking into account that HA has changed a little bit. Starting from version 11, the UI already supports VLAN configuration in the menu Settings > System > Network, so these old tutorials will only be left here available, to others looking for different options.
VLAN in HA:
Install and configure (according to documentation) the “Home Assistant Community Add-on: SSH & Web Terminal” add-on in System > Add-ons
Open the terminal and confirm you are the root user
~ whoami
root
From here you will use the nmcli configuration tool. #nmcli connection show will list the connections available, its UUIDs, types and devices.
Create the VLAN interface with a static address choosing whichever network physical interface (parent interface) you want the VLAN to traverse (in this example, we use eth0, but it might change depending on your setup), by defining the VLAN’s connection name, id, ip, gateway and dns (adjust the numbers to your network and needs), as in the example below:
#nmcli con add type vlan con-name eth0@vlan10 dev eth0 id 10 ip4 10.0.0.2/8 ipv4.dns 10.0.0.1 gw4 10.0.0.1
Let’s break down this last command:
“nmcli con add” - Add a new connection
“type vlan” - a vlan type interface
“con-name eth0@vlan10” - the name of the new VLAN interface
“dev eth0” - the parent device where the VLAN will attach
“id 10” - the vlan id number
“ip4 10.0.0.2/8” - ip and netmask of the VLAN interface
“ipv4.dns 10.0.0.1” - dns server of the VLAN interface
“gw4 10.0.0.1” - gateway of the VLAN interface
More information here:
and here:
Show connections again and it should list your new VLAN (fake uuids) #nmcli connection show
NAME UUID TYPE DEVICE
eth0 aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa ethernet eth0
eth0@vlan10 bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb vlan eth0.10
To see more detailed info about the connection #nmcli -p con show eth0@vlan10
To force all HA generated traffic through the “normal”/more private route and avoid some problems caused by having now two default gateways, there are three possible solutions:
a) first is that you can change/set the gateways’ priorities/metric values in each interface so that traffic first chooses the interface you want (by default, network manager sets ethernet as 100 and vlan as 400). If you use only tagged VLANs and remove the physical network interface ip configuration, it could be important to choose which VLAN carries default network traffic from HA. You can set priorities like this:
#nmcli con modify eth0@vlan10 ipv4.route-metric value
The lower the value, the higher will be the priority for the interface.
#nmcli con modify eth0@vlan1 ipv4.route-metric 400 #nmcli con modify eth0@vlan10 ipv4.route-metric 401
would give priority to vlan1 as a default gateway for internet access.
b) second is to disable/block default routing altogether in the unwanted device(s), so that each interface only uses its assigned network:
#nmcli con modify eth0@vlan10 ipv4.never-default yes
would disable default routing through this VLAN interface.
c) third option is to remove the gateway from the interface by setting the gateway as empty (note the empty value between the ticks):
#nmcli con mod eth0@vlan10 ipv4.gateway ''
More information here:
Repeat steps 4 to 7 to create additional VLANS, adjusting network settings
Now enter the nmcli editor to “edit” your connection #nmcli con edit eth0@vlan10
Just save the settings and properties and it should report a successful update to the connection #nmcli> save
To double-check settings of the vlan interface #nmcli> print ipv4
Quit the nmcli editor #nmcli> quit
(depending on the type of HA installation, your files might not be visible at all! That is ok, and you can proceed to 15, if nmcli is listing the connections.)
Check for the creation of a new file(s) with VLAN(s) definitions (there should be an eth0@vlan10 file and one for each new VLAN created) #ls -la /etc/NetworkManager/system-connections/
(optionally) Check the contents of the file (possible output below) #cat /etc/NetworkManager/system-connections/eth0@vlan10
Exit the session and reboot the HA host to test (after rebooting you can login to HA again like in 1st step and see if file with definitions still exists)
My terminal HP has LAN enp1s0 and WIFI wlp2s0. Now i have connected my terminal w Home Assistant by LAN (enp1s0) to VLAN 10(192.168.10.x)
How i can do this as you write to connecte VLAN 1 (192.168.4.x) where is connected Samsung TV ?
When LAN (enp1s0) i connect to VLAN 1 it was removed from VLAN 10. Yes ?
What you are saying is that you have VLAN10 as pvid (port default vlan id) set in Ubuquiti switch where HA cable connects to, right? So now you have to enable VLAN1 tagged to that same port, configure VLAN1 tagged in HA as per the tutorial and you should be able to reach 192.168.4.0 network directly from HA. Configuration of the Ubiquiti switch should be easy for you
Yes. VLANs are separate logical networks that can be configured to use the same physical interface and cable. In order for that separation to happen, you need to use tagging, so that the switch and network interfaces can recognize that these are different LANs (VLANS).
Each physical cable can carry one untagged VLAN (pvid) and multiple tagged VLANS (depending on switch capabilities).
You can set a pvid (in your case, I guess the default untagged VLAN in this switch port is 10) and then you can enable many other tagged VLANS that will travel through the same cable/interface.
I am not a network specialist, so maybe some reading could help you clear these concepts
Default on my Ubiquiti is VLAN1 and it is with Samsung. HA is in VLAN10.
On ubiquiti on port in switch i can setup ALL or select specied network VLAN.
In this i think that i must setup ALL.
In every managed switch (with vlan capabilities) there is a pvid for all ports that comes by default from factory. Usually this is vlan id 1. If your HA is on a different vlan (10) that means that you (or someone) had to create the vlan id 10 and change the pvid of that port where HA connects to 10 too. You’ll have to go to this same configuration and add vlan 1 as a tagged vlan in this port.
very very thanks. Now looks that works ok and communication betwen HA and Samsung TV works ok.
I also test when come back to home. But you are very veru good expert. Thanks
My problem is that I’m using VMware ESXi 7u3. The system dynamically assigns an interface name similar to ens1p2 or something. I’ve tried to attach vlans via the commanding but that just caused a duplicate address to show up on the network and didn’t solve the problem.
Best solution ice found so far is to only staticly assign and IP to an interface you want as default. Then let the rest pick up their is via DHCP Reservations. Haven’t had any trouble since, but I’ve also moved onto ipv6