I'm trying to configure the network interface on embedded linux using ifconfig:

ifconfig eth0 netmask

but I don't know how to add the default gateway as an ifconfig parameter,

Any Ideas?

  • Please specify which embedded Linux you are using. – Rui F Ribeiro Feb 1 '16 at 11:24

ifconfig is not the correct command to do that.

You can use route like in route add default gw for example.

And if route is not present, but ip is, you can use it like this: ip route add default via dev eth0, assuming that is the ip of your gateway

  • 1
    ip should be the first choice.ip r add default via [gw]. – prosti Sep 24 '18 at 12:02

ifconfig is deprecated on Linux and furthermore, it's the wrong tool for the job. To set the default gateway on Linux use the ip command as follows:

ip route add default via <host> dev <dev>

# e.g.
ip route add default via dev eth0

Using route

route add default gw {IP-ADDRESS} {INTERFACE-NAME}

example: route add default gw eth0

OR use hostname such as dsl-router:

route add default gw dsl-router eth0 

Or use the ip command (newer syntax) to route all traffic via gateway connected via eth0 network interface for example:

ip route add dev eth0


ip route add via

For remove gateway in Linux Command : route delete default gw eth1

For add gateway in Linux Command : route add default gw eth1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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