How to set gateway address to a particular interface?

How to set gateway address to a particular interface? waht are the files need to update to make it permanent?

What do you mean by "a particular interface"? Do you have multiple interfaces?

The easy answer is to edit or create the file /etc/defaultrouter and insert the address of the default router (gateway). This file is ascii and editable and should contain just an ip address of the router and nothing else (first line of file, left justified). This change would be permanent.

For example:

131.156.202.6

Does that help (or did you already know that)?

The default router will need to be directly available from any Network Interface Card (NIC) that uses it. If you have:-

NIC 0  - IP 123.100.100.30, Netmask 255.255.255.224
NIC 1  - IP 168.100.100.30, Netmask 255.255.0.0
NIC 2  - IP 123.100.100.230, Netmask 255.255.255.224

...and you set the default router as 123.100.100.1 , then all the traffic will route through NIC 0 as that is the only one that can get to it. Even NIC 2 on the similar range will be ignored.

What are you trying to achieve? Do you want to have multiple 'default' routes? It is possible, but then you don't know what route will be used for any connection and you end up writing many more firewall rules.

Robin
Liverpool/Blackburn
UK