Você está na página 1de 5

CONFIGURE BASIC NETWORK SERVICES AND SETTINGS LINUX

LINUX NETWORK CONFIGURATION There are many network utilities in Linux that can be used to configure Ethernet ip address, netmask, routing table, name server and so on. Below are essential Linux commands used to configure Linux ip address. LINUX IFCONFIG COMMAND The Linux ifconfig command can be used to configure a network interface card or Ethernet card. If the Linux ifconfig command issued without any argument or option, it displays the status of the currently active interfaces.

NAME ifconfig - configure a network interface SYNOPSIS ifconfig [-v] [-a] [-s] [interface] ifconfig [-v] interface [aftype] options | address ... DESCRIPTION Ifconfig is used to configure the kernel-resident network interfaces. It is used at boot time to set up interfaces as necessary. After that, it is usually only needed when debugging or when system tuning is needed. If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down. Otherwise, it configures an interface.

COMPLETE USAGE SYNTAX:

Usage: ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>] [add <address>[/<prefixlen>]] [del <address>[/<prefixlen>]] [[-]broadcast [<address>]] [[-]pointopoint [<address>]] [netmask <address>] [dstaddr <address>] [tunnel <address>] [outfill <NN>] [keepalive <NN>] [hw <HW> <address>] [metric <NN>] [mtu <NN>] [[-]trailers] [[-]arp] [[-]allmulti] [multicast] [[-]promisc] [mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>] [txqueuelen <NN>] [[-]dynamic] [up|down] ... <HW>=Hardware Type. List of possible hardware types: loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP) slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP) strip (Metricom Starmode IP) ash (Ash) ether (Ethernet) tr (16/4 Mbps Token Ring) tr (16/4 Mbps Token Ring (New)) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel) ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB) arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device) sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI) irda (IrLAP) ec (Econet) x25 (generic X.25) eui64 (Generic EUI-64) <AF>=Address family. Default: inet List of possible address families: unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6) ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE) ipx (Novell IPX) ddp (Appletalk DDP) ec (Econet) ash (Ash) x25 (CCITT X.25)

IFCONFIG COMMAND INVOKE WITH NO OPTION EXAMPLE BELOW:

root@slackware:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:aa:11:bb:22:cc inet addr:10.10.0.6 Bcast:10.21.35.255 Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b) Interrupt:11 Base address:0x1080 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

The first paragraph above shows the first Ethernet card, eth0 configuration. The line in red shows Ethernet ip address, broadcast and netmask. The second paragraph shows localhost or loopback configuration.

THIS IS AN EXAMPLE ON HOW TO USE IFCONFIG COMMAND TO SETUP A NEW LINUX IP ADDRESS FOR THE FIRST ETHERNET CARD:

root@slackware:~# ifconfig eth0 192.168.1.5 netmask 255.255.255.0 up

LINUX ROUTE COMMAND After setting up a Linux ip address with ifconfig command, use Linux route command to set up static routes to specific hosts or networks. Linux route command is a tool where you can setup where to send which data. Basically you can use route command to show and manipulate routing table. This is an example of how to use route command in Linux. Issue route command without any option will print current routing table. To add a new ip route via eth0 (first Ethernet card), issue route add command in this format: route add -net <ip> netmask <ip> dev eth0

root@slackware:~# route add -net 192.168.1.0 netmask 255.255.255.0 dev eth0

You can also add a gateway of the network: route add -net <ip> gw <ip> netmask <ip> dev eth0

root@slackware:~# route add -net 192.168.1.0 gw 192.168.1.1 netmask 255.255.255.0 dev eth0

Now, check the routing table again:

root@slackware:~# route Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 192.168.1.0 * 255.255.255.0 U 0 0 0 eth0 loopback * 255.0.0.0 U 0 0 0 lo default 192.168.1.1 0.0.0.0 UG 1 0 0 eth0 root@slackware:~#

THAT'S IT, SAVE THE FILE AND RESTART RC.INET1 DAEMON. RUN THE 'IFCONFIG' COMMAND TO UPDATE THE NEW NETWORK CARD DATA.

root@slackware:~# ifconfig eth0 Link encap:Ethernet HWaddr 00:aa:11:bb:22:cc inet addr:192.168.1.5 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::223:cdff:feb4:9f1f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1895974 errors:0 dropped:28 overruns:0 frame:0 TX packets:411289 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:674815483 (643.5 MiB) TX bytes:73677358 (70.2 MiB) Interrupt:17 Base address:0xe800 eth1 Link encap:Ethernet HWaddr 33:aa:44:bb:55:cc inet addr:192.168.2.1 Bcast:192.168.2.255 Mask:255.255.255.0 inet6 addr: fe80::21b:fcff:fed3:e47f/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:332574 errors:0 dropped:35 overruns:0 frame:0 TX packets:470231 errors:0 dropped:0 overruns:0 carrier:8 collisions:0 txqueuelen:1000 RX bytes:64241167 (61.2 MiB) TX bytes:498941589 (475.8 MiB) Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:18 errors:0 dropped:0 overruns:0 frame:0 TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:980 (980.0 B) TX bytes:980 (980.0 B)

lo

root@slackware:~#

THE PING FORMAT IS PING <OPTION> <TARGET IP>:

root@slackware:~# ping -c3 192.168.1.5 PING 192.168.1.5 (192.168.1.5) 56(84) bytes of data. 64 bytes from 192.168.1.5: icmp_seq=1 ttl=64 time=0.200 ms 64 bytes from 192.168.1.5: icmp_seq=2 ttl=64 time=0.287 ms 64 bytes from 192.168.1.5: icmp_seq=3 ttl=64 time=0.290 ms --- 192.168.1.5 ping statistics --3 packets transmitted, 3 received, 0% packet loss, time 1998ms rtt min/avg/max/mdev = 0.200/0.259/0.290/0.041 ms root@slackware:~#

Você também pode gostar