954,525 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

how to add a default gateway ?

im new to shell scripting

i want a simle script to configure the ip adress and add a default gw

this is what i got so far

#!/bin/bash
    ifconfig eth0 "ipadress" 
    route add default gw "gw adress"


it does not recognise route ? can anyone help?

moroccanplaya
Junior Poster
178 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

What shows when you type

route -n

after running your script?

I have used the following before

#!/bin/bash

$IP="192.168.1.12"
$ROUTE="192.168.1.1"

ifconfig eth0 inet $IP netmask 255.255.255.0
route add default gw $ROUTE

liliafan
Junior Poster
117 posts since Apr 2004
Reputation Points: 66
Solved Threads: 3
 

thnx it worked?

moroccanplaya
Junior Poster
178 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You