us network and Uuntu 8.10 - is there a better way?

Joel Newkirk freerunner at newkirk.us
Fri Dec 26 19:55:11 CET 2008


On Fri, 26 Dec 2008 16:47:46 +0100, "Torfinn Ingolfsen" <tingox at gmail.com>
wrote:

> Thanks!
> It seems that it still works by using the ifdown / ifup scripts.
> annoying that good old ifconfig doesn't work anymore, but I can live
> with that.
> 
>> PS And consider using "ip addr" and friends instead of venerable
>> "ifconfig". "ip" command is newer way of operating network
>> interfaces.
> 
> Hmm, I found that one. What's up with that? Whay are they changing the
> established way of doing things?
> AFAICT, the ip command is a Linuxism.
> Not everything is better just because it is new.

It's not exactly new, "ip" has been around since kernel 2.2. (ten years?
Early 1999 IIRC)  "ip" together with "tc" (Traffic Control) comprise
iproute2 and expose a vast array of networking options within the kernel,
including basic networking setup but also various advanced routing
scenarios like tunnels, multiroute setups, route failovers, bandwidth
management, etc.  Basically use iptables/ip6tables/arptables/ebtables for
firewall, tc for bandwidth management, ip for everything else networking.

If you're interested in what it offers beyond basic network controls take a
look at lartc.org - Linux Advanced Routing & Traffic Control.  They have
the manpages and primary documentation as well as extensive tutorials and
howtos, cookbook for things like a gateway router load-balancing multiple
uplinks (IE dual T1), 'wondershaper' bandwidth management script, etc.

As far as the basics, "ip route add default via 10.11.12.254 dev eth0
metric 20", "ip link set eth0 down" (=="ifconfig eth0 down"), "ip address
add 192.168.0.202/30 dev usb0" are some examples of common tasks.  Almost
all keywords can be abbreviated, leading to "ip l s eth0 up" and "ip a a
192.168.0.202/30 dev usb0" for example, and other portions can be omitted
sometimes, like "ip r a default via 10.11.12.254" which will determine the
interface needed for the given gateway and use default metric. (more
advanced, "ip tunnel add netb mode gre remote 172.19.20.21 local
172.16.17.18 ttl 2" would try to create a GRE tunnel to 172.19.20.21 named
"netb")

When you use "ip a a 192.168.0.202/30 dev usb0" to set that IP and subnet
on device usb0 it also implicitly performs "ip route add 192.168.0.202/30
dev usb0 src 192.168.0.202 table 254" (254="main")

On the informative rather than configuration side of things, "ip a" shows
all interfaces with their statuses and their addresses/subnets (ipv4, ipv6
and MAC), "ip r" shows main routing table (short for "ip route show table
main", "ip r s t local" shows the "local" routing table, etc - uses numbers
for tables, or names if they're defined in /etc/iproute2/rt_tables), "ip n"
shows neighbor table with IP, MAC, interface and status, "ip ru" shows
routing rules ("ip rules show"), which specify which routing table to use
for various conditions.


j

PS - be aware that the "ip" functions in busybox are a small subset of the
full command's capabilities - everything is still there in the kernel, but
busybox doesn't expose much of it.

-- 
Joel Newkirk
http://jthinks.com      (blog)
http://newkirk.us/om (FR stuff)





More information about the community mailing list