4

I'm trying to listen to two different interfaces that are loopbacks on a single Linux machine using wireshark. Since I'll need to listen to the new interface, I'll need to be able to send data to the interface. Meaning it will require an ip address that I can send data to via netcat.

I've seen a method to add different loopback interfaces here, but that doesn't actually add an interface option, just seems to assign a separate ip address to the single lo interface.

I also tried adding the lo2 loopback interface to /etc/network/interfaces file, and after reboot, it didn't appear to do anything. Also, sudo ifup lo2 didn't work either.

This is Ubuntu 16.04 desktop, and I need to keep it to a desktop version of a Debian based distro.

Is there a way to add an additional loopback with a separate interface name?

3
  • From .../drivers/net/loopback.c : /* The loopback device is special. There is only one instance per network namespace. */ Commented Jul 6, 2017 at 19:42
  • 1
    It says, "There is only one instance", not, "There can only be one" (HighLOnder), which would mean there's still a possibility. I have faith! Commented Jul 7, 2017 at 15:16
  • 2
    To be honest, I thought I'd get several hundred upvotes for the HighLOnder line. Commented Jul 10, 2017 at 2:45

1 Answer 1

1

Install the uml-utilities package:

sudo apt install uml-utilities

Create a loopback interface :

sudo tunctl

Sample output:

Set 'tap0' persistent and owned by uid 0

Bring up the tap0 interface:

sudo ifconfig tap0 up

To remove the tap0 run : tunctl -d tap0

To assign an Ip address :

 sudo ifconfig tap0 192.168.0.254 up

Sample output:

tap0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.0.254  netmask 255.255.255.0  broadcast 192.168.0.255
        ether ce:bd:dd:0f:08:c8  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

e,g 2:

$ sudo ifconfig tap0 127.0.0.1 up
tap0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
inet 127.0.0.1  netmask 255.0.0.0  broadcast 127.255.255.255

Tap interfaces

man tunctl

3
  • Thanks, while that does add an additional loopback interface, it doesn't assign it an ip address (similar to 127.0.0.x, or anything else). Is there a way so that this interface is reachable via something I can see on wireshark? Commented Jul 10, 2017 at 2:33
  • I did try ifconfig tap0 127.0.0.2 netmask 255.255.255.0 up, but everything seems to still go through the 127.0.0.1 (lo) interface. Nothing is seen on wireshark actually going to the tap0 interface. Commented Jul 10, 2017 at 2:45
  • @trueCamelType, the tap interface will not have the IFF_LOOPBACK flag set, so won't be a true loopback interface, even if you assign it an IP address in 127/8. Commented Jul 10, 2017 at 8:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .