Assuming you want to make the following changes to the network device eth0
- Change the
IP
to thestatic
value192.168.1.2
- Set the
Subnet Mask
to255.255.255.0
- Set the
Default Gateway
for the device to be192.168.1.1
you can perform these changes using the following two commands
sudo ifconfig eth0 192.168.1.2 netmask 255.255.255.0; sudo route add default gw 192.168.1.1 eth0;
ifconfig
ifconfig
is an application that allows you to configure a network interface.
It is used to configure the kernel-resident network interfaces. and it is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed.
If no arguments are given, ifconfig
displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a
argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface.
route
route
is an application that allows you to show and manipulate the IP routing table
. The primary use of route
is to set up static routes
to specific hosts or networks via an interface after it has been configured with the ifconfig
program.
When the add
or del
options are used, route modifies the routing tables. Without these options, route displays the current contents of the routing tables.