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
route(8c) route(8c)
Name
route - manually manipulate the routing tables
Syntax
/etc/route [ -f ] [ -n ] command args ]
Description
The program is used to manipulate the network routing tables manually. However, normally it is not needed, as the system routing table
management daemon, should tend to this task.
The program accepts two commands: add, to add a route and delete, to delete a route.
All commands have the following syntax:
/etc/route command [ net | host ] destination gateway [ metric ]
In this syntax, destination is a host or network for which the route is to, gateway is the gateway to which packets should be addressed,
and metric is an optional count indicating the number of hops to the destination. The metric is required for add commands. It must be
zero if the destination is on a directly-attached network, and nonzero if the route utilizes one or more gateways.
When adding a route with metric 0, the gateway given is the address of this host on the common network, indicating the interface to be used
for transmission. Routes to a particular host are distinguished from routes to a network by interpreting the Internet address associated
with destination. The optional keywords net and host force the destination to be interpreted as a network or host, respectively. If the
destination has a local address part of INADDR_ANY, then the route is assumed to be to a network. Otherwise, it is presumed to be a route
to a host. If the route is to a destination connected via a gateway, the metric should be greater than 0. All symbolic names specified
for a destination or gateway are looked up first as a host name using If this lookup fails, is then used to interpret the name as that of a
network.
The command uses a raw socket and the SIOCADDRT and SIOCDELRT ioctls to do its work. As such, only the superuser can modify the routing
tables.
Options
-f Flushes the routing tables of all gateway entries. If is used with one of the commands described above, the tables are flushed prior
to the command's application.
-n Prevents attempts to print host and network names symbolically when reporting actions.
Restrictions
The change operation is not implemented. Therefore, you should first add the new route, and then delete the old one.
Diagnostics
add [host | network] %s: gateway %s flags %x"
The specified route is being added to the tables. The values printed are from the routing table entry supplied in the ioctl call. If the
gateway address used was not the primary address of the gateway (the first one returned by the gateway address is printed numerically as
well as symbolically.
delete [ host | network] %s: gateway %s flags %x
The specified route is being deleted from the tables. The values printed are from the routing table entry supplied in the ioctl call. If
the gateway address used was not the primary address of the gateway (the first one returned by the gateway address is printed numerically
as well as symbolically.
%s %s done
When the flag is specified, each routing table entry that is deleted is indicated with a message of this form.
Network is unreachable
An attempt to add a route failed because the gateway listed was not on a directly-connected network. The next-hop gateway must be given.
not in table
A delete operation was attempted for an entry which was not present in the tables.
routing table overflow
An add operation was attempted, but the system was low on resources and was unable to allocate memory to create the new entry.
See Also
intro(4n), routed(8c)
route(8c)