Question:
I can reach Host B from Host A using interface eth0. Host B has Ip address 192.168.26.116 assigned to interface eth3. Ip address 192.168.26.116 is reachable from host A. Now host B has another Ip address, 192.168.29.200, at interface interface_at_hostb. But this Ip is not reachable from Host A. How to fix this issue using linux static route approach?
Answer:
To add a static route in Host A so that you can reach Host B using the IP address 192.168.29.200, you can use the command:
route add -host <ip-address-you-want-resolve> gw <HostB_eth3_IP> dev <interface_eth0>
You will need to replace the following with the appropriate values:
<HostB_eth3_IP>
: the IP address assigned to the eth3 interface on Host B (example:192.168.26.116
)<interface_eth0>
: the interface on Host A that is used to connect to Host B (example:eth0
)
For example:
route add -host 192.168.29.200 gw 192.168.26.116 dev eth0
You can verify the route has been added by using the command route -n
.
This command will add a static route in host A to reach host B's IP 192.168.29.200 via gateway IP 192.168.26.116, which is assigned to host B's interface eth3, and you will be able to reach to host B via interface interface_at_hostb as well.
You can delete this route using following command.
route del -host 192.168.26.104
Top comments (0)