5

I need to create a VLAN in order to be able to ssh from my macbook to another computer(Comp1). My macbook is connected to this computer(Comp1) peer to peer using ethernet cable.

If this computer(Comp1) was connected to my ubuntu machine, I would have to run the following commands in ubuntu to create a VLAN and subsequently ssh in to the computer(Comp1).

sudo vconfig add en0 3
sudo ip addr add 192.168.126.5/24 dev en0.3
sudo ip link set up en0.3

Now I want an equivalent of the above commands for macbook. Man page for 'ifconfig' shows me 'vlan' as an option but it doesn't have enough detail for me to infer the command.

Most of the searches I did with regards to "VLAN setup in macbook" I found instructions that showed the way to configure VLAN using the UI. That is: System Preferences -> Network -> (left bottom gear)->Manage Virtual Interfaces -> (+) -> New VLAN... -> set VLAN name, Tag, Interface.

However I can not pick from the "Interface" dropdown list, the dropdown list has nothing to show. So I am not able to pick and consequently I am not able to create the VLAN (see pic)

enter image description here

Therefore this is the main reason why I am looking to find the command line way of creating VLAN in mac.

So in short, since the UI way of creating VLAN is broken for some reason, I want to create VLAN using terminal command on my macbook. How can I do that?

Thank you!

Rose
  • 151

2 Answers2

3

Your example from Linux

vconfig add en0 3
ip addr add 192.168.126.5/24 dev en0.3
ip link set up en0.3

can be translated to macOS by e.g.

ifconfig vlan0 create
ifconfig vlan0 vlan 3 vlandev en0
ifconfig vlan0 inet 192.168.126.5 netmask 255.255.255.0

Use DHCP instead of a static address:

ipconfig set vlan0 DHCP

Remove of vlan interface:

ifconfig vlan0 destroy
reichhart
  • 131
0

from the graveyard... If you want to solve the initial problem from the System Preferences UI, instead of going the workaround through Terminal:

  1. Network -> (left bottom gear)-> Manage Virtual Interfaces -> select "Thunderbolt Bridge" -> (-) delete it
  2. Network -> (left bottom +) -> "Thunderbolt Ethernet" -> create
  3. Network -> (left bottom gear)-> Manage Virtual Interfaces -> (+) -> New VLAN... -> set VLAN name, Tag, Interface. Thunderbolt Ethernet is now selectable
mjonas
  • 1