I. IP configuration: Do not directly modify the file mode: Set the IP address and subnet mask of the NIC eth0: sudo ifconfig eth0192.168.2.1Netmask255.255.255.0change the IP address to:192.168.2.1, the subnet mask is changed to:255.255.255.0set up Gateway: sudo route adddefaultGw192.168.2.254manually modify the file mode: First (second) block network card configuration file:/etc/sysconfig/network-scripts/ifcfg-eth0 (different systems typically contain eth0) DEVICE=eth0 Bootproto=none #指定是静态分配IP还是动态分配. The values are:StaticDHCP Onboot=Yes #系统启动时加载 HWADDR=xx: 0c: in: -:d 1:b1 ipaddr=192.168.8.200NETMASK=255.255.255.0GATEWAY=192.168.8.1#设置默认网关 (can be set below) TYPE=Ethernet/etc/network/interfaces (Ubuntu) auto eth0 iface eth0 inetStatic#取值有:StaticDHCP (DHCP: Available sudo dhclient eth0 get IP address) address192.168.2.1Gateway192.168.2.254netmask255.255.255.0#network192.168.2.0#broadcast192.168.2.255Second, modify the gateway vim/etc/sysconfig/Network adds gateway information=192.168.1.1Third, modify the Dnsvim/etc/resolv.conf #指定当前主机的DNS服务器, you can specify up to three search lpwr.net #设置当前主机的默认查找域nameserver192.168.0.100#指定首选DNS服务器nameserver172.16.254.2Iv. Reloading the network configuration/etc/init.d/Networking Restart (Ubuntu)/etc/init.d/Network Restart (redhat CentOS) Service Network Restart Five, firewall settings1, shut down the firewall directly (Centos7 available) Systemctl stop firewalld.service #停止firewall systemctl disable Firewalld.service #禁止firewall Boot up2, set up Iptables service (without installing iptables-services) VI/etc/sysconfig/iptables Add Rule-A input-p tcp-m state--state new-m TCP--dport A-J ACCEPT-A input-p tcp-m state--state new-m TCP--dport50070-J ACCEPT-A input-p tcp-m state--state new-m TCP--dport8088-J ACCEPT-A input-p tcp-m state--state new-m TCP--dport19888-J ACCEPT-A input-p tcp-m state--state new-m TCP--dport9000-J Accept Save after exit Systemctl restart Iptables.service #重启防火墙使配置生效systemctl enable Iptables.service #设置防火墙开机启动六, disable IPV6 sudo vi/etc/modprobe.d/blacklist.conf indicates that the contents of blacklist.conf documents in the MODPROBE.D folder under the ETC folder can be edited using the VI editor (or other editors, such as Gedit). Note: can only be modified in root user mode to add blacklist IPv6 at the end of the document and then view the results of the changes cat/etc/modprobe.d/blacklist.conf vii. Modification of hostname modification/etc/Hosts file that will contain the current hostname changes to the new hostname. I changed Shiwei to Rabbit. Modify/etc/sysconfig/Network file that will contain the current hostname to the new hostname. I changed Shiwei to Rabbit. Use the command hosname to change the command: hostname the new hostname, and then use the hostname name to see if the modification was successful.
Network Configuration commands under Linux