[ Enlarge Image ]  
 
 
<< Back 
Posted: 2006/03/29 by: fcruz. Linux - Unix Blogs.
Changing the gateway on a linux / unix server or machine without using a graphical interface is a very common task for network administrators, check the solution here.


How to Change Your Default Gateway

Your server needs to have a single default gateway. DHCP servers will automatically assign a default gateway to DHCP configured NICs, but NICs with configured static IP addresses will need to have a manually configured default gateway. This can be done with a simple command. This example uses a newly installed wireless interface called wlan0, most PCs would be using the standard Ethernet interface eth0.

 

[root@felo tmp]# route add default gw 192.168.1.1 wlan0

 

In this case, make sure that the router/firewall with IP address 192.168.1.1 is connected to the same network as interface wlan0!

Once done, you'll need to update your /etc/sysconfig/network file to reflect the change. This file is used to configure your default gateway each time Linux boots.

 

NETWORKING=yes
HOSTNAME=felo
GATEWAY=192.168.1.1

Some people don't bother with this step and just place the route add command in the script file /etc/rc.d/rc.local which is run at the end of each reboot.

It is possible to define default gateways in the NIC configuration file in the /etc/sysconfig/network-scripts directory, but you run the risk of inadvertently assigning more than one default gateway when you have more than one NIC. This could cause connectivity problems. If one of the default gateways has no route to the intended destination, every other packet will become lost. Firewalls that are designed to block packets with irregular sequence numbers and unexpected origins could also obstruct your data flow.






[ Back ]