Search code examples
unixnetwork-programmingipethernet

How to configure Ethernet interface with gateway IP address?


I have been asked to the following on a sample Unix server:

Configure eth1 to xxx.xx.xx.xxx/24 with gateway IP Address of: xxx.xx.xx.x

Any help would be welcome as I am a relative novice when it comes networking with Unix.


Solution

  • The route command is what you want, something like this:

    route add -net 192.168.3.0 netmask 255.255.255.0 gw 192.168.3.10
    

    This only adds it until networking is restarted or the machine is rebooted, so you will need to find where to add static routes like /etc/sysconfig/static-routes to add it permanently.