The ip command

Linux

The ip command is used to display or configure networking and to assign an address to a network interface on Linux operating systems. It replaces the ifconfig command now deprecated.

list all network interfaces and show all ip address associated

 ip a
or
ip addr

to specify one interface :

 ip a show eth0

Assign an IP address to an interface

ip a add {ip/mask} dev {interface}

example, assign 192.168.1.10 to eth0 :

ip a add 192.168.1.10/255.255.255.0 dev eth0
or
ip a add 192.168.1.10/24 dev eth0

Enable or disable the network device

ip link set dev eth0 down
ip link set dev eth0 up

Change the MTU to enable Jumbo Frames on Gigabit networks

The maximum transmission unit (MTU) defines the largest payload size of a packet that can be transmitted. The default value is set at 1500 bytes. Nevertheless, it is possible to allow for the transmission of more data and improve transfer rates by adjusting the MTU to 9000, which facilitates the utilization of Jumbo Frames.

ip link set mtu 9000 dev eth0

kernel routing table management

display the routing table

netstat -rn
or 
ip r
ip route

add a new route

ip route add {NETWORK/MASK} via {GATEWAYIP}

Add a plain route to network 192.168.1.0/255.255.255.0 via gateway 192.168.1.1:

ip route add 192.168.1.0/255.255.255.0 via 192.168.1.1

To route all traffic via 192.168.1.1 gateway on eth0 network interface :

ip route add 192.168.1.0/255.255.255.0 dev eth0
or
ip route add 192.168.1.0/24 via 192.168.1.1

Delete a route

ip route del 192.168.1.0/255.255.255.0 dev eth0

Change the mac address

ip link set dev eth0 down
ip link set dev eth0 address aa:bb:cc:dd:ee:ff
ip link set dev eth0 up

when using macchanger, the single command is :

macchanger -m aa:bb:cc:dd:ee:ff eth0

Previous Post Next Post