Next Spaceship

Driving into future...

Configure Network Using Ifconfig and Route

| Comments

Setting up your network consists of three steps. First we assign ourselves an IP address using ifconfig. Then we set up routing to the gateway using route. Then we finish up by placing the nameserver IPs in /etc/resolv.conf.

1

To assign an IP address, you will need your IP address, broadcast address and netmask. Then execute the following command, substituting ${IP_ADDR} with your IP address, ${BROADCAST} with your broadcast address and ${NETMASK} with your netmask:

1
# ifconfig eth0 ${IP_ADDR} broadcast ${BROADCAST} netmask ${NETMASK} up

2

Now set up routing using route. Substitute ${GATEWAY} with your gateway IP address:

1
# route add default gw ${GATEWAY}

3

Now open /etc/resolv.conf with your favorite editor (in our example, we use nano):

1
# nano -w /etc/resolv.conf

Now fill in your nameserver(s) using the following as a template. Make sure you substitute ${NAMESERVER1} and ${NAMESERVER2} with the appropriate nameserver addresses:

nameserver ${NAMESERVER1}
nameserver ${NAMESERVER2}

Comments