PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

C program for getting IP address of standlone box with no sockets 7162


Your Ad Here

Your Ad Here

What do you mean by a "standalone box"? If it has no network connections, then its only IP address is 127.0.0.1.

How would it even work? If eth0 is not connected, it will not appear in ifconfig eth0.

E.g., on the machine for these, eth0 is configured and connected, and ppp0 is configured, but not connected.

C program for getting IP address of standlone box with no sockets 7163
the Black Sun and said: What? If you're going to call ifconfig, why not just use popen()? FILE *FP; char buff1024; FP=popen("-sbin-ifconfig bin-grep inetaddr","r"); if(!FP){ barf("popen...
Escaping backslash programming question
You'll need to create a new file anyway. If all you want to do is delete that line... mvtmp-tempfileetc-syslog.conf Will do it. :-) You might...

$sbin-ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:90:27:42:12:75 inet addr:192.168.42.242 Bcast:192.168.42.255 Mask:255.255.255.0 inet6 addr: fe80::290:27ff:fe4f:1275-64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:122511 errors:0 dropped:0 overruns:0 frame:0 TX packets:141923 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 $sbin-ifconfig ppp0 ppp0: error fetching interface information: Device not found

So, at least on relatives of Red Hat distributions, you would need to look in

etc-sysconfig-networking-devices and do something like

grep IPADDR *

On my machine, I can see something like this (slightly fudged):

-etc-sysconfig-networking-devices# grep IPADDR * ifcfg-eth0:IPADDR=192.168.41.241 ifcfg-eth1:IPADDR=192.168.42.241 ifcfg-myISP:IPADDR=62.42.129.141

So if you look at your system, you will see the names it uses for these interfaces, and all your running program would need to do is open the right one and parse it slightly.

Try something like

man 3 opendir

Linux Security 7166
If you run redhat-fedora there is a program system-config-securitylevel you can use to configure a firewall rather easily...

to open that directory and search for the one you want (if you do not know its name), or just open the one you want if you do know its name. Then parse it for IPADDR and pick up what you need.

Nuts. You should be able to read most of those files in

etc-sysconfig-networking-devices

The only one needing root access would be the ppp* one, but you could open that one safely if you open it for read only. Are you giving the program setuid? That could be unsafe if you do not want the program to divulge its information to a non-root user.

Even a standalone box has an interface, and its name is "lo". So

If the interface does not have a name, what good is it? Recall that your machine already has, for sure, interface "lo". So if you have any other interface, you must have a name for it or there would be no way it could ever be used.

Linux Security 7167
E11 It depends on what distribution you have used and how you installed it. Well, Robert Morris wrote a worm over 10 years ago that...

If you just give the host names to DNS, you could get lots of IP addresses. My machine has three IP addresses, one on ppp0, one on eth0, and one on eth1. How do you propose getting "the" IP address of a box if it has more than one?

-- .~. Jean-David Beyer Registered Linux User 85642. V PGP-Key: 9A2FC99A Registered Machine 241939. ^^-^^ 22:45:00 up 14 days, 9:15, 5 users, load average: 4.14, 4.19, 4.17



Your Ad Here

List | Previous | Next

C program for getting IP address of standlone box with no sockets 7163

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

XMMS & Scripts