08-17-2010
Set host default gateway in C program.
Hello everybody,
I'm having troubles on setting the default gateway address (and other addresses, such as netmask, or ip) of the host running a C program. I know it has to be with ioctl, but don't know how to do it.
Could somebody give me an example on how to set the default gateway address of a determinated device from the C program?
Any comment will be of help,
Thanks.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I want to end a host (shell script based) concurrent program in WARNING. Is it possible? Tried out a few things but it just either ends in NORMAL or ERROR. :confused:
Any ideas/inputs would be appreciated.
Thanks,
coolblue_3 (2 Replies)
Discussion started by: coolblue_3
2 Replies
2. UNIX and Linux Applications
hi, linux gurus...
i'm trying to write a script in ksh called ResetPass that allows a user to change mysql passwords. the script accepts user, password and host like this: ResetPass <user> <password> <host>. here's the code:
*****************************************************
mysql... (1 Reply)
Discussion started by: ankimo
1 Replies
3. Shell Programming and Scripting
I have my Mac OS X program executing a shell script (a script that copies files to a drive). I want to make it so that the shell script automatically kills itself if it finds that the host .app is not running OR kill itself if the drive that it is copying files to has been unmounted. Right now what... (2 Replies)
Discussion started by: pcwiz
2 Replies
4. Programming
I need to know what is the maximum stack size i.e. -Xss my java program is running with.
Is there a way to find that out from inside my java program code and outside of it.
What i am looking for is to read whatever the current set max limit -Xss (stack sie) is for a particular JVM(not... (3 Replies)
Discussion started by: mohtashims
3 Replies
5. Solaris
How to set gateway address to a particular interface? waht are the files need to update to make it permanent? (2 Replies)
Discussion started by: Naveen.6025
2 Replies
6. Shell Programming and Scripting
Can anyone suggest a workaround
zone_5.org='/qaz/qwe/path/tns.osn'
output
/home/bingo/XXX_script.sh: line 180: zone_5.org=/qaz/qwe/path/tns.osn: no parent
The path does not exist on the local machine, the allocation used to work till the server was upgraded.
Red Hat Enterprise Linux... (2 Replies)
Discussion started by: squrcles
2 Replies
7. Red Hat
I have an Oracle Linux 7.1 vsphere host built. It's be preconfigured with our security configurations.
What I would like to do is unconfigure this host. Then set the host to do firstboot --reconfigure.
how do I do that using /etc/sysconfig/firstboot?
I've tried setting
... (10 Replies)
Discussion started by: os2mac
10 Replies
8. Shell Programming and Scripting
Hi All,
I have a requirement to make a oracle concurrent program end with
warning based on a given condition. If the condition is true, the
concurrent program should end with completed warning status.
The host program I am using is a shell script that checks if a file exists.
... (2 Replies)
Discussion started by: megha2525
2 Replies
9. Red Hat
Hi all,
i have a rhel 6.2 with a default gateway.
This server is an Intranet office with no internet access.
DNS are already configured and it's possible to resolve my target.
My goal is to link my application (apache forward) only to http://mytarget.yyy through a new gateway (That does... (0 Replies)
Discussion started by: kamose
0 Replies
10. UNIX for Beginners Questions & Answers
Dear friends
I use RedHat 6.5, which sets the gateway in the configuration file / etc / sysconfig / network as GATEWAY = 192.168.1.26, and the gateway in the configuration file / etc / sysconfig / network-scripts / ifcfg-eth11 as GATEWAY = 192.168.1.256. The two gateways are different.... (6 Replies)
Discussion started by: tanpeng
6 Replies
DHCPING(8) General Commands Manual DHCPING(8)
NAME
dhcping - send a DHCP request to DHCP server to see if it's up and running
SYNOPSIS
dhcping [-v] [-q] [-i] [-r] -t maxwait -c client-IP-address -s server-IP-address -h client-hardware-address [-g gateway-IP-address]
DESCRIPTION
This command allows the system administrator to check if a remote DHCP server is still functioning.
Options are:
-v Verbose, print some information.
-i Use DHCPINFORM packets.
-r Use DHCPREQUEST packets (default behaviour).
-q Quiet, print nothing on the screen.
-t maxwait
Maximum time to wait for an answer from the server in seconds. Default is 3 seconds.
-c client-IP-address
Request this IP address. Note that this is also the IP address the answer will be sent to.
-s server-IP-address
Send the DHCP packet to this IP address.
-h client-hardware-address
Use this hardware-address in the DHCP request. It can be up to sixteen octets seperated by colons (i.e. 01:02:03:04)
-g gateway-IP-address
Use this IP address for the gateway IP address in the DHCP packet. This option is currently broken.
RETURN VALUES
If everything goes okay, it returns 0. If there went something wrong, it returns 1.
SETUP
This program should be installed setuid root or ran by root only. See SECURITY for more information.
On your DHCP server, add these lines to the dhcpd.conf:
host <your monitoring host FQDN> {
hardware ethernet <your monitor host mac address>;
fixed-address <your monitoring host IP address>;
}
Then try it:
$ dhcping -c your monitoring host IP address
-s your DHCP server IP address
-h your monitor host mac address
It will either respond with "no answer" or "Got answer from: your DHCP server IP address"
The DHCP server logfile will give:
DHCPREQUEST for 192.168.1.1 from 00:20:18:56:29:8f via ed0
DHCPACK on 192.168.1.1 to 00:20:18:56:29:8f via ed0
DHCPRELEASE of 192.168.1.1 from 00:20:18:56:29:8f via ed0 (found)
Running in DHCPINFORM mode with -i:
If you see "DHCPINFORM from 192.168.1.1 via xl0: not authoritative for subnet 192.168.1.0", you should add the authoritative statement to
the subnet, See dhcpd.conf(5) for details.
When running in very verbose mode, dhcping tries to dump all data of the send and received DHCP packets. It will first dump the packet in
hex-format, then decodes the header and finally the options.
HOW IT WORKS
The client either sends a DHCPREQUEST or DHCPINFORM packet to the server and waits for an answer. Then, if a DHCPREQUEST was send, it will
send a DHCPRELEASE back to the server.
SECURITY
This program is installed setuid root as it requires the privileges to bind itself to port 68 (bootpc). Root privileges are dropped as soon
as the program has bound itself to that port.
BUGS
Currently (this may, or may not, change in the future) the ISC DHCP daemon does not write leases with a fixed IP address in the
dhcpd.leases file.
DHCPINFORM packets can only be used on subnets the server is authori- tative for. If the monitoring script runs on a subnet the server
isn't authoritative for, it should use the DHCPREQUEST packets. I also experienced some problems with ISC DHCPD v2 servers, but that is
also in the README of it.
The -V option is still working, but shouldn't be used for debugging of the packets. Better use dhcpdump(8) for that, which is available on
my website. I wanted to remove it, but decided only to do it from the documentation, not from the code. Maybe I'll need it one day for
debugging.
AUTHOR
Edwin Groothuis, edwin@mavetju.org (http://www.mavetju.org)
SEE ALSO
dhcpd(8), dhclient(8), dhcpd.conf(5), dhcpdump(8)
Januari 27, 2002 Januari 27, 2002 DHCPING(8)