in linux

Linux “ip” command Cheat Sheet

# add default gateway
ip route add default via $GATEWAY_IP

# add static route
ip route add $DST_NET via $GATEWAY_IP dev $DEV

# show routing table
ip route show

# add ip address to device
ip addr add $IP/$NETMASK dev $DEV

# remove ip address from device
ip addr del $IP/$NETMASK dev $DEV

# enable interface
ip link set $DEV up

# disable interface
ip link set $DEV down

Configure Static IP Address

To configure static IP Address, you need to update or edit network configuration file to assign a Static IP Address to a system.

Assign Static IP Address to eth0 interface editing configuration file /etc/network/interfaces to make permanent changes as shown below.

auto eth0
iface eth0 inet static
address 192.168.1.2
netmask 255.255.255.0
gateway 192.168.1.1

Next, restart network services.

# /etc/init.d/networking restart
$ sudo /etc/init.d/networking restart

 

UPDATE