IP packet TTL (Time to Live) is to prevent infinite transfer. When passing through a subnet (router), it is decremented (value is decremented by 1). Here, set the router on Linux and check the operation of TTL.
As usual, we use VirtualBox to create such a configuration. See here for an example of VirtualBox settings.
With the above configuration, there is no need to set Static Route. Just enable Forwarding (net.ipv4.ip_forward).
~# sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 0
~# sysctl -w net.ipv4.ip_forward=1
net.ipv4.ip_forward = 1
Ping from terminal 2 (192.168.102.2) to terminal 1 (192.168.101.2). At this time, set the TTL to 10 (-t option).
~# ping -t 10 192.168.101.2
PING 192.168.101.2 (192.168.101.2) 56(84) bytes of data.
64 bytes from 192.168.101.2: icmp_seq=1 ttl=63 time=0.691 ms
It seems that the default of ttl is usually 64. The TTL decrement can also be confirmed with the reply packet "ttl = 63", but here, the state of "TTL = 10" at the time of transmission is confirmed with the packet capture data. Click here for the captured data on the sending side (terminal 2). Click here for the captured data on the receiving side (terminal 1). As expected, it is decremented as "TTL = 9".
Set to "TTL = 1".
~# ping -t 1 192.168.101.2
PING 192.168.101.2 (192.168.101.2) 56(84) bytes of data.
From 192.168.102.1 icmp_seq=1 Time to live exceeded
The TTL was decremented by the router, and it became '0', making the packet unreachable.
I confirmed that it can be a router even on Linux. Is it natural?
Recommended Posts