Linux: Find out which network card or NIC server is bind or running on

Q. I have two network cards interface eth0 and eth1. Further eth1 has 4 aliases. All end user can use access any service using these IP address. So I want to find out which network card or NIC server/service is bind or running on. For example Apache web server or postfix mail server.

ADVERTISEMENTS

A. That is true, by default server will bind to all ports. You need to use combination of netstat and ifconfig to find out all binding ports for selected service.

For example, find out Postfix (port 25) is bind to which IP or network card (aliases):
$ netstat -tulpn | grep :25
Output:

tcp        0      0 192.168.5.10:25                0.0.0.0:*                   LISTEN      26586/master

Above command find out that Postfix is listing to which port and bind to which IP address.

From the output, you can see Postfix is bind to IP 192.168.5.10 address. Use ifconfig command to find out network card name:
# ifconfig

Many network software programs have an option to bind to specific IP. Read the man page of particular software for more information.

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
0 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.