- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Need to change gateway in Linux
Operating System - Linux
1819814
Members
2678
Online
109607
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2011 12:01 AM
тАО02-02-2011 12:01 AM
Hi Gurus,
I need to change the gate way in my linux box.
root @up-p03:~# uname -a
Linux up-p03 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
root @up-p03:~# more /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
root @up-p03:~#
Pls guide me the procedure to o it in a production Box.
Do reboot needed?
what are the files needed to modify?
any services needed to restarted?
many thanks for your help.
Rgds
Sree
I need to change the gate way in my linux box.
root @up-p03:~# uname -a
Linux up-p03 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
root @up-p03:~# more /etc/redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
root @up-p03:~#
Pls guide me the procedure to o it in a production Box.
Do reboot needed?
what are the files needed to modify?
any services needed to restarted?
many thanks for your help.
Rgds
Sree
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2011 04:08 AM
тАО02-02-2011 04:08 AM
Solution
The default gateway is normally configured in either the global network configuration file /etc/sysconfig/network or in one of the interface-specific configuration files, named like /etc/sysconfig/ifconfig-*.
If your gateway is 11.22.33.44, you'll find a setting:
GATEWAY=11.22.33.44
in one of the above-mentioned files.
If you only change the GATEWAY= line in the file, the change would take effect only after you reboot the system or run ifdown & ifup on the appropriate network interface.
To make the change immediately, you must also use the "route" command to change the current gateway. For example, to change the gateway immediately from 11.22.33.44 to 22.33.44.55:
route del default gw 11.22.33.44
route add default gw 22.33.44.55
If you only use the "route" command, the gateway will be changed, but your change will be lost the next time the system is rebooted. So you must *both* use the route command to make the actual change, *and* edit the configuration file so that the change will be permanent.
If only the gateway is changed (and the host IP address and netmask will stay as-is), the change can be made without restarting any services.
You should not make this change over a regular SSH/telnet/rlogin etc. connection, as deleting the old default gateway may break your session. A remote console system like iLO uses a separate network interface at the hardware level, so it would be safe to use.
A reboot is not strictly _necessary_, but very much recommended: it ensures any connections that are interrupted by the gateway change are cleaned up, and it confirms the new gateway is correctly configured.
MK
If your gateway is 11.22.33.44, you'll find a setting:
GATEWAY=11.22.33.44
in one of the above-mentioned files.
If you only change the GATEWAY= line in the file, the change would take effect only after you reboot the system or run ifdown & ifup on the appropriate network interface.
To make the change immediately, you must also use the "route" command to change the current gateway. For example, to change the gateway immediately from 11.22.33.44 to 22.33.44.55:
route del default gw 11.22.33.44
route add default gw 22.33.44.55
If you only use the "route" command, the gateway will be changed, but your change will be lost the next time the system is rebooted. So you must *both* use the route command to make the actual change, *and* edit the configuration file so that the change will be permanent.
If only the gateway is changed (and the host IP address and netmask will stay as-is), the change can be made without restarting any services.
You should not make this change over a regular SSH/telnet/rlogin etc. connection, as deleting the old default gateway may break your session. A remote console system like iLO uses a separate network interface at the hardware level, so it would be safe to use.
A reboot is not strictly _necessary_, but very much recommended: it ensures any connections that are interrupted by the gateway change are cleaned up, and it confirms the new gateway is correctly configured.
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-02-2011 11:24 PM
тАО02-02-2011 11:24 PM
Re: Need to change gateway in Linux
Hi Sree,
Please follow the instructions as mentioned by matti for adding a default gateway.
if you want to add route for a particular network then use the command
#iproute add via
to make this permanent edit the config file
/etc/sysconfig/network-scripts/route-ethX
network address/mask via gateway
Regards
Abushad
Please follow the instructions as mentioned by matti for adding a default gateway.
if you want to add route for a particular network then use the command
#iproute add
to make this permanent edit the config file
/etc/sysconfig/network-scripts/route-ethX
network address/mask via gateway
Regards
Abushad
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP