Tuesday, January 22, 2008

Console for networking and internet

Перетаскивая ноутбук дом-работа приходиться менять конфиги:
Можете использовать gedit вместо vi.

1.1. ip command to set a default router to 192.168.0.1
sudo ip route add default via 192.168.0.1

1.2. route command to set a default router to 192.168.0.1
sudo route add default gw 192.168.0.1

1.3. Save routing information to a configuration file /etc/network/interfaces
sudo vi /etc/network/interfaces
gateway 192.168.0.1

2.
Save nameserver information to a configuration file /etc/resolv.conf
sudo vi /etc/resolv.conf
nameserver 192.168.0.1

3. Restart networking
sudo /etc/init.d/networking restart

ip a change 192.168.0.12/24 dev eth0

ip r list
ip a list
cat /etc/network/interfaces
ifconfig
sudo mtr ya.ru
telnet svn.exoplatform.org 80
ping www.exoplatform.org
cat /etc/resolv.conf

Ping
ping HOST_OR_IP
ex.1:
$ ping google.ru
------------------------------
PING google.ru (72.14.221.104) 56(84) bytes of data.
64 bytes from fg-in-f104.google.com (72.14.221.104): icmp_seq=1 ttl=248 time=1106 ms
...
------------------------------
ex.2:
$ ping ya.ru
------------------------------
PING ya.ru (213.180.204.8) 56(84) bytes of data.
64 bytes from ya.ru (213.180.204.8): icmp_seq=2 ttl=56 time=99.3 ms
...
------------------------------



Nmap
sudo nmap -sS -PI -PT -O -F 192.168.0.1
sudo nmap -sS --open -p T:80,8080 192.168.0.1-255
ex.1:
alexey@wtf:~$ sudo nmap -sS --open -p T:80,8080 72.14.221.104
------------------------------
Starting Nmap 4.20 ( http://insecure.org ) at 2008-01-22 09:11 EET
Interesting ports on fg-in-f104.google.com (72.14.221.104):
Not shown: 1 filtered port
PORT STATE SERVICE
80/tcp open http

Nmap finished: 1 IP address (1 host up) scanned in 5.444 seconds
------------------------------


ex.2:
alexey@wtf:~$ sudo nmap -sS -PI -PT -O -F 72.14.221.104
------------------------------
Starting Nmap 4.20 ( http://insecure.org ) at 2008-01-22 09:12 EET
Interesting ports on fg-in-f104.google.com (72.14.221.104):
Not shown: 1252 filtered ports
PORT STATE SERVICE
80/tcp open http
113/tcp closed auth
179/tcp closed bgp
443/tcp open https
Device type: general purpose
Running (JUST GUESSING) : Microsoft Windows 95/98/ME|NT/2K/XP|3.X (85%), Linux 1.X (85%), NetBSD (85%)
Aggressive OS guesses: Microsoft Windows NT 3.51 SP5, NT 4.0 or 95/98/98SE (85%), Linux 1.3.20 (x86) (85%), NetBSD 1.6.2 (alpha) (85%), Microsoft Windows 3.1 with Trumpet Winsock 2.0 revision B (84%)
No exact OS matches for host (test conditions non-ideal).

OS detection performed. Please report any incorrect results at http://insecure.org/nmap/submit/ .
Nmap finished: 1 IP address (1 host up) scanned in 97.809 seconds

------------------------------


Telnet
telnet 192.168.0.1 80
GET . HTTP/1.0
ex.1:
alexey@wtf:~$ telnet 72.14.221.104 80
------------------------------
Trying 72.14.221.104...
Connected to 72.14.221.104.
Escape character is '^]'.
------------------------------

GET http://www.google.ru HTTP/1.0
------------------------------
HTTP/1.0 200 OK
Cache-Control: private
Content-Type: text/html; charset=windows-1251
Set-Cookie: PREF=ID=940ca0c052b49a6a:NW=1:TM=1200985708:LM=1200985708:S=xE0rP3DhbLa0U2SU; expires=Thu, 21-Jan-2010 07:08:28 GMT; path=/; domain=.google.ru
Server: gws
Date: Tue, 22 Jan 2008 07:08:28 GMT
Connection: Close

...
meta equiv="content-type" content="text/html; charset=windows-1251" .. title .. Google ./title..
...
...
------------------------------


ex.2:
POST /portal/portal HTTP/1.0
Host: localhost
Content-Length: 26

fis=yes&listCollapsed=true


Wget
r - рекурсивно
c - дописать
l - глубина
ex.
wget -r -c -l 2 http://docs.oasis-open.org/wsrp/v2/
wget -r -c -l 1 -nd -P wsrpSpecFiles http://docs.oasis-open.org/wsrp/v2/
wget -r -k -с -l 0 -np http://example.com/
- выкачка сайта целиком (рекурсивно, изменяя ссылки на относительные, докачивая, с неограниченной глубиной, без вышестоящего домена)

wget - wiki
Wget - насос для Интернета

Iptables

добавьте 127.0.0.1 link.altova.com в hosts
> sudo gedit /etc/hosts

запретить всем программам TCP подключения к 443 и 2799 портам на IP адресах 84.53.166.97, 88.221.170.97, 88.221.2.97
> sudo iptables -A INPUT -p tcp --dport 443:2799 -d 84.53.166.97 -j DROP
> sudo iptables -A INPUT -p tcp --dport 443:2799 -d 88.221.170.97 -j DROP
> sudo iptables -A INPUT -p tcp --dport 443:2799 -d 88.221.2.97 -j DROP
> sudo iptables --list


Links
http://www.xml.com/pub/a/2004/12/15/telnet-REST.html
http://ipesin.linux.kiev.ua/translations/rhm/love_cl1.htm
http://ipesin.linux.kiev.ua/translations/rhm/love_cl2.htm

No comments: