Centos6 Connect WiFi
Centos6 Connect WiFi
// 安装 wireless tools yum install wireless-tools dkms pciutils lsusb // 使用wlan命令检查无线网卡 # iwconfig // 安装 wpa supplicant # yum install wpa_supplicant
# service wpa_supplicant status
# service wpa_supplicant reload // 编辑文件 /etc/wpa_supplicant/wpa_supplicant.conf # vi /etc/wpa_supplicant/wpa_supplicant.conf // 编辑文件 /etc/sysconfig/network-scripts/ifcfg-wlan0 # vi /etc/sysconfig/network-scripts/ifcfg-wlan0 // 启用无线网卡wlan0 # ifconfig wlan0 up // 扫描无线网络,如果有用手机热点,建议将热点改为英文名字,避免乱码的问题 # iwlist wlan0 scan // 连接手机的WIFI热点小米 # iwconfig wlan0 essid "xiaomi" // 通过DHCP方式自动获取IP # dhclient wlan0 // 查看wlan0配置状态 # iwconfig wlan0 // 查看路由状态 # netstat -nr // 测试网络连通性 # ping www.baidu.com
// 编辑文件 /etc/wpa_supplicant/my_wpa_supplicant.conf # cat /etc/wpa_supplicant/my_wpa_supplicant.conf ctrl_interface=/var/run/my_wpa_supplicant ctrl_interface_group=wheel # // 编辑文件 /etc/sysconfig/network-scripts/ifcfg-wlan0 # cat /etc/sysconfig/network-scripts/ifcfg-wlan0 DEVICE=wlan0 ONBOOT=yes BOOTPROTO=dhcp # // 连接wlan0到网络,并以daemon方式运行。备注:-B Background在后台以daemon 运行,-i interface -c 配置文件 # wpa_supplicant -B -i wlan0 -c /etc/my_wpa_supplicant.conf // 通过DHCP方式自动获取IP # dhclient wlan0
关闭防火墙,永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
关闭防火墙,即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
清空防火墙规则
# iptables -F
# iptables -X
# /etc/init.d/iptables save
# /etc/init.d/iptables status
# /etc/init.d/iptables reload
设置IP转发
# sed -i '/net.ipv4.ip_forward/s/0/1/' /etc/sysctl.conf
# sysctl -p
关闭SELINUX
# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# setenforce 0
# reboot
查询TCP连接情况:
netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
查询端口占用情况
netstat -anp | grep portno (例如:netstat –apn | grep 80)
=============== End