4

I need the ip command in cygwin. I discovered that it's part of the iproutes2 package. But cygwin doesn't have that package??

I what cygwin package can I find ip command?

(I need to find the gateway, and I don't want to use Windows' ipconfig command as my script needs to be portable)

2
  • Related: superuser.com/questions/721954/… Commented Jun 4, 2018 at 14:11
  • @Kusalananda that detals the basics, I know my way around cygwin, just cant find that command, maybe its in a different package bu the package search reveals nothing :( Commented Jun 4, 2018 at 14:16

2 Answers 2

5

The ip command is not available in any official Cygwin package (at the time of writing).

You may search the contents of all Cygwin packages using the "Cygwin Package Search" page, which allows you to search using regular expressions.

The ip command is however available in the Windows Subsystem for Linux (look for "Ubuntu" in the "Microsoft Store" app on Windows 10), but I can't say anything about whether it works as expected.

2
  • 2
    Thanks. Do you have any idea why such basic tools are not part of cygwin? Also ifconfig is not available. Thats weird Commented Jun 5, 2018 at 4:25
  • 3
    @lonix Cygwin provides some of the user-level tools that you would often find in Linux, but since it does not provide a Linux kernel, it can hardly be said to be "a Linux". ifconfig and ip are administrative tools that are usually available on Linux systems, but they are in no way standard tools on all Unix systems (ifconfig usually exists, in one form or another, but there's no guarantee). The Cygwin maintainers have opted to not try to provide admin tools for the underlying Windows OS. Commented Jun 5, 2018 at 5:00
1

There is no idiot proof way to do this in MSYS/Cygwin, so you have to resort to parsing native windows utilities. Looking at tools like ipconfig, arp, route, there are few options. The easiest seem to be parsing ipconfig. But the output depends on what you have named your interface, and possibly in what language your Windows OS was provided with. It also depends on how you are connected with your windows host, like via Ethernet, VPN etc.

So you'd see some long constellation of devices:

# ipconfig ... Wireless LAN adapter Local Area Connection* 2: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : home IPv4 Address. . . . . . . . . . . : 192.168.1.222 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.1 Ethernet adapter Bluetooth Network Connection: Media State . . . . . . . . . . . : Media disconnected Connection-specific DNS Suffix . : ... 

But here we see we want the one called "home", so we do the following:

alias ip="ipconfig | grep -i ': home' -A1 | grep -i 'IPv4 Address' | cut -d: -f2" # ip 192.168.1.222 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.