⬅️ **[[$-Linux|Linux]]**
***
# Linux - Network tools
see also [[$-Netzwerk]] für allgemein Infos
## Command / Config Overview
- [[Linux - Network - Netplan]]
```
netstat -nap | grep 8080
```
| File / Command | Description |
| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| uname -a | System information <br> `Linux goldeneye 2.6.32-504.el6.x86_64 #1 SMP Tue Sep 16 01:56:35 EDT 2014 x86_64 x86_64 x86_64 GNU/Linux` |
| hostname | Hostname from network settings <br> `goldeneye` |
| hostname -f | FQDN <br> `goldeneye.ab.cd.com` |
| /etc/hosts | IP and corresponding Hostname --> custom |
| /etc/environment | e.g. Proxy Settings <br> `http_proxy`, `https_proxy` |
| /etc/resolv.conf | DNS Server <br> `domain`, `nameserver`, `search` |
| /etc/sysconfig/network | **RedHat** Network Config <br>`NETWORKING`, `HOSTNAME`, `GATEWAY` |
| /etc/sysconfig/network-scripts/ifcfg-eth0 | **RedHat** Network Device Settings <br> `DEVICE`, `ONBOOT`, `NETWORK`, `NETMASK`, `IPADDR` |
| /etc/network/interfaces | **Debian** Network Device Settings |
| ifup / ifdown | Interface eth0, eth1, ... startup. Use ifconfig to see it. |
| iptables | iptables -L = List <br> iptables -F = flush all <br> service iptables save = save current settings to file <br> **RedHat** `/etc/sysconfig/iptables` |
| telnet 192.168.42.110 5901 | check if port is available and open from outside |
| netstat -ba > c:\temp\netstat.log | Who listens on port? |
| `netstat -an | find "5093"` | Listens someone? |
[Network Commands](http://javarevisited.blogspot.com/2010/10/basic-networking-commands-in-linuxunix.html)
## Overview
- finding host/domain name and IP address - hostname
- test network connection – ping
- getting network configuration – ifconfig
- Network connections, routing tables, interface statistics – netstat
- query DNS lookup name – nslookup
- communicate with another hostname – telnet
- outing steps that packets take to get to network host – traceroute
- view user information – finger
- checking status of destination host - telnet
## Commands
### hostname
- hostname with no options displays the machine's hostname
- `hostname –d` displays the domain name the machine belongs to
- `hostname –f` displays the fully qualified host and domain name
- `hostname –i` displays the IP address for the current machine
### ping
It sends packets of information to the user-defined source. If the packets are received, the destination device sends packets back. Ping can be used for two purposes
1. To ensure that a network connection can be established.
2. Timing information as to the speed of the connection.
If you do ping www.yahoo.com it will display its IP address. Use ctrl+C to stop the test.
### ifconfig
View network configuration, it displays the current network adapter configuration. It is handy to determine if you are getting transmit (TX) or receive (RX) errors.
### netstat
Most useful and very versatile for finding a connection to and from the host. You can find out all the multicast groups (network) subscribed by this host by issuing "netstat -g"
- `netstat -nap | grep port` will display process id of application which is using that port
- `netstat -a` or `netstat –all` will display all connections including TCP and UDP
- `netstat --tcp` or `netstat –t` will display only TCP connection
- `netstat --udp` or `netstat –u` will display only UDP connection
- `netstat -g` will display all multicast network subscribed by this host.
### nslookup
If you know the IP address it will display hostname. To find all the IP addresses for a given domain name, the command nslookup is used. You must have a connection to the internet for this utility to be useful, e.g.
`nslookup blogger.com`
You can also use the nslookup to convert hostname to IP Address and from IP Address from the hostname.
### traceroute
A handy utility to view the number of hops and response time to get to a remote system or website is traceroute. Again you need an internet connection to make use of this tool.
### finger
View user information, displays a user’s login name, real name, terminal name and write status. this is pretty old Unix command and rarely used nowadays.
### telnet
Connects destination host via the telnet protocol, if telnet connection establishes on any port means connectivity between two hosts is working fine.
`telnet hostname port`
### static routing
[Tutorial Statisches Routing](http://www.willemer.de/informatik/unix/tcproutb.htm)
### IP Tables / Firewall
[RedHat - Iptables](https://oracle-base.com/articles/linux/linux-firewall)
[IP Tables speichern](https://www.thomas-krenn.com/de/wiki/Iptables_Firewall_Regeln_dauerhaft_speichern)
[Debian/Ubuntu - Firewall](https://webprosa.de/howto-firewall-mit-iptables-unter-debian-oder-ubuntu-einrichten/)
#
***
Related:
- [[$-Netzwerk|Netzwerk]]