LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-04-2016, 06:48 AM   #1
john.searra
LQ Newbie
 
Registered: May 2016
Posts: 2

Rep: Reputation: Disabled
Multiple Network Interfaces - How to log the destination IP / Interface


Hi Folkes,

I am running an HTTP server and an SSH server which are bound to 0.0.0.0.

I have multiple network interfaces. Now, in the logs, I do get the source IP address of the user and other session related data.

But, I do not get the interface to which the user connected.

Is there a way to somehow get this information ?

Regards;

John
 
Old 05-04-2016, 07:47 AM   #2
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi there, and welcome.

Your best best is probably to look at the iptables command. Something like this will most likely do the trick:

Code:
iptables -A INPUT -p TCP --dport 80 -m limit -j LOG
iptables -A INPUT -p TCP --dport 22 -m limit -j LOG
Log messages are sent to syslog.

More info available at https://www.iptables.org/documentati...ing-HOWTO.html.

I hope this helps.
 
Old 05-04-2016, 08:46 AM   #3
john.searra
LQ Newbie
 
Registered: May 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
Thanks cliffordw.

Thats a neat idea. But in case of a lot of logs, it is going to be pretty hard to map application logs to syslog logs.

I am hoping that I should be able to somehow tweak the application itself to log the destination IP / Interface.

My servers are written in python.

Regards;

John
 
Old 05-04-2016, 01:22 PM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,309
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Quote:
Originally Posted by john.searra View Post
My servers are written in python.
Both the HTTP server and the SSH server you have are written in Python?

Maybe there is an option to increase the verbosity of the logs, or else you could find the lines where the log entry is created and add info about the interface yourself.
 
Old 05-04-2016, 01:45 PM   #5
cliffordw
Member
 
Registered: Jan 2012
Location: South Africa
Posts: 509

Rep: Reputation: 203Reputation: 203Reputation: 203
Hi,

In general, it should be possible for any user space application to log the IP addresses (source & destination) for any network connection it is handling. The interface name is a lot harder to get to.

In your Python code, you'll need to share a little more info if you want help. How are these servers handling the network connections? Are you using low level socket methods, or some higher level module(s)?
 
Old 05-06-2016, 04:07 AM   #6
fmattheus
Member
 
Registered: Nov 2015
Posts: 104

Rep: Reputation: 38
You didn't say which webserver you are running. If apache, you can log the local IP Address with the %A parameter to logformat. Then it should be easy to find out which device the IP Address belongs to. Unless you're using link aggregation, although I fail to see why you'd be interested in the information in that case ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple bridge interfaces on same Network interface. stazang Linux - Networking 3 10-10-2013 03:58 AM
RHEL: Linux Bond / Team Multiple Network Interfaces (NIC) Into a Single Interface SBN Linux - Networking 12 12-02-2011 10:53 PM
Network Unreachable for Destination Network other than Interface Jack10 Linux - Networking 3 08-17-2010 07:50 AM
Multiple Network Interfaces Simultaneously? Choose Interface for each program? smaddox Linux - Software 7 01-20-2010 01:26 PM
Several network interfaces: preventing access to one interface Pinguix Linux - Networking 1 11-30-2006 08:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration