I think -net tap is the old way, use -netdev tap with new android sdk emulator and -device virtio-net-pci for x86 android emulator. For ARM emulator you must use an other device.
And you must install the emulator package with the sdkmanager as this:
Then you can use the emulator located in /opt/android-sdk/emulator/emulator.
Create a network bridge which include a tap interface (tap0) for the emulator and an ethernet interface (enp0s20u1) connected to a lan network.
# ip addr flush dev enp0s20u1
# ip link set enp0s20u1 down
# ip tuntap add dev tap0 mode tap user $(whoami)
# ip link add br0 type bridge
# ip link set enp0s20u1 master br0
# ip link set tap0 master br0
# ip link set enp0s20u1 up
# ip link set tap0 up
# ip link set br0 up
A quick overview of the bridge.
# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.0050b609a5d1 no enp0s20u1
Start a dhcp client on the bridge:
# dhcpcd br0
Then you can plug the tap interface (tap0) to the android emulator via -qemu options when you launch the emulator.
-avd android_25_x86 \
-verbose -no-window \
-device virtio-net-pci,netdev=hn0,mac=52:55:00:d1:55:51 \
Normaly a new eth1 interface is present in the android emulator. And you can run the dhcpclient binary if it present or configure static route to your network, then it work.
generic_x86:/ # ping -c 1 -I eth1 22.214.171.124
PING 126.96.36.199 (188.8.131.52) from 192.168.1.60 eth1: 56(84) bytes of data.
64 bytes from 184.108.40.206: icmp_seq=1 ttl=55 time=17.1 ms
--- 220.127.116.11 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 17.160/17.160/17.160/0.000 ms
But I have some issues to ping the emulator from the outside or route all the traffic in the emulator to the host network, see my other post.
Connect android emulator to lan