Ping IP with source IP?
Asked Answered
S

4

8

I am trying to send ping, but using with a source Ip. Tried this,

ping example.org -i 88.65.48.77

It pings without any errors, but I am confused. In the manual, it says -S is a source operator. But if I use -S 88.65.48.77, I get a Ping Transmit failed. General Error. So what is the correct way to do that ?

Slinkman answered 21/11, 2014 at 16:1 Comment(4)
What version of Unix/Linux?Shaniceshanie
Using on windows, command line.Slinkman
So, you have a windows PC; does it have multiple network interface cards (NICs), and is the IP address for one of them 88.65.48.77? The purpose of the -S flag is to send the pings from a specific NIC.Shaniceshanie
No, the IP is not one of them.Slinkman
S
5

You only need/want the -S flag if you have multiple network interface cards (NICs), and you want the source of the pings to come from a specific NIC; this is seldom needed. Your command

ping example.org -i 88.65.48.77

is actually saying to ping example.org with a TTL (time to live) value of 88.65.48.77, where -i is really expecting a maximum number of "hops" -- say 10, not an IP address.

So if you are trying to ping 88.65.48.77, just

ping 88.65.48.77
Shaniceshanie answered 21/11, 2014 at 16:39 Comment(4)
No, I want to ping example.org with mimicking that ip. Means that, using source ip as 88.65.48.77 when sending ping to example.orgSlinkman
Sorry, you can't spoof your IP address using the ping command. Some network protocol analyzers will let you do that by generating "doctored" packets, but not the ping command.Shaniceshanie
@MarkStewart How would one "spoof" an IP and ping another IP? In other words, My IP is A, but I want to ping IP C with IP BClaypool
A commercial network protocol analyzer program like Omnipeek from Savvius can do it; not sure if wireshark (open source) can.Shaniceshanie
S
5

Check your network using Source Address in different environment.

If you are a Windows user use the following command. Example:

ping target address(x.x.x.x) -S source address(x.x.x.x)

If you are a Linux user use the following command. Example:

ping -I source address(x.x.x.x) target address(x.x.x.x) 

In Cisco device use the following command Example:

ping target address(x.x.x.x) source source address(x.x.x.x)
Southeasterly answered 23/6, 2018 at 10:52 Comment(0)
A
0

I had a situation where ping example.org -S x.x.x.x and I was getting a Ping Transmit failed. General Error. too. In my case the IP address I was trying to use as the source was not bound to that machine. Using the correct source IP resolved my issue.

Assr answered 6/5, 2022 at 20:53 Comment(0)
K
0

To "spoof" an IP Address in Windows, you need to add the IP address to the network interface in question.

  1. Click Start, type npca.cpl, and hit enter
  2. Right click interface in question (will assume Ethernet) and select Properties
  3. Select Internet Protocol Version 4 (TCP/IPv4) and select properties
  4. Select Advanced
  5. Select Add... under IP addresses
  6. Enter your IP and Subnet (88.65.48.77 / 255.255.255.0 or .255 is also fine)
  7. Select Add, Ok, Ok to save changes

You can now use Ping -S 88.65.48.77 example.org to test sending pings on that IP address.

What happened in the background? Your IP was bound to the Network Interface in question and Windows also updated your route tables to allow for this IP to function, even though your primary IP might be something like 192.168.1.100. This is viewable via entering ROUTE PRINT in Command Prompt. You can also use a tool like WireShark to see traffic on your interface and see that you are in fact sending ICMP (Ping) packets via 88.65.48.77

Kelsey answered 17/7, 2023 at 17:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.