I will gradually learn some instructions about Network in Linux. First, here are somethings about IPv4: There are A, B, C, D, E, 5 classes. (images co ...
I will gradually learn some instructions about Network in Linux.
First, here are somethings about IPv4:
There are A, B, C, D, E, 5 classes.
(images copied from here)
And Sub-net mask for each is :
- A : 255.0.0.0
- B : 255.255.0.0
- C : 255.255.255.0
P.S.
- 127.x.x.x is loopback IP for your local host.
- D is remained for multi-cast
- E is remained for future applications
- the first IP in one class belongs to the network itself.E.g. 192.168.1.0 is a network IP
- the last IP in one class is a broadcast IP, packets sended to which will be sended to all hosts in the corresponding network.
ifconfig & iwconfig
- See IP, MAC address and network mask
ifconfig
- Modify IP
ifconfig eth0 192.168.1.104
- Activate/Shutdown Interface
ifconfig etho up/down
- Configure network mask
ifconfig eth0 netmask 255.255.255.0
- Change mode of Wireless network card
iwconfig wlan0 mode managed/monitor
nslookup
query Internet name servers
E.g.
nslookup www.baidu.com
netstat
See current ports' states
netstat -tunl
- t: means TCP
- u: means UDP
- n: Show numerical addresses instead of trying to determine symbolic host, port or user names.
- l: Show only listening sockets
netstat -an
- a: all
ping
ping hostname,
if the host you ping is down, your ping will return:
If the host you ping ignores your ICMP packet, the ping will continue:
Avoid ping by others:
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all
If you want to be ping:
echo 0 > /proc/sys/net/ipv4/icmp_echo_ignore_all
tcpdump
Use eth0 (-i) and ip/port (-nn means not use domain/service format) to monitor port 21 in hex (-X):
tcpdump -i eth0 -nnX port 21
P.S.
ftp and telnet use plain text to transport information and you can use tcpdump to monitor it directly.
(Also, you should use ssh to replace telnet !)
nmap
traceroute
- traceroute www.baidu.com
print the route packets trace to network host
telnet
You can use telnet to test whether a specific port in target host is open:
telnet 192.168.1.103 21
If it is open:
Or it will be:
ssh & scp
ssh username@IP
E.g.
First, switch on the sshd servie in the virtual environment:
service sshd start
In the host:
ssh [email protected]
Use scp to copy files:
scp [-r] username@IP:file-path local-path
scp [-r] local-path username@IP:file-path