Sei sulla pagina 1di 2

Linux Networking Commands

--------------------------------------------------------------------------------
Configuring a Network Interface Card
If NIC is detected during installation, the required modules are normally automa
tically configured
Some NICs are not automatically detected and must be configured manually
Drivers are usually modules that are inserted into the kernel
/lib/modules is the default location for NIC driver modules
insmod or modprobe are the commands to insert modules into the kernel
To load this module at boot time, you must edit the /etc/modprobe.conf file
/etc/modprobe.conf file assigns an alias to the module since it is in the kernel
and not in the /dev directory
eth0 is the alias for the first ethernet NIC, eth1 is the alias for the second e
thernet NIC
alias eth0 ne2k-pci would be the command entered into the /etc/modprobe.conf fil
e to load the driver for first NE2000 PCI NIC card
alias eth1 ne2k-pci would be the command to load the driver for the second NE200
0 PCI NIC card
The ifconfig command
ifconfig is the command to view configuration of all network interfaces
the interface labeled lo is the loopback address 127.0.0.1 when using the ifconf
ig command
netstat -i command can also be used to show interface statistics
netstat -rn command can be used to find the gateway
ifconfig can also be used to assign a TCP/IP configuration. for example:
ifconfig eth0 92.10.20.7 netmask 255.0.0.0 broadcast 92.255.255.255 will assign
the first ethernet card the IP address of 92.10.20.7 with a subnet mask of 255.0
.0.0 and broadcast address of 92.255.255.255
These values work only while the system is running.
Type dhclient to get back your original IP number from dhcp server
If you want the values to apply each time you boot, you need to edit the /etc/sy
sconfig/network-scripts/ifcfg-eth0 file
The /etc/sysconfig/network-scripts/ifcfg-eth0 file can be used to configure othe
r protocols such as IPX/SPX
You do not have to reboot to make the configurations active
ifdown eth0 removes the old configuration
ifup eth0 configures the eth0 interface by using the settings in the /etc/syscon
fig/network-scripts/ifcfg-eth0 file
dhclient command will get an IP address from the DHCP service
The packet Internet groper (ping) command
ping command can be used to test the network configurations
ping sends a small TCP/IP packet to another computer and waits for the other com
puter to respond
ping continues to send packets until Control+C is pressed
ping -c 5 127.0.0.1 will send only five packets to the loopback address
If the ping command fails to receive packets from 127.0.0.1 then there is a prob
lem with the TCP/IP configuration
ping -c 4 92.10.20.7 can be used to test your own NIC if you had it configured f
or 92.10.20.7
ping -c 4 92.0.0.1 can be used to test the gateway setup in the above table
Click on File and then Save to save the changes to the /etc/sysconfig/network-sc
ripts directory
Other commands and files
/etc/resolv.conf file specifies the address of the name server
passwords used to connect to the ISP are stored in /etc/ppp/pap-secrets and /etc
/ppp/chap-secrets
Working with DNS
to view or set the host name, use the host name command
to view or configure the hostname use the /etc/sysconfig/network file
to set a host name, type host name computer1.sampledomain.com and then type host
name to see the new name
to use the new host name each time the computer boots up, then edit the HOSTNAME
field in /etc/sysconfig/network file
the /etc/hosts file maps host names to IP addresses
the IP addresses of the DNS servers are specified in the /etc/resolv.conf file
to find the IP address of the pioneerpacific.edu domain you can use nslookup pio
neerpacific.edu or host pioneerpacific.edu
The order that a host name is resolved is located in the /etc/nsswitch.conf file
the line that starts with hosts: indicates that the search should start with fil
es (/etc/hosts file) and then dns (/etc/resolv.conf)
older Linux computers used the file /etc/host.conf instead of the file /etc/nssw
itch.conf

Potrebbero piacerti anche