Hot answers tagged

136 votes
Accepted

How can I create a virtual ethernet interface on a machine without a physical adapter?

Setting up a dummy interface If you want to create network interfaces, but lack a physical NIC to back it, you can use the dummy link type. You can read more about them here: iproute2 Wikipedia page. ...
user avatar
  • 346k
82 votes
Accepted

List ports a process PID is listening on (preferably using iproute2 tools)?

You can use ss from the iproute2 package (which is similar to netstat): ss -l -p -n | grep "pid=1234," or (for older iproute2 version): ss -l -p -n | grep ",1234," Replace 1234 with the PID of the ...
user avatar
  • 25.4k
70 votes

List ports a process PID is listening on (preferably using iproute2 tools)?

I am not aware of a way using iproute2 tools. But as a workaround, you could try this one out. lsof -Pan -p PID -i should give you the information you are looking for. Output lsof -Pan -p 27808 -...
user avatar
  • 36.7k
42 votes

alternative to "netstat -s"

NETSTAT is considered deprecated at nowadays and others programs included in the net-tools like arp, ifconfig, iptunnel, nameif, netstat, and route. The functionality provided by several of these ...
user avatar
  • 58.2k
36 votes

How can I create a virtual ethernet interface on a machine without a physical adapter?

You can create virtual interfaces using the iproute2 toolkit. ip link add veth0 type veth peer name veth1 This will create 2 interfaces, veth0 and veth1. Think of them as 2 ends of a pipe. Any ...
user avatar
  • 67.6k
28 votes
Accepted

Is it possible to have multiple default gateways for outbound connections?

Solved it myself. There seems to be very little information about the networking stuff that you can do with Linux, so I have decided to document and explain my solution in detail. This is my final ...
user avatar
  • 843
27 votes
Accepted

alternative to "netstat -s"

netstat has indeed been deprecated by many distributions, though it's really much of the "net-tools" package (including ifconfig, route and arp) that has been deprecated in favour of the &...
user avatar
  • 9,271
22 votes

How to understand (the output of) ifconfig or ip addr show

Here're the parts that I can already parse, for reference for anyone else with the same question. eth0 is the interface name. It can be any string: mtu 1500 maximum transmission unit = 1500 bytes, ...
user avatar
19 votes

'ip addr' command shows 'UP' even there is no address associated with that interface

The LOWER_UP is the state of the Ethernet link (or other link layer protocol). It's defined as Driver signals L1 up, which basically means the cable is fitted and it can see another device on the ...
user avatar
  • 31.7k
18 votes

List ports a process PID is listening on (preferably using iproute2 tools)?

You can use netstat for this to figure out pid of each listen process. netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships -a,...
user avatar
  • 3,831
18 votes

Is it possible to have multiple default gateways for outbound connections?

Linux provides a better solution than your scripted workaround: active-backup bonding. This way your machine will have only one ip address (and one mac address) and automatically and transparently ...
user avatar
  • 181
13 votes

List ports a process PID is listening on (preferably using iproute2 tools)?

@jofel's answer shows you the appropriate tool to use, ss, here's the replacements for the other networking tools in iproute2. The deprecated commands and their iproute2 equivalents are as follows: ...
user avatar
  • 346k
11 votes

Namespace management with ip netns (iproute2)

You have two questions in one: what are the empty files in /var/run/netns/? how to use /etc/netns/ which doesn't even exist? What are the empty files in /var/run/netns/? Some understanding of ...
user avatar
  • 25k
10 votes
Accepted

List *all* IP routes to a destination in the Linux routing table

There is an easy way to list all routes matchig prefix on linux : ip -6 route list match 2607:f8b0:4005:804::200e table all This will list all possible routes to specified target (including default, ...
user avatar
  • 116
10 votes
Accepted

Where is the official documentation (Debian package iproute-doc)?

The documentation is available in the Debian 9 package but was removed in later releases because it was outdated. The manpage is supposed to be the complete documentation now. (But it doesn’t have ...
user avatar
9 votes
Accepted

what do the numbers mean in ip rule show command

From the man page ip-rule: At startup time the kernel configures the default RPDB consisting of three rules: 1. Priority: 0, Selector: match anything, Action: lookup routing table ...
user avatar
  • 346k
9 votes
Accepted

Interface both up and down?

Within the angle brackets there is a list of flags (= on/off type properties) of the interface. After the flags, non-binary properties (also known as attributes) are listed. There are two concepts you ...
user avatar
  • 68.2k
9 votes
Accepted

iproute2: How to display the TYPE of a network devices?

The interface type information, being rarely used, is normally displayed only by adding the -details option to ip: -d, -details     Output more detailed information. So ip -details link show would ...
user avatar
  • 25k
9 votes
Accepted

The difference between ip link down and physical link absence

There are difference between an interface which is administratively up but disconnected or administratively down. Disconnected The interface gets a carrier down status. Its proper handling might ...
user avatar
  • 25k
8 votes
Accepted

Connecting two network namespaces via a veth interface pair where each endpoint has the same name

The best that I can offer is to execute the command in one namespace (using the -n shortcut), create each endpoint with the same name, and move one of them into a different namespace in that command: ...
user avatar
  • 29k
7 votes
Accepted

Translating this `ip` command to `route` command in `post-up` hook

Simply add the ip command as an up command in /etc/network/interfaces (no need to translate to route, post-up is an alias for up): allow-hotplug eth0 iface eth0 inet static address 10.1.10.100 ...
user avatar
  • 15k
7 votes
Accepted

How can I bring up a non-boot (ONBOOT=no) network interface with iproute2?

In RHEL 7+, you'll have to use nmcli command for permanent change. nmcli command uses /etc/sysconfig/network-scripts/ifcfg-con_name file first, also when you modify connection properties with nmcli it ...
user avatar
  • 502
7 votes
Accepted

iproute2 command to enable a IPv4 address

ip and ifup serve different purposes, and are complimentary. ip should not be used to replace ifup. Actually, ifup operates at a higher level. ifconfig (traditional, portable) and ip (Linux-only, but ...
user avatar
  • 41.1k
7 votes

'ip addr' command shows 'UP' even there is no address associated with that interface

The UP status is the administrative state of the interface, i.e. whether the interface has been enabled. You can enable any interface using e.g. ip l s eth0 up If the cable is plugged in and a link ...
user avatar
6 votes

What's the exact behaviour of the command: ip address change?

When you are not sure of what something does, and the documentation doesn't say, you got to the sources, namely line 1588: if (matches(*argv, "change") == 0 || strcmp(*argv, "chg&...
user avatar
  • 34k
6 votes
Accepted

What's ndisc_cache?

In IPv4 networks the neighbour tables are written with usage of the Address Resolution Protocol. Those tables are commonly known as "ARP-tables". They resolve IP-addresses (addresses in the network ...
user avatar
  • 45.6k
6 votes
Accepted

How to get numerical output in `ip route` command

The purpose of the -n option of route is to suppress address-to-name lookups. It can be used for example to get the raw numerical information in case the lookups are too slow or returning incorrect ...
user avatar
  • 41.1k
6 votes

How can I bridge two interfaces with ip/iproute2?

The equivalent of brctl show is bridge link. You can show the bridge status per device with bridge link show dev eth0 but bridge looks at the network interface and tells you which bridge it belongs to ...
user avatar
6 votes
Accepted

ss not showing all ports being listened on

This might help you, ss -tupln | grep 1080
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible