58 votes
Accepted

ip vs ifconfig commands pros and cons

The ifconfig command on operating systems such as FreeBSD and OpenBSD was updated in line with the rest of the operating system. It nowadays can configure all sorts of network interface settings on ...
JdeBP's user avatar
  • 68.8k
39 votes
Accepted

How to set the Default gateway

ifconfig is not the correct command to do that. You can use route like in route add default gw 192.168.0.254 for example. And if route is not present, but ip is, you can use it like this: ip route ...
netmonk's user avatar
  • 1,880
33 votes

How to view your computer's MAC address using 'ifconfig'?

First, your computer doesn't have a MAC address. Each network card has a MAC address. So if your machine has a wireless card and an Ethernet card, it'll have two MAC addresses. On Linux, either of ...
dr_'s user avatar
  • 29.7k
33 votes

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

Here are 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, ...
Ari Sweedler's user avatar
23 votes
Accepted

How to find unspoofed MAC address of NIC

This answer is about Linux. ifconfig is obsolete and doesn't have access to a kernel API able to provide it this information. This information has been able to be retrieved for a long time with ...
A.B's user avatar
  • 36.6k
22 votes

Can I prevent a default route being added when bringing up an interface?

I faced similar problem on Raspbian (I suppose the solution below will be applicable to Debian as well). Raspberry Pi 3 has 2 NICs integrated: Wi-Fi and Ethernet. I use both of them, they are wlan0 ...
Roman Me's user avatar
  • 361
20 votes

How to set the Default gateway

ifconfig is deprecated on Linux and furthermore, it's the wrong tool for the job. To set the default gateway on Linux use the ip command as follows: ip route add default via <host> dev <dev&...
Marco's user avatar
  • 33.6k
20 votes
Accepted

How to capture the first IP address from a ifconfig command?

It is better avoid using ifconfig for getting an IP address in a scriptas it is deprecated in some distributions (e.g. CentOS and others, do not install it by default anymore). In others systems, ...
Rui F Ribeiro's user avatar
17 votes

How do I get my IP address from the command line?

This would return to you your public IP dig TXT +short o-o.myaddr.l.google.com @ns1.google.com
user3411123's user avatar
16 votes

ip vs ifconfig commands pros and cons

The standard ifconfig we have in many distributions is deprecated for several reasons. Talks in a outdated and limited way with the kernel, and in fact, does not understand anymore all the network ...
Rui F Ribeiro's user avatar
14 votes

How to find unspoofed MAC address of NIC

This answer is about NICs in general. Nothing about that MAC address is "unreal". In general, nothing guarantees that any network card does have any ROM that contains a unique MAC address. ...
Marcus Müller's user avatar
13 votes

How to view your computer's MAC address using 'ifconfig'?

For many linux systems ipconfig doesn't show the mac anymore. If that is the case for you, try: ip -a link
Gabriel Fair's user avatar
13 votes
Accepted

Create an array with all network interfaces in bash

Here is a solution, assign the list and then add item to it: #!/bin/bash array_test=() for iface in $(ifconfig | cut -d ' ' -f1| tr ':' '\n' | awk NF) do printf "$iface\n" array_test+...
Kevin Lemaire's user avatar
13 votes

What is my LAN IP (ubuntu and missing eth0)?

enp0s31f6 shows the flag UP but not RUNNING: this typically means it does not have a valid link at the moment. On the other hand, wlp0s20f3 has both UP and RUNNING flags present. The name prefix wl ...
telcoM's user avatar
  • 96.9k
12 votes
Accepted

Count network interfaces in Bash

It is possible using either a combination of grep and wc, or using awk First approach, using grep: ifconfig | grep "^tun" | wc -l This will pipe the output of ifconfig through grep, match all lines ...
AdminBee's user avatar
  • 22.8k
12 votes

Count network interfaces in Bash

You probably don't need ifconfig (or ip) for this. The interfaces are listed in /sys/class/net: % ls /sys/class/net eth0 lo tun0 tun1 tun2 wlan0 So, you can count the directories there, with ...
muru's user avatar
  • 72.9k
11 votes

What's the difference between "errors:" "dropped:" "overruns:" and "frame:" fields in ifconfig RX packets output?

I know this is a 1 year old question but it is 1st on Google so maybe I can add 5 cents to it. First I was not aware of this mod 8 rule on frame field... Is it a driver rule or kernel rule? In the ...
Tomasz Janicki's user avatar
11 votes
Accepted

How do I get my IP address from the command line?

You mean whatever routable IP your dsl/cable modem/etc. router has? You need to either query that device OR ask an outside server what IP it sees when you connect to it. The easiest way of doing ...
ivanivan's user avatar
  • 4,965
10 votes

Can I prevent a default route being added when bringing up an interface?

On RHEL6/Fedora 22 the following has been tested. In /etc/sysconfig/network-scripts/ifcfg-eth1 add the line: DEFROUTE=no Replace eth1 with name of interface where default routing is not wanted. ...
user3489409's user avatar
10 votes
Accepted

How to view your computer's MAC address using 'ifconfig'?

The command that you want on MacOS, FreeBSD, and TrueOS is: ifconfig -a link OpenBSD's ifconfig doesn't have this. Further reading ifconfig. Mac OS 10 Manual Pages. Apple corporation. 2008. ...
JdeBP's user avatar
  • 68.8k
9 votes
Accepted

How to know if my servers should use jumbo frames (MTU)

In my opinion the question should not be "How to know ...if"; it is more suitable asking "When should I setup Jumbo frames". As per your questions about MTU/Jumbo frames: To see ...
Rui F Ribeiro's user avatar
8 votes

where is ifconfig on suse studio

That particular program was "deprecated" in favor of a different package versus net-tools according to discussion last year in this page: openSUSE Tumbleweed net-tools vs net-tools-deprecated, and ...
Thomas Dickey's user avatar
8 votes
Accepted

What is a generic socket and how does it relate to a network device?

Let's quickly review device files: In Linux, application programs communicate read and write operations to the kernel through file descriptors. That works great for files, and it turned out that the ...
dirkt's user avatar
  • 32.4k
8 votes

How do I get my IP address from the command line?

Alternatives (avoid parsing): To get the IPv4 curl -4 icanhazip.com To get the IPv6 curl -6 icanhazip.com
Nuno Dio's user avatar
  • 306
8 votes

What is the ip address command equivalent of the default output of the ifconfig command?

ip address shows all IPv4 (inet), IPv6 (inet6), and link-level (like link/ether for ethernet interfaces) addresses by default, while ifconfig without -a only shows the interfaces that are up along ...
Stéphane Chazelas's user avatar
7 votes
Accepted

linux + single user mode and set network

Single-user mode by definition does not implement networking at startup. To put it in sysV runlevel terms, you want runlevel 2 (local multi-user with networking). You can switch to this with telinit ...
DopeGhoti's user avatar
  • 76.1k
7 votes

How to show only interfaces starting with a certain pattern

ifconfig's output has a blank line between each interface, making it perfectly suited for reading and processing in "paragraph mode" in a scripting language like awk or perl. A "paragraph" is any ...
cas's user avatar
  • 78.6k
7 votes

Ubuntu 18.04 New Netplan / IP Configuration (pointopoint?)

You have the right idea in your "additional info" pastebin. Applying the same IP addresses as your question: network: version: 2 renderer: networkd ethernets: ens18: dhcp4: no ...
Mathieu Trudel-Lapierre's user avatar
7 votes

How to find unspoofed MAC address of NIC

This answer is specific to FreeBSD. The MAC addresses of the NICs that were identified during the most recent boot are recorded in /var/run/dmesg.boot: $ grep 'Ethernet' /var/run/dmesg.boot em0: ...
Jim L.'s user avatar
  • 8,007
6 votes

change IP address

You might need to specify the subnet mask to use. The command above is likely assuming that the subnet mask is 255.255.255.255, which is for a point-to-point network. The following might work: sudo ...
saiarcot895's user avatar
  • 1,371

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