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. Feb 1, 2016 at 11:24

4 Answers 4


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

  • 3
    ip should be the first choice.ip r add default via [gw].
    – prosti
    Sep 24, 2018 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

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

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


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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .