Linux环境设置IP及关闭防火墙
Posted sekihin
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux环境设置IP及关闭防火墙相关的知识,希望对你有一定的参考价值。
确认当前网络配置:
[root@localhost ~]# nmcli -p dev ===================== Status of devices ===================== DEVICE TYPE STATE CONNECTION ------------------------------------------------------------------ virbr0 bridge connected virbr0 eth0 ethernet connected eth0 lo loopback unmanaged --
设置IP的文件修改如下:
## Configure eth0 # # vi /etc/sysconfig/network-scripts/ifcfg-eth0 HWADDR=00:0C:29:10:A0:DB MACADDR=00:0C:29:10:A0:DB TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no # Static IP Address # BOOTPROTO=static IPADDR=192.168.1.249 PREFIX=24 # Default Gateway IP # GATEWAY=192.168.1.1 # DNS Servers # DNS1=118.118.118.1 DEFROUTE=yes PEERDNS=no # Disable ipv6 # IPV4_FAILURE_FATAL=no IPV6INIT=no NAME=eth0 UUID=2734ae8a-4190-4cb9-9b32-4404dfc83e29 # Activate on Boot # ONBOOT=yes ## Configure Default Gateway # # vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=centos6 GATEWAY=192.168.1.1 ## Restart Network Interface # /etc/init.d/network restart ## Configure DNS Server # # vi /etc/resolv.conf nameserver 118.118.118.1 # Replace with your nameserver ip nameserver 192.168.1.1 # Replace with your nameserver ip
打开控制台,通过命令修改如下:
sudo ifconfig eth0 192.168.1.251 netmask 255.255.255.0 sudo route add default gw 192.168.1.1 sudo echo "nameserver 118.118.118.1" > /etc/resolv.conf sudo echo "nameserver 192.168.1.1" > /etc/resolv.conf
关闭防火墙及重启网络链接:
systemctl stop firewalld
systemctl disable firewalld
/etc/init.d/network restart
通过ifconfig命令查看当前IP,如未反映上时,可通过设置画面重启网络链接:
以上是关于Linux环境设置IP及关闭防火墙的主要内容,如果未能解决你的问题,请参考以下文章
Linux系统标准化设置:克隆系统后网卡设置固定IP设置关闭防火墙和SELINUX更改主机名