connect to internet if a gateway is known

October 15th, 2006 mysurface Posted in ifconfig, Network, route | Hits: 30180 | No Comments »

To check for your IP, you can type


It gives very detail information regarding your network interfaces. For linux, network interface is always eth0, eth1 etc, but for BSD, network interface can be any name. If in the case you doesn’t have any IP for your network interface, and you are given a gateway to connect. You can use ifconfig to configure a static IP for your network interface.

Let say, your network interface is eth0, your gateway is and your network is ( that means your network mask is ). You need to configure an IP for you network interface, then adding a default gateway.

Configure your static IP, let say,

ifconfig eth0 netmask up

Now check whether the IP is configured,

ifconfig eth0

Once it conplete, now add a default gateway using route.

route add default gw

The way of IP configuration and adding route might be different from Linux to BSD and other variant of Unix, check the manual for more.

To check the default gateway is it added, type this



netstat -nr

You will get a line from netstat -nr looks like bellow, ( for linux only)         UG        0 0          0 eth0

Leave a Reply