Linux network configuration

Temporary Change Solution:
#ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up
Permanent Change Solution:
Step1 Change config file:/etc/sysconfig/network-scripts/ifcfg-eth0
(Or use system-config-network command to config but remember to check config file)
dynamic IP config:
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=00:03:47:2C:D5:40
ONBOOT=yes
TYPE=Ethernet
static IP config:
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.1.223
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
HWADDR=00:03:47:2C:D5:40
ONBOOT=yes
TYPE=Ethernet
Step2. restart service:
Before Linux 6.0:
service network restart
 
Linux 6.0: 
service NetworkManager restart
service network restart
 
Addintional
network --> /etc/rc.d/init.d/network
NetworkManager --> /etc/rc.d/init.d/NetworkManager
 
Check network adapter status: mii_tool / ip link

Close the feedback of ping: echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_all

Check network connection: ping / traceroute <domain name> / mtr <domain name> / dig / host / iptraf

Load check: ab -n 1000 -c 1000 <domain name>
Example: ab -n 1000 -c 1000 www.sina.com.cn

Check the firewall setting: iptables -L

Temporary clear the firewall setting: iptables -F

Check network status: netstat -antup
Attention: 
netstat -antup | wc -l is huge
1. If there are a lot of "Established" connections and the source IP address is same, the server got the CC network attack;
2. If the status of "Established" is little, it may receive the DDOS or syn_flood attack;

Check about arp attack:
1. check arping <gateway ip>
If the feedback is the same MAC address, there is no arp attack. Otherwise there is arp attack.
Solution: setup the right gateway: arp -s <gateway ip address> <gateway mac address>

Error: mac address different
Solution: check the mac address in Virtual Box setting of the vm server

Setup several ipaddress
Temporary
ifconfig eth0:0 12.11.0.136/24
ifconfig eth0:1 12.11.0.137/24
ifconfig eth0:2 12.11.0.138/24

Permanent
vim /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
onboot=yes
BOOTPORTO=static
IPADDR=12.11.0.136
NETMASK=255.255.255.0
GATEWAY=12.11.0.100

vim /etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
onboot=yes
BOOTPORTO=static
IPADDR=12.11.0.137
NETMASK=255.255.255.0
GATEWAY=12.11.0.100

vim /etc/sysconfig/network-scripts/ifcfg-eth0:2
DEVICE=eth0:2
onboot=yes
BOOTPORTO=static
IPADDR=12.11.0.138
NETMASK=255.255.255.0
GATEWAY=12.11.0.100

After clone virtual box system, the mac address will not change.
1. change the system config file /etc/udev/rules.d/70-persistent-net.rules
The new mac will be used as eth1, the original one will be used as eth0
Remove the eth0 config and change eth1 as eth0
2. change the network adaptor config file /etc/sysconfig/network-scripts/ifcfg-eth0
use new mac instead of old one. 
3. restart network service: service network restart

Comments

Popular posts from this blog

Nginx Proxy & Load Balance & LNMP

Snort+barnyard2+Snorby CentOS 6.5_64 Installation

ORACLE Error