ifconfig command, change host name, change DNS hosts, close selinux firewalld netfilter firewall

The ifconfig command is used to view network related commands:

Installation: yum install net-tools -y

 ifdown eth_name shuts down the network card

 ifup eth_name enable network card

Configure the virtual network card:

Edited content:

DEVICE=bond:1
BONDING_OPTS="updelay=0 resend_igmp=1 use_carrier=1 miimon=100 arp_all_targets=any min_links=0 downdelay=0 xmit_hash_policy=layer2 primary_reselect=always fail_over_mac=none arp_validate=none mode=active-backup lp_interval=1 primary=ens33 all_slaves_active=0 arp_interval=0 ad_select=stable num_unsol_na=1 num_grat_arp=1"
TYPE=Bond
BONDING_MASTER=yes
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
IPADDR=192.168.6.111
PREFIX=24
GATEWAY=192.168.6.10
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=bond
UUID=cd9a0d91-8ec9-41fb-bf2d-c83b7dc0ddd8
ONBOOT=yes

Check the network connection status:

mii-tool eth_name

ethtool eth_name

Change of hostname:

vim /etc/hostname

hostnamectl set-hostname new_name

Change DNS:

Configuration file: /etc/resolv.conf

Usually, the main change that can be temporarily changed
is to prepare and change in eth0 or other network cards.

/etc/sysconfig/network-scripts/ifcfg-eth0 改变。

ifdown eth0 && ifup eth0 shutdown and restart eth0

hosts file:

Path: /etc/hosts, you can modify the local resolution

Custom resolution: echo "127.0.0.1 www.baidu.com " >> /etc/hosts

Turn off selinux:

Path: /etc/selinux/config

getenforce View the status of selinux

setenforce temporarily sets the state of selinux (setenforce 0 off / setenforce 1 on)

sed -i 's/SELINUX=disabled/SELINUX=enforcing/' /etc/selinux/config

sed -i '7s/disabled/enforcing/'  /etc/selinux/config

firewall

netfilter firewalld -->iptables management tool:

Turn off the firewall:
systemctl disable firewalld (permanently off, not starting at boot)

systemctl stop firewalld (temporarily stop)

Install the iptables management tool:

(netfilter--->iptables 是它的管理工具,censt os 6 以前是用的这个)

yum install iptables-services

systemctl enable iptables  把iptables 加入开机自动启动

systemctl start  iptables   开启iptables服务

iptables的使用:

原理图:

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

iptables -nvL  可以看默认的表(filter)

 默认存放路径:/etc/sysconfig/iptables

清空:iptables -F

保存:service iptables save

重启:service iptables restart

清空数据包: iptables -Z

添加一条规则:iptables -A INPUT -s 192.168.100.100 -p tcp --sport 8080 -d 192.168.100.200 --dport 80 -j DROP

       iptables -I INPUT -p tcp --dport 81 -j DROP (插入一条规则,简写) 

删除一条规则:iptables -D INPUT -s 192.168.100.100 -p tcp --sport 8080 -d 192.168.100.200 --dport 80 -j DROP

       iptables -D INPUT -p tcp --dport 81 -j DROP (删除一条规则,简写) 

也可以用行号来删除:

查看行号:iptables -nvL --line-number

  删除:iptables -D INPUT 5        

查看nat表

iptables -t nat -nvL

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325985776&siteId=291194637