Red Hat / CentOS Linux Setting a Default Gateway
Q. How do I setup up a default Gateway for all interfaces (eth0 and eth1) under CentOS Linux 5?
A.There are different ways to setup TCP/IP hosts so that you can reach to remote destinations. The simplest one is to setup default gateway by modifying the /etc/sysconfig/network
Setup a default Gateway
Open /etc/sysconfig/network file:
# vi /etc/sysconfig/network
Setup GATEWAY={Router-IP}, if router IP is 74.86.49.129, type:
GATEWAY=74.86.49.129
Save and close the file. Here is my complete file:
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=wan.nixcraft.in
GATEWAY=74.86.49.129
You need to restart networking service:
# /etc/init.d/networking restart
Subscribe to our free e-mail newsletter or RSS feed to get all updates.
You can Email this page to a friend.
Related Other Helpful FAQs:
- Debian / Ubuntu Linux Setting a Default Gateway
- Linux setup default gateway with route command
- Ubuntu Linux Configure Gateway / Default Routing IP Address
- Linux creating or adding new network alias to a network card (NIC)
- Openbsd change, add or display default gateway
Discussion on This FAQ
Leave a Reply
We encourage your comments, and suggestions. But please stay on topic, be polite, and avoid spam. Thank you very much for stopping by our site!
Tags: centos linux, default gateway, network setup, networking service, router ip, setup default router ip, tcp ip



November 22nd, 2007 at 11:12 am
could we get a write-up on howto to do this on Debian also?
November 22nd, 2007 at 1:34 pm
Open /etc/network/interfaces and setup gateway parameter
Restart networking.
November 29th, 2007 at 1:39 pm
If you only do the editing in the /etc/network/interfaces file they will be overwritten at boot time.
Please edit /etc/sysconfig/network as described in the article as well.
You can allso set the gateway on each device by editing :
vim /etc/sysconfig/networking/devices/ifcfg-eth0
vim /etc/sysconfig/networking/devices/ifcfg-eth1
And changing the gateway declaration.
Alternativly you could use the util :
system-config-network (from both command line and X.)