# how create virtual interface (as Cisco vlan)



## andrian (May 17, 2016)

Hi, please help me. I want create virtual interface, but vlan is tagged! How create virtual interface and tie to real interface (physical) as on Cisco vlan access port?


----------



## SirDice (May 17, 2016)

See vlan(4). In short:

```
cloned_interfaces="vlan10"
ifconfig_em0="up"
ifconfig_vlan10="inet 10.10.10.1 netmask 255.255.255.0 vlan 10 vlandev em0"
```


----------



## andrian (May 17, 2016)

Thank you. But you example is create tagged vlan10 on the interface em0. Please help, how create not tagged vlan10 on the interface em0?


----------



## kpa (May 17, 2016)

"Not tagged VLAN", what you mean by that? A VLAN is tagged on the wire by definition and other types of VLANs don't exist. Please give us more information of what you're trying to do.


----------



## andrian (May 17, 2016)

Ok, wait please.


----------



## andrian (May 17, 2016)

if_bge1 - is physical interface (192.168.0.1/24)
alias0 - is alias on physical interface (192.168.0.10/24)
if_bge1 connected (cable) to switch untagged port 18.
So, I want create two virtual interfaces on physical interface.
example:
vlan1 (not tagged) address is 192.168.0.1/24  --------->if_bge1
vlan 2(not tagged) address is 192.168.0.10/24--------->if_bge1


----------



## andrian (May 17, 2016)

And these two vlans use in the packet filter (if_ext="vlan1" and if_ext2="vlan2"...).


----------



## SirDice (May 17, 2016)

```
cloned_interfaces="vlan1 vlan2"
ifconfig_bge1="up"
ifconfig_vlan1="inet 192.168.0.1 netmask 255.255.255.0 vlan 1 vlandev bge1"
ifconfig_vlan2="inet 192.168.0.10 netmask 255.255.255.0 vlan 2 vlandev bge1"
```


----------



## andrian (May 17, 2016)

Thank you, but me necessary "vlan" without tagged. How create "vlan" without tagged?


----------



## SirDice (May 17, 2016)

You can get the trunked data on bge1 itself.


----------



## andrian (May 17, 2016)

No trunk on bge1


----------



## andrian (May 17, 2016)

Can`t trunk on bge1 (sorry my English, I am study this language).


----------



## andrian (May 17, 2016)

me give (I have) only untagged port 18 on switch (look on picture). I can`t port 18 change mode to tag.


----------



## andrian (May 17, 2016)

Good day.
Please help me.
How create virtual network interface card and tie to physical network card?


----------



## Chris_H (May 17, 2016)

Using the alias keyword.
See ifconfig(8), for greater detail.

--Chris


----------



## andrian (May 17, 2016)

Thank you. I use alias, but necessary virtual nic.


----------



## andrian (May 17, 2016)

For example in Cisco:
physical interface have vlan mode (trank or access port). How create virtual interfaces in the FreeBSD?


----------



## Chris_H (May 17, 2016)

Hmm. Haven't used any Cisco equipment in years. Maybe try vlan(4), or divert(4)?

--Chris


----------



## andrian (May 17, 2016)

Vlan in FreeBSD not suitable because when create vlan - must write vlan id (tagged)!


----------



## andrian (May 17, 2016)

I hate Cisco ...


----------



## Chris_H (May 17, 2016)

dummynet(4), then?

--Chris


----------



## andrian (May 17, 2016)

divert and dumynet - is are packet tracker (firewalls). me necessary virtual nic as physical interface
example:

```
ifconfig vlan0 create
ifconfig vlan1 create
vlan0: flags=8002<BROADCAST,MULTICAST> metric 0 mtu 1500
  ether 00:00:00:00:00:00
  vlan: 0 parent interface: <none>
vlan1: flags=8002<BROADCAST,MULTICAST> metric 0 mtu 1500
  ether 00:00:00:00:00:00
  vlan: 0 parent interface: <none>
```


----------



## usdmatt (May 17, 2016)

I appreciate English isn't your first language, but the configuration you're trying to use makes very little sense. You can't turn one interface into two without some sort of encapsulation or tagging.



> vlan1 (not tagged) address is 192.168.0.1/24 --------->if_bge1
> vlan 2(not tagged) address is 192.168.0.10/24--------->if_bge1



For a start Cisco docs heavily discourage have two vlans using the same IP range, although it technically works.

Secondly, how can the FreeBSD machine receive traffic for two independent vlans, which are technically separate networks, if all the packets for both are coming into one interface untagged? At least one of the vlans is going to have to be tagged.



> me give (I have) only untagged port 18 on switch (look on picture).



In that really confusing picture you have two separate lines coming into bge1. How is this actually connected up physically?


----------



## SirDice (May 18, 2016)

As it's the same subject, same issue. Threads merged.


----------



## andrian (May 20, 2016)

Maybe me necessary create virtual switch at the physical interface and connect two vlans to virtual switch?


----------



## phoenix (May 22, 2016)

If the switch is configured to only receive untagged packets and add them internally to clean 18, then there is nothing you can do on the FreeBSD side of things.

If you want two separate vlans, then the switch needs to be configured to support multiple tagged vlans on that port (aka a trunk port).

If you can't reconfigure the switch, then vlans won't help you. You'll just need to either use two separate IP subnets and aliases (bge1=192.168.0.1/24 and bge1_alias0=192.168.1.1/24), or use two separate aliases in the same subnet (bge1=192.168.0.1/24 and bge1_alias0=192.168.0.10/32).


----------

