Virtual network interface in Mac OS X

前端 未结 12 2255
礼貌的吻别
礼貌的吻别 2020-12-12 10:15

I know that you can make a virtual network interface in Windows (see here), and in Linux it is also pretty easy with ip-aliases, but does something similar exist for Mac OS

相关标签:
12条回答
  • 2020-12-12 11:09

    Go to Network Preferences.

    At the bottom of the list of network adapters, click the + icons

    Select the existing interface that you want to arp (say Ethernet 1), and give the Service Name that you want for the new port (say Ethernet 1.1) then press create.

    Now you have the new virtual interface in the gui and can manage IP addresses etc it in the normal way.

    ifconfig -a will confirm that you have multiple IPs on the interface, and these will still be there when you reboot.

    Its a Mac. Don't fight it, do it the easy way.

    0 讨论(0)
  • 2020-12-12 11:11

    In regards to @bmasterswizzle's BRILLIANT answer - more specifically - to @DanRamos' question about how to force the new interface's link-state to "up".. I use this script, of whose origin I cannot recall, but which works fabulously (in coordination with @bmasterswizzles "Mona Lisa" of answers)...

    #!/bin/zsh
    
    [[ "$UID" -ne "0" ]] && echo "You must be root. Goodbye..." && exit 1
    echo "starting"
    exec 4<>/dev/tap0
    ifconfig tap0 10.10.10.1 10.10.10.255
    ifconfig tap0 up
    ping -c1 10.10.10.1
    echo "ending"
    export PS1="tap interface>"
    dd of=/dev/null <&4 & # continuously reads from buffer and dumps to null
    

    I am NOT quite sure I understand the alteration to the prompt at the end, or...

    dd of=/dev/null <&4 & # continuously reads from buffer and dumps to null

    but WHATEVER. it works. link light

    0 讨论(0)
  • 2020-12-12 11:16

    It's possible to use TUN/TAP device. http://tuntaposx.sourceforge.net/

    0 讨论(0)
  • 2020-12-12 11:17

    Take a look at this tutorial, it's for FreeBSD but also applies to OS X. http://people.freebsd.org/~arved/vlan/vlan_en.html

    0 讨论(0)
  • 2020-12-12 11:18

    The loopback adapter is always up.

    ifconfig lo0 alias 172.16.123.1 will add an alias IP 172.16.123.1 to the loopback adapter

    ifconfig lo0 -alias 172.16.123.1 will remove it

    0 讨论(0)
  • 2020-12-12 11:19

    ifconfig interfacename create will create a virtual interface,

    0 讨论(0)
提交回复
热议问题