|
||||||||||
|
|
||||||||||
NavigationMy posts on Twitter
|
iproute2 instead of ifconfig/routeFor many, The default command to work with To configure a host to use IP address 192.168.0.102, netmask 255.255.255.0 and default gateway 192.168.0.1, the "old" commands were: +-------------------------------------------------------------------------+ | Code Listing 5.1: | | Using ifconfig and route | +-------------------------------------------------------------------------+ | | |# ifconfig eth0 192.168.0.102 netmask 255.255.255.0 up | |# route add default gw 192.168.0.1 | | | +-------------------------------------------------------------------------+ Using +-------------------------------------------------------------------------+ | Code Listing 5.2: | | Using iproute2's ip command | +-------------------------------------------------------------------------+ | | |# ip address 192.168.0.102/24 dev eth0 | |# ip route add default via 192.168.0.1 | | | +-------------------------------------------------------------------------+ The syntax isn't all that difficult, is it? Let's take a look at our current routing table. With +-------------------------------------------------------------------------+ | Code Listing 5.3: | | Using route | +-------------------------------------------------------------------------+ | | |# route -n | |Kernel IP routing table | |Destination Gateway Genmask Flags Metric Ref Use Iface | |192.168.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 | |127.0.0.0 127.0.0.1 255.0.0.0 UG 0 0 0 lo | |0.0.0.0 192.168.0.1 0.0.0.0 UG 0 0 0 eth0 | | | +-------------------------------------------------------------------------+ With +-------------------------------------------------------------------------+ | Code Listing 5.4: | | Using ip to show the routing table | +-------------------------------------------------------------------------+ | | |# ip route show | |192.168.0.0/24 dev eth0 proto kernel scope link src 192.168.0.121 | |127.0.0.0/8 via 127.0.0.1 dev lo scope link | |default via 192.168.0.1 dev eth0 | | | +-------------------------------------------------------------------------+ You might find this output strange; however, it gives a lot of useful information. For instance, scope link means that the network is reachable while proto kernel informs us that the kernel has added this routing as part of bringing the interface up. Using ip within Gentoo isn't difficult either. The Gentoo +-------------------------------------------------------------------------+ | Code Listing 5.5: | | Configuring the network through /etc/conf.d/net | +-------------------------------------------------------------------------+ | | |(Old-style configuration) | |config_eth0=( "192.168.0.102 netmask 255.255.255.0" ) | |routes_eth0=( "default gw 192.168.0.1" ) | | | |(Using iproute2 -- don't forget to emerge it first) | |modules=( "iproute2" ) | |config_eth0=( "192.168.0.102/24" ) | |routes_eth0=( "default via 192.168.0.1" ) | | | +-------------------------------------------------------------------------+ Note: For more That's it for now; have fun with Gentoo ! |
|
||||||||
| © Copyleft 2005-2011 - Lode Vanstechelman - Login | ||||||||||