ish icon indicating copy to clipboard operation
ish copied to clipboard

ip/ifconfig not working, needs netlink

Open bc1bb opened this issue 6 years ago • 20 comments

Hello, I have tested ~20 packages today and I found some interesting things about ip and ifconfig on iSH : ip route get 1 give me ip: socket(AF_NETLINK,3,0): Invalid argument ifconfig give me

iPad~# ifconfig                                                                                                                       
ifconfig: /proc/net/dev: No such file or directory                                                                                         
ifconfig: ioctl 0x8912 failed: Invalid argument

I found no issue related to this

bc1bb avatar Dec 01 '18 13:12 bc1bb

There's no need for these to work, as network connectivity is managed by iOS. Still, I should make them return better errors.

tbodt avatar Dec 01 '18 17:12 tbodt

We can't get local IP on iOS without going to settings ? It would be useful

bc1bb avatar Dec 01 '18 17:12 bc1bb

That would be pretty useful actually.

tbodt avatar Dec 01 '18 17:12 tbodt

Output from ifconfig would still be handy. :)

DominikTo avatar Dec 22 '18 19:12 DominikTo

Regarding this, when using iSH with F5, it doesn’t know of routes coming in via the VPN, and as such I’m unable to ssh to machines in the VPN network.

marksergeant avatar Jan 22 '19 03:01 marksergeant

If ish does not have IP, then SSH cannot be used?

Koororo avatar Nov 19 '19 05:11 Koororo

SSH and internet works fine. The only thing that doesn't work is the ip and ifconfig commands.

tbodt avatar Nov 19 '19 05:11 tbodt

SSH and internet works fine. The only thing that doesn't work is the ip and ifconfig commands.

The difference is that if the mobile phone can access the alpine system through network, we could have the inside system to do many things, like establishing an ssh tunnel and using the tunnel to proxy the mobile phone network. Just like a accessable local backend.

riverhxz avatar Dec 08 '19 17:12 riverhxz

ssh tunneling should work fine.

tbodt avatar Dec 08 '19 18:12 tbodt

is there any way that other apps could access the tunnel ?

riverhxz avatar Dec 09 '19 01:12 riverhxz

What are you trying? What does it do instead of working?

tbodt avatar Dec 09 '19 04:12 tbodt

Sorry, the network works fine. I can access the localhost port. Another issue is the tunnel need background data refresh.

riverhxz avatar Dec 10 '19 07:12 riverhxz

Any progress on this?

authorisation avatar Aug 19 '21 20:08 authorisation

Bump

WillBishop avatar Jan 13 '22 02:01 WillBishop

Ifconfig is obsolete for iSH, it would be iplink && ip a to display network devices. 'AF_NETLINK missing socket' displayed due to config repository not added. Make sure you have drivers installed Run 'apk add linux-firmware' for drivers add config repo.. and setup lo loop back in networking.

redneckanarchist avatar May 27 '22 23:05 redneckanarchist

Hi @Tmero2, would you be able to clarify your comment? I have run apk add linux-firmware but I'm still getting the error ip: socket(AF_NETLINK,3,0): Invalid argument.

I am trying to understand:

  1. "add config repo" - is there any documentation on this config repo and how to add it?
  2. "setup lo loopback" - does this happen automatically when installing linux-firmware, or is it a separate step? If it is another manual step is this the same as adding a loopback device on standard linux, or are there any additional steps for iSH?

Thanks

b177y avatar Aug 10 '23 10:08 b177y

Hi @Tmero2, would you be able to clarify your comment? I have run apk add linux-firmware but I'm still getting the error ip: socket(AF_NETLINK,3,0): Invalid argument.

I am trying to understand:

  1. "add config repo" - is there any documentation on this config repo and how to add it?
  2. "setup lo loopback" - does this happen automatically when installing linux-firmware, or is it a separate step? If it is another manual step is this the same as adding a loopback device on standard linux, or are there any additional steps for iSH?

Thanks

It appears that @Tmero2 has been inactive on Github since he first signed up, back in May of last year. That comment above is only 1 of 2 tangible footprints he'd left on this network thus far.

So it's back to a bit more of the good ole google-fu exercise routine.

Unless of course the man himself @tbodt -->>> the original Dev, would kindly care to chime in.

Cheers, fellas!

reanimat0r avatar Sep 13 '23 17:09 reanimat0r

This script create by Abo5 using python

To get your ip in ish app do this steps

Usage:

cat > get-my-ip.py
import socket

#creating a socket object
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

#sending a dummy packet to a public DNS server
s.connect(("8.8.8.8", 80))

#getting the local IP address
ip = s.getsockname()[0]

#printing the IP address
print("Your IP address is:", ip)

#closing the socket connection
s.close()

and run the script

python3 get-my-ip.py

output is

Your IP address is: 192.168.1.100

Abo5 avatar Nov 18 '23 17:11 Abo5

Here is a C version by ChatGPT

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <unistd.h>

int get_local_ip(const char* target_ip) {
    int sockfd;
    struct sockaddr_in servaddr;
    char buffer[1024];

    // Create socket
    sockfd = socket(AF_INET, SOCK_DGRAM, 0);
    if (sockfd == -1) {
        perror("Error creating socket");
        return -1;
    }

    memset(&servaddr, 0, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    servaddr.sin_port = htons(80);
    servaddr.sin_addr.s_addr = inet_addr(target_ip);

    // Connect to server
    if (connect(sockfd, (struct sockaddr*)&servaddr, sizeof(servaddr)) == -1) {
        perror("Error connecting");
        close(sockfd);
        return -1;
    }

    // Get local IP address
    struct sockaddr_in localaddr;
    socklen_t addrlen = sizeof(localaddr);
    getsockname(sockfd, (struct sockaddr*)&localaddr, &addrlen);
    char* ip = inet_ntoa(localaddr.sin_addr);

    printf("Your IP address is: %s\n", ip);

    close(sockfd);
    return 0;
}

int main(int argc, char* argv[]) {
    if (argc != 2) {
        printf("Usage: %s <target_ip>\n", argv[0]);
        return 1;
    }

    if (get_local_ip(argv[1]) == -1) {
        printf("Unable to retrieve IP address for %s.\n", argv[1]);
        return 1;
    }

    return 0;
}

you can compile it using gcc

gcc -o ip_checker ip_checker.c

Then run it:

iSH:~# ./ip_checker 8.8.8.8
Your IP address is: 192.168.123.101

But you don't actually need to enter an ip address, any number also work!

iSH:~# ./ip_checker 1
Your IP address is: 192.168.123.101

Here's my pre-compiled binary. ip_checker.zip

lurenJBD avatar Feb 12 '24 13:02 lurenJBD