Thursday, July 24, 2008

Network administration Commands

netconf
(as root) A very good menu-driven setup of your network.

pingmachine_name
Check if you can contact another machine (give the machine's name or IP), press C when done (it keeps going).

route -n
Show the kernel routing table.

nslookup host_to_find
Query your default domain name server (DNS) for an Internet name (or IP number) host_to_find. This way you can check if your DNS works. You can also find out the name of the host of which you only know the IP number.

traceroute host_to_trace
Have a look how you messages trave to host_to_trace (which is either a host name or IP number).

ipfwadm -F -p m
(for RH5.2, seen next command for RH6.0) Set up the firewall IP forwarding policy to masquerading. (Not very secure but simple.) Purpose: all computers from your home network will appear to the outside world as one very busy machine and, for example, you will be allowed to browse the Internet from all computers at once.

echo 1 > /proc/sys/net/ipv4/ip_forward
ipfwadm-wrapper -F -p deny
ipfwadm-wrapper -F -a m -S xxx.xxx.xxx.0/24 -D 0.0.0.0/0
(three commands, RH6.0). Does the same as the previous command. Substitute the "x"s with digits of your class "C" IP address that you assigned to your home network. See here for more details. In RH6.1, masquarading seems broken to me--I think I will install Mandrake Linux:).

ifconfig (as root) Display info on the network interfaces currently active (ethernet, ppp, etc). Your first ethernet should show up as eth0, second as eth1, etc, first ppp over modem as ppp0, second as ppp1, etc. The "lo" is the "loopback only" interface which should be always active. Use the options (see ifconfig --help) to configure the interfaces.

ifup interface_name (/sbin/ifup to it run as a user) Startup a network interface. E.g.:
ifup eth0
ifup ppp0
Users can start up or shutdown the ppp interface only when the right permission was checked during the ppp setup (using netconf ). To start a ppp interface (dial-up connection), I normally use kppp available under kde menu "internet".

ifdown interface_name (/sbin/ifdown to run it as a user). Shut down the network interface. E.g.: ifdown ppp0 Also, see the previous command.
netstat more Displays a lot (too much?) information on the status of your network.

Wednesday, July 23, 2008

Useful Net Commands for LINUX

Note: You MUST be at the ROOT user to make/save any changes. Linux users, your distribution will determine the location of your network config file which will need to be updated and saved in order for the changes to remain in effect after rebooting. Network cards are referred to as eth0, eth1, eth2, etc based on their position on the PCI bus. Display Current Config for all NIC's: ifconfig

Display Current Config for eth0: ifconfig eth0
Assign IP: ifconfig eth0 192.168.1.2
Assign IP/Subnet: ifconfig eth0 192.168.1.2 netmask 255.255.255.0
Assign Default Gateway: route add default gw 192.168.1.1
Assign multiple IP's: ifconfig eth0:0 192.168.1.2
Assign second IP: ifconfig eth0:1 192.168.1.3
Disable network card: ifconfig eth0 down
Enable network card: ifconfig eth0 up View current routing table: route "or" route -n
View arp cache: arp "or" arp -n
Ping: ping -c 3 192.168.1.1
Trace Route: traceroute www.whatismyip.com
Trace Path: tracepath www.whatismyip.com
DNS Test: host www.whatismyip.com
Advanced DNS Test: dig www.whatismyip.com
Reverse Lookup: host 66.11.119.69
Advanced Reverse Lookup: dig -x 66.11.119.69

Best Useful Commands

Display Connection Configuration : ipconfig /all
Display DNS Cache Info Configuration : ipconfig /displaydns
Clear DNS Cache : ipconfig /flushdns
Release All IP Address Connections : ipconfig /release
Renew All IP Address Connections : ipconfig /renew
Re-Register the DNS connections : ipconfig /registerdns
Change/Modify DHCP Class ID : ipconfig /setclassid Network Connections: control netconnections
Network Setup Wizard : netsetup.cpl
Test Connectivity : ping www.whatismyip.com
Trace IP address Route : tracert
Displays the TCP/IP protocol sessions : netstat
Display Local Route : route
Display Resolved MAC Addresses : arp
Display Name of Computer Currently on: hostname
Display DHCP Class Information : ipconfig /showclassid