Jump to content

Guide to Unix/Explanations/Fake Networking Interfaces

From Wikibooks, open books for an open world

Loopback

[edit | edit source]

The system uses the loopback interface "lo0" to talk to itself. Most systems automatically configure it at boot. Talking-to-oneself is useful for testing servers, and also for any situation where the server and client are on the same computer. (For example, some computer games have a one-player mode where server and client are on the same computer. These games use the "network", but because there is only one computer, they use the loopback interface.)

Use the ifconfig command to check the status of the interface. It probably looks something like:

$ ifconfig lo
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 33224
        groups: lo
        inet 127.0.0.1 netmask 0xff000000
        inet6 ::1 prefixlen 127
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x5

The IPv4 address of your computer is "127.0.0.1". This is in addition to any address that it has on an actual network. In fact, every computer calls itself "127.0.0.1", so it is impossible to use this address to communicate between computers. (Some jokes involve a person who is given "127.0.0.1" as an attack target and proceeds to destroy their own computer.)

If your system is running an IPv6 stack, then your IPv6 loopback address is "::1". The computer should be able to use IPv6 to communicate with itself, even if it has no connection to an actual IPv6 network.

You probably have no problem pinging the interface with ping or ping6. We use "ping -c3" and "ping6 -c3" to ping 3 times; otherwise it would ping every second until you interrupted with ^C (CTRL+C).

$ ping -c3 127.0.0.1
PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.206 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.094 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.096 ms
--- 127.0.0.1 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.094/0.132/0.206/0.052 ms
$ ping6 -c3 ::1
PING6(56=40+8+8 bytes) ::1 --> ::1
16 bytes from ::1, icmp_seq=0 hlim=64 time=0.284 ms
16 bytes from ::1, icmp_seq=1 hlim=64 time=0.118 ms
16 bytes from ::1, icmp_seq=2 hlim=64 time=0.116 ms

--- ::1 ping6 statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.116/0.173/0.284/0.079 ms

Create interfaces

[edit | edit source]

If you want to use a fake network interface, you often must create it with "ifconfig create".

Some interfaces that you might be able to create: bridge, carp, gif, gre, lo, ppp, pppoe, sl, trunk, tun, vlan.