新服务器网络配置

发布时间:2017-02-08 15:30:29编辑:丝画阁阅读(452)

修改IP地址

vim /etc/sysconfig/network-scripts/ifcfg-eth0


DEVICE=eth0  物理设备名

HWADDR=D8:CB:8A:13:4C:59  MAC地址,通过ifconfig获得
TYPE=Ethernet
UUID=01fc1eb8-c5e7-4998-85bf-fd2fc013b33d
ONBOOT=yes 激活设备
NM_CONTROLLED=yes
BOOTPROTO=static [none|static|bootp|dhcp]引导时不使用协议|静态分配|BOOTP协议|dhcp协议,这里选对静态分配
IPV6INIT=no
IPV6_AUTOCONF=no
IPADDR=192.168.1.166 IP地址
NETMASK=255.255.255.0 子网掩码
GATEWAY=192.168.1.1 网关地址
DNS1=192.168.1.1

DNS2=114.114.114.114


修改网关地址

vim /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=yimeikang
GETEWAY=192.168.0.1


修改DNS

vim /etc/resolv.conf

nameserver 192.168.1.1
nameserver 114.114.114.114


2.4:重启网卡
# service network restart


25

/etc/rc.d/rc.local最后加上 ifup eth0  /et/rc.d/rc.local脚本是在所有其他初始化脚本执行完毕后执行.


防火墙开放端口

# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3690 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT


关键字