Linux環境設置IP及關閉防火牆

確認當前網絡配置:centos

[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

打開控制檯,經過命令修改以下:oop

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

關閉防火牆及重啓網絡連接:spa

systemctl stop firewalld
systemctl disable firewalld
/etc/init.d/network restart

經過ifconfig命令查看當前IP,如未反映上時,可經過設置畫面重啓網絡連接:rest

相關文章
相關標籤/搜索