Monday, August 29, 2011

Adding default Gateway in Linux SUSE


Changing the default route permanently in SuSe Linux
To make 192.168.2.1 as default route, add the following line into /etc/sysconfig/network/routes file. (Create a file if it does not exist.)

default 192.168.2.1 - -

Syntax: default xxx.xxx.xxx.xxx - -

Linux route add using route command
Route all traffic via 192.168.1.254 gateway connected via eth0 network interface:
# route add default gw 192.168.1.254 eth0

Linux route add using ip command
Just like above but with ip command:# ip route add 192.168.1.0/24 dev eth0
 route add -net default gw gateway_ip_address


Change IP address
You can change ip address using ifconfig command itself. To set IP address 192.168.1.5, enter command:# ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up
# ifconfig eth0