Is IPv6 send-to-self possible in linux - linux

I am trying to create a setup for testing network equipment, and would like to use multiple (3) NICs in a single PC to produce traffic through an external device, i.e. a network switch. From one interface to another.
All of the tests are for IPv6 and ethernet. All NICs have link local and global IPv6 addresses with the same network/subnet prefix.
Atm. all packets are routed internally and never use the physical wire.
I see a lot of threads solving the problem for IPv4 using the net.ipv4.conf.all.accept_local parameter together with some routing table fixes. But I can't find a solution for IPv6.
Anyone know of a solution?

Related

is there map for ipv4 internet?

sorry my poor title but I don't know how to express my intention.
In ipv4 there are 2**32 addresses right?
and then if I send 1024 packets per second I could check all the devices of the internet in 1165 hours to create map of the internet. with it I want to make a topology of the internet
it's not that bad, if I go with multiple computers like raspberry pie it would be more faster.
if it's not me but somewhat organization or people and they have enough time, it could even scanning all the ports of all the devices of the internet..!
is my thought a daydream? or somebody already did it? please let me know! I'm curious
If you are interested in the actual physical location of an IP address, then there are many sources compiled already available, like the one here for free. Some are more accurate(commercial ones) than others.
If you just want to know if an IP address is alive or what services are available then you are out of luck as many of these "public" IP addresses are only accessible from whitelisted sources and/or heavily protected from folks like you trying to sniff around for profiling reasons.
If you would like to map out the topology of the Internet, you could get a view of the Autonomous Systems (collection of IP network addresses typically owned by ISPs or larger corporations) by looking at publicly accessible BGP looking glasses. BGP is the protocol that controls the routing of packets on the Internet. Please note that this is very dynamic and changes frequently due to the dynamic nature of path selection algorythms.

Switch connection not working

Although some similar questions have been asked here, none of them seem to solve my problem, so I've decided to specify my case in a new question.
(Please keep in mind that I am a beginner in computer networks) I have 5 machines I want to connect to each other. I am using a switch to do so.
My first problem is that among 4 of the machines, 3 of them seem to have the same Broadcast and can hence communicate with each other. But 1 of them has a completely different broadcast and cannot communicate with any of the machines (although all 4 are connected to the same switch...). Note that all 4 machines have the Gentoo linux distribution.
Moreover, the fifth machine (which has Ubuntu linux distribution) doesn't even seem to have an ip assigned to itself. When I do "ifconfig" I don't get the eth0 interface but enp0s25 instead, where the inet addr is not specified.
I guess if I can determine the same broadcast in all 5 machines I will be able to obtain a propoer connection between the machines.
Thank you for your time
You have to check if your PCs are in the same network maybe that is the reason you have different broadcast address. Check if your IP and Netmask are correct. Read this link for more information IP Addressing and Subnetting for New Users
Example:
Network - Broadcast
192.168.1.0/24 -> 192.168.1.255
192.168.1.0/25 -> 192.168.1.127
192.168.1.127/25 -> 192.168.1.255
In the examples look like all are in the same network but in reality are in different networks/sub-networks
About you eth0 check if your interface is using a static or DHCP IP.
check the configuration file:
/etc/network/interfaces

Linux: talk to different devices with same mac on different interfaces

I have multiple devices with the same hardware mac address (in factory reset mode) that all call a tftp server in order to get a proper mac.
On the same nic, there would obviously be no way to differentiate the devices, however, i have one device per nic. I evaluated these options to use that fact:
SO_BINDTODEVICE
Binding the tftp server on each nic separately would probably still not give me a way to respond with a package to the sender, since linux' arp table would be confused about which nic to send that package out from.
net namespaces
Linux does not allow bringing physical interfaces into a net namespace. only veths, which again would need to be bridged on the 'host' side, which will probably not work with the same mac appearing on multiple physical nics.
Am i missing an option here?

Perform Connect on specific NIC in a two NIC Linux system

Business case:
This is year 2015, and I am using Linux kernel 3.17. My ARM Linux has two NIC, eth0 and eth1. eth0 is for configuration purpose locally for a person next to it, and eth1 is for configuration purpose from remote. So they are basically same function, except eth0 has a person to plug in the cable in the field.
Local PC ------ [eth0 My ARM Linux Computer eth1] ------ Remote PC
Using eth0, the PC software can configure eth1 IP address and port for configuration. To do that, my eth0 has a preset IP address (192.168.1.2) so the PC software can easily find it. The ARM Linux (3.17) application needs to listen on eth0 port A, and eth1 Port B (if configured), and once connected, will respond, but never initiate any activity (not even ping).
There is no connection between local PC and remote PC. They are not supposed to be bridged, or networked.
Question 1:
If eth1 is configured with same IP as eth0, will my application still able to listen on both NIC ports, and correctly respond? I will have two independent threads (maybe same function, but different parameters) to listen on the two NIC ports.
This is why I ask whether I can specify the NIC when connect, and respond, because now you can see they could have same IP address. Ideally, the OS knows where is the connect request is from, so it should know which way to reply to, even if the two NIC have same IP as long as they have different Ethernet address. But, does C++11 or Berkeley model allow me to specify eth0 or eth1 when I listen and reply?
Now, the local PC and remote PC could have same IP address as well (but different from the ARM Linux). But imagine I have two ARM Linux computers, then this configuration is completely ok. But unfortunately I only have one embedded system and one OS with eth0 and eth1.
Question 2:
If answer to question 1 is no, then can they have same subnet mask? Also, can the local PC and remote PC have same IP address?
Assumption
Setting routing table, is a solution, if works. I wanted to know whether it is feasible and also whether it is recommended not to do it.
Also, this is Linux. Similar questions were asked long time ago for Windows, and Windows XP says (no) and I am using Linux 3.17 and I have same IP address so things are different from similar questions.
At the system level, you can configure a bridge on the mediating box. This can have the same IP address on both sides of the bridge and can be locked down using iptables to only respond to particular TCP/UDP ports.
You can't have systems on both sides of the bridge with the same IP address (i.e. the local pc and remote pc can't have the same IP address). You can use ebtables to limit the access on either side of the bridge to the IP address of the bridge itself, which means that the local pc can only talk to the mediating box and the remote pc can only talk to the mediating box.
This is based on never expecting the local and remote pcs to talk to each other.
It's mostly a sys-adminny solution, though, there's not really an API that you could use as a developer to accomplish the same thing.

Doing ARP and Inverse ARP on Linux 2.6.21 (glibc 2.3.5)

I need to store persistent reference to third party device on an arbitrary IP network where the IP address of the devices may be static or randomly assigned by DHCP. I don't control the devices on the network and I can't rely on DNS and other ad-hoc networking protocols existing or working with the devices.
So I have been instructed to investigate using hardware addresses and ARP. This will work but I don't want to duplicate code. The kernel must manage an ARP table. On Windows you can access it using GetIpNetTable etc.
I am hoping there is an API to answer these two questions:
How do I translate from IP to MAC address? (ARP)
How do I translate from MAC to IP address? (InARP)
If not then I may have to do it more manually:
How do I read the kernel's ARP table?
How do I add an entry if I have the determined a mapping myself?
/proc/net/arp
K
ARP tables tend to be fairly local and short-lived. If you examine the protocol, the real MAC addresses are generally only provided when the given IP address is in the local subnet.
Otherwise, the packet is forwarded to the local router, which is then responsible for forwarding it.
If you do "arp -g" on Windows or "arp -a" on UNIX, you'll see the table, but I don't think it will do you any good, due to the reasons mentioned above. That command and
That's really what DNS is for but, as you say, it may not be an option for you.
You may well have to write your own 'ARP' database at your application level.
As for ARP:
You could use system("/usr/bin/arp -option_of_choice"); and parse the output, but that's an ugly hack. -- Not my recommendation.
Take a look at /usr/include/linux/sockios.h -- At the SIOCGARP, SIOCDARP, and SIOCSARP details. Those are ioctls that you can perform to manage the ARP table on linux. Of course, you'll have to perform these ioctls on a socket fd.
Here's some examples: SIOCGARP examples
I'm sure you can find many other examples in several other languages as well. As I'm assuming that you're using C.
As for RARP:
A quote from the linux rarp manpage:
" This program is obsolete. From version 2.3, the Linux kernel no longer
contains RARP support. For a replacement RARP daemon, see ftp://ftp.demen-
tia.org/pub/net-tools"
So you'll have to install rarpd on the target system.

Resources