I have just finished two advanced Linux classes in my BS in IT(straight
A's). I have been working with various virtual machines. THrough the
process of setting up A DHCP,Firewall,Name server, and Time server, (each
with a secondary server for redundancy) I have had to learn  about the
networking interfaces. I am sharing what I have learned.
Linux IP Utility

The ip utility has replaced the ifconfig command. The ip command can set

interfaces attributes, manage arp tables, perform routing commands, read
neighbor tables, set site specific routing rules, Vlan specific, and host
specific addresses.

man ip

ip - show / manipulate routing, devices, policy routing and tunnels ip [
OPTIONS ] OBJECT { COMMAND | help }

Using IP
By using aliasing for ip’s, the concept of a device having one ip address
is obsolete.

How to show the status of your interfaces.

ip link show

Setting your eth0 ip address[es].

ip addr add 192.168.1.21/24 dev eth0

You can see how this syntax matches the above definition od ip (OPTIONS [
addr add 192.x.x.x]) (OBJECT [ dev eth0 ])

Using these options we can set gateways, ip address, broadcast address and
much more. This is something you should make note of. In UNIX/Linux
devices are virtualized and can have more than one ip address and hardware
address. The ip command use the concept of scope for setting ip
address.Host scope,local scope for the LAN, and global for the globe.

Now lets look at our ARP cache(arp is the request sent out on the LAN to
find machines and resolve local machine name requests).

ip neigh show



You can add more names to your arp cache by pinging your neighbors on the
or by using ip neigh add 192.168.x.x dev eth0. You can use the delete
keyword in place of add to remove a neighbor from the arp cache.

This shows us our routing table.

ip route show

ip rule list will show you the default rule list “main”(old kernel rule
list)” “local”& “default” are new. From all main,local, and default.

ip route list table local

Shows the local table with the scope for the address from the ip rules.

Lets add a rule to the config for another computer. The config file is
/etc/iproute2/ ip_route. Perform a less command for that file to get a lay
of the routing table setup

enter this command set using the ; as a delimiter.

echo 666 BatChicken >> /etc/iproute2/rt_tables;ip rule add from (insert
your default gateway ip here) table BatChicken;

ip rule show

This has added a rule for BatChicken to rt_tables now lets generate the
table.

This part is a little tricky so pay attention.

ip route add default via 192.168.x.x dev ppp2 table BatChicken

The address is the address of your gateway on your network. Now clean the
cache.

ip route flush cache

Many people have issues with the incrementing of nic card values in a
Linux system. I use IP to fix this here is how.

If your cloning a VM use the VM to generate a new nic MAC. Then use ip
link sh dev eth3 to output only the ethx number you want to use. Then
append that to your eth0 interface configuration file. ip link sh dev eth3
>> /etc/sysconfig/network-scripts/ifcfg-eth0

then edit your HWADDR= line in your ifcfg-eth0





I hope by now you are starting to see the value of the ip utility.There
are many more advanced monitoring interface states, policies and more
inside the ip utility toolset way too much to be covered here.

How do you gather your interface information



ip addr sh

ip route sh

will show will show your route.

The important thing is to examine your Final line



default via 10.0.0.1 dev eth0



This line is your default gateway, and its address. It is this gateway
that will most likely be your DHCP server(router) as well. This matters
because the DHclient script writs to your /etc/resolv.config file.
DHclient updates your name server lines dynamicly. If you are looking to
use your own name servers  you can edit your ifcfg-ethx file by adding a
line like.

PEERDNS=no



This will stop DHclient from overwriting your /etc/resolv.config file. I
have tried using DHCP=no but DHclient still over writes resolv.config.



I hope this helps some people get to know the IP utility and Linux a
little better.