Difference between revisions of "Networking"

From wiki
Jump to navigation Jump to search
m
(8 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[category:networking]]
+
[[Category:networking]]
 +
[[Category:Linux/Unix]]
 +
 
 
==Check network connections==
 
==Check network connections==
  
Line 15: Line 17:
 
;<code>curl -vvv telnet://<IP>:<port></code>
 
;<code>curl -vvv telnet://<IP>:<port></code>
 
:Just test connectivity to a port
 
:Just test connectivity to a port
 +
 +
<syntaxhighlight lang=bash>
 +
#!/bin/bash
 +
 +
PORT=$1
 +
 +
TARGETS="999.999.999.999
 +
888.888.888.888
 +
777.777.777.777
 +
666.666.666.666
 +
"
 +
 +
for TARGET in ${TARGETS}
 +
do
 +
  curl  http://${TARGET}:${PORT} --connect-timeout 1 > /dev/null 2>&1
 +
  if [ $? == 28 ]
 +
  then
 +
    echo No connection to ${TARGET}:${PORT}
 +
  fi
 +
done
 +
</syntaxhighlight>
  
 
===Wget===
 
===Wget===
Line 20: Line 43:
 
:Get the data from <URL>
 
:Get the data from <URL>
  
===openssl===
+
===[[OpenSSL]]===
;<code>openssl s_client -showcerts -connect <IP>:443</code>
+
See the [[OpenSSL]] page
:Test SSL connection
+
 
 +
==Interfaces==
 +
;ifconfig -a
 +
:Show all network interfaces
 +
 
 +
;ifconfig <interface> <ipaddrss>
 +
:Assign <ipaddress> to <interface>
 +
 
 +
;mii-tool <interface>
 +
:Show interface link status (speed)
 +
 
 +
;The interfaces file
 +
<syntaxhighlight lang=bash>
 +
apt-get purge network-manager
 +
vi /etc/network/interfaces
 +
auto <interface>
 +
iface <interface> inet dhcp
 +
    wpa-ssid <ssid>
 +
    wpa-psk <password>
 +
</syntaxhighlight>
 +
 
 +
For interfaces that may not be connected use <code>allow-hotplug</code> instead of <code>auto</code>.<br>
 +
The bootprocces now does not wait for an DCHP-answer on disconnected interfaces. Saves you about 5 minutes during startup.
 +
 
 +
==Routing==
 +
;route add -net default gw <IPaddress>
 +
:Add a default route using <IPaddress>  as gateway
  
 
==Tunneling==
 
==Tunneling==
 
;<code>ssh -L 8080:remotehost:3006 proxy</code>
 
;<code>ssh -L 8080:remotehost:3006 proxy</code>
:Login over ssh to proxy and there connect to remotehost port 3306. Connect local port 8080 to the remote connection.
+
:Login over ssh to proxy and there connect to remotehost port 3006. Connect local port 8080 to the remote connection.
:Now if you connect to port 8080 on your local server you are connected to port 3306 on the remotehost
+
:Now if you connect to port 8080 on your local server you are connected to port 3006 on the remotehost
 
:Using <code>-nNT</code> prevents that the ssh command opens a terminal on the proxy. The ssh command however must remain active.
 
:Using <code>-nNT</code> prevents that the ssh command opens a terminal on the proxy. The ssh command however must remain active.
 +
 +
==Tracing==
 +
For tracing traffic see [[Tcpdump]]

Revision as of 14:54, 25 December 2019


Check network connections

Netcat

nc -v -z <host> <port>
Tell me if we can open a connection to <host> on <port>. Without -z it works like telnet
nc -v -u -z <host> <port>
Tell me if we can open a connection to <host> on a UDP <port>

Curl

curl -vvv -k --proxy1.0 <proxyIP>:<proxyPort> <Remote URL>
Get the data from <remote URL> via <proxyIP> -k allows insecure SSL connections
curl -vvv telnet://<IP>:<port>
Just test connectivity to a port
#!/bin/bash

PORT=$1

TARGETS="999.999.999.999
888.888.888.888
777.777.777.777
666.666.666.666
"

for TARGET in ${TARGETS}
do
  curl  http://${TARGET}:${PORT} --connect-timeout 1 > /dev/null 2>&1
  if [ $? == 28 ]
   then
    echo No connection to ${TARGET}:${PORT}
  fi
done

Wget

wget <URL>
Get the data from <URL>

OpenSSL

See the OpenSSL page

Interfaces

ifconfig -a
Show all network interfaces
ifconfig <interface> <ipaddrss>
Assign <ipaddress> to <interface>
mii-tool <interface>
Show interface link status (speed)
The interfaces file
apt-get purge network-manager
vi /etc/network/interfaces
auto <interface>
iface <interface> inet dhcp
    wpa-ssid <ssid>
    wpa-psk <password>

For interfaces that may not be connected use allow-hotplug instead of auto.
The bootprocces now does not wait for an DCHP-answer on disconnected interfaces. Saves you about 5 minutes during startup.

Routing

route add -net default gw <IPaddress>
Add a default route using <IPaddress> as gateway

Tunneling

ssh -L 8080:remotehost:3006 proxy
Login over ssh to proxy and there connect to remotehost port 3006. Connect local port 8080 to the remote connection.
Now if you connect to port 8080 on your local server you are connected to port 3006 on the remotehost
Using -nNT prevents that the ssh command opens a terminal on the proxy. The ssh command however must remain active.

Tracing

For tracing traffic see Tcpdump