Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

For some reason everytime I connect to my VM I have to manually launch these two commands for it to connect to the Internet.

route add 198.245.49.254 dev eth0
route add default gw 198.245.49.254

Is there a way I can automate this so that I don't have to do this manually every time?

share|improve this question
    
1  
the the machines ip address dhcp or static? –  chaos Dec 28 '13 at 20:48
3  
Please give us some more information. What OS is the VM running, CentOS? Do you have root access to it? –  terdon Dec 28 '13 at 20:50
    
Please post the output of ip address show and ip route show from within your VM before you enter these commands. –  Bananguin Dec 28 '13 at 23:40

1 Answer 1

up vote 1 down vote accepted

You can create an /etc/sysconfig/network-scripts/route-eth0 file with the content like this if you use multiple routes:

default via 192.168.0.1 dev eth0
10.10.10.0/24 via 192.168.0.1 dev eth0
172.16.1.0/24 via 192.168.0.1 dev eth0

For the default gateway you need to add this line :

GATEWAY=198.245.49.254

To the file /etc/sysconfig/network

Link: https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-networkscripts-static-routes.html

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.