In linux In which file ip address of my system is present - c

From which file ifconfig command takes input for displaying ip address, inet addr and h/w addr ?. I want this information for my presentation. Any file apart from /etc/network/interfaces is there ? Looking foreword for help.

It's in the manual man. just run command man ifconfig in your terminal and at bottom it says
it comes from these three files:
FILES
/proc/net/socket
/proc/net/dev
/proc/net/if_inet6
Hope it works.

IN computer to look up hostnames and IP addresses go to /etc/hosts file.
here ifconfig displays the status of the currently active interfaces you only view the information not access.

Related

how can i fetch the names & ip addresses of machines connected in a same network using c?

for my project i have to fetch all devices name & their ip address which are connected in same network.
How to get the names and ips of all devices on my local network? somewhat similar to post but i have to use c code & this post is for ios only.
I know that ARP protocol use to map ip address with the mac address but exactly don't know how to scan all the ip's from there.
My aim is to get the output without any command line tool as nmap & arp command are also there which will give the network ip addresses but not in a proper way.
Can anybody tell me the way i can get all these details with or without code that would be really helpful.
Thanks,
you can socket raw c, Create two threads
Thread 1: ping all machines using ICMP.
Thread 2: Caputre all data comming to your interface (ex: eth0) then filter only ARP response.

Search device using MAC address

I want to check presence of a device in network. The IP address of device keeps on changing. Is there any way I can search device through MAC address.
Through ARP I can ping the device but as IP keep on changing, I am thinking get device through MAC address.
Is there any mechanism to search device through MAC.
On Linux, you can use a tool called arp-scan.
Not sure what you tried so far.
arp -s < IP address > < MAC address >
There is an interesting article published by Microsoft
https://technet.microsoft.com/en-us/library/cc961394.aspx

Finding IPMI ip Address

Currently I'm part of a CTF competition and I'm trying to get a flag from an IPMI server (specifically an Supermicro IPMI) to which I have to find a back-door of some kind. I have a guide for gaining back-door access, but I need the ip address of the server. The web address of the IPMI isn't preceded by an ip address like I've seen others (sorry for vagueness here but I can't provide certain info or I'll break the rules of the competition). If somebody could help me understand more about how web addresses of IPMI servers (like I said it's a Supermicro) work that would be so helpful. Participially, either getting the ip or methods that don't use it that I can use as an alternative (I have Kali installed btw).
If you can reach the target machine,
You can enter the input method on the machine...
# ipmitool lan print | grep "IP Address"
To clarify:
The server has a microprocessor which controls the system which is called BMC (Baseboard Management Controller). The BMC is a system on it's own, it has a limited linux running, and several interfaces and regarding IP it has different ports open and IPv4 and IPv6 address.
Either you have a DNS name which you can resolve or you have an IP address. The answer really depends on what information you really got. (maybe more exotic like serial number, MAC address, etc).
So I'm trying to give multiple choices:
If you have no other servers in this network you could scan the network
fping -a -g -q -m 10.200.0.0/24
If you have access to the server as root you can the command what #xiadong proposed
ipmitool lan print | grep "IP Address"
This is version how to get IPMI ip when ipmitool is installed and assume that /dev/ipmi0 exists ( loaded modules )
if [ -e /dev/ipmi0 ];then
IPMI_IP=$(ipmitool lan print | grep "IP Address " | cut -d: -f2 | tr -d [:blank:])
fi
echo $IPMI_IP
192.168.100.100

How can I extract mac address from a icmp reply in c on linux

I am trying to find out mac address of a machine in a switched environment after sending it a raw packet. I am trying to implement traceroute command . I want to know when i receive a ICMP time exceeded message how can I extract the mac address of that machine . I am a new to network programming so am confused what socket call will help me to extract the mac address.
Thanks .
No, you can not extract MAC address from ICMP reply.
You can only determine MAC addresses of linked machines next to you. In ICMP(tracert) you can just find out the IP address of target or middle machine.
If you want to detect MAC addresses, you should use ARP protcols where it's applicable in local networks not Internet.
ICMP protocol starts after IPv4 header[1] and MAC addresses is related to physical/link layer. In low level layers the MAC addresses will transparent from top level layers such as network(IP) or Transmission,...
To determining MAC addresses, you should use Raw sockets or PCAP SDKs to access lower layers of network programming. (I say again, these are not useful over Internet)
Like Masoud M said, you can only get the MAC address of machines that are on your local network. That said, you can parse the output the arp command to find the MAC address given the IP address of a machine one your local network.
In general, on internet, you don't even know the media a host is using for transmitting packets. Let's suppose a remote host is conected over a serial rs-232-C link with PPP protocol. It doesn't have a mac address. This also happens for example if the host uses a token ring interface or frame relay link. This makes determining the remote mac addresses of hosts a local issue completely. Normally, when you get a packet from a remote site over ethernet, the source mac addres you get in the packet is the one of the last router that links you to the internet, not the one of the original host that sent the IP packet. In the RFC on IP over avian carriers (rfc1149, rfc2549 and rfc6214) the media used for transmission doesn't allow to use mac addresses (the link address, if somewhat feasible on a pidgeon could be, would be its name)
If you want to read about traceroute on ethernet network of switches, perhaps you had to have a look at the IEEE802.1ag, that has an specification to do tracerouting over switches (tracelink service) but I think is far over the scope of this answer.

How to Determine IP and MAC address for netsnmp agent?

I am using Debian 6.0 and net-snmp 5.4.3. I have a question relating to capturing IP address and MAC address for ethernet interfaces exist on the system. In my SNMP agent, I have to figure out how many system ethernet interfaces are exist and update their IP and MAC address in a table. I have looked at pre installed mibs and found that IP-MIB contains a table for system ethernet IP addresses but I couldn't find the source to check how it is implemented. Could you please suggest me how can I implement this functionality or where I can find some further infromation?
Thanks,
Ravi
Someone may suggest a better way, but if not here's a solution of last resort. You can call out to ifconfig to get the data as text and then parse the results.

Resources