网络配置:
/etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=localhost.localdomain
GATEWAY=192.168.5.1
/etc/sysconfig/network-scripts/ifcfg-eth0
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0//用于设置网络接口的名称
BOOTPROTO=static//用于设置网络接口是配置为静态地址(static)还是配置为dhcp;
BROADCAST=192.168.5.255
HWADDR=00:0C:29:D1:42:3F
IPADDR=192.168.5.247 //设置网络接口地址
GATEWAY=192.168.5.1 //设置网络接口的默网关
IPV6ADDR=
IPV6PREFIX=
NETMASK=255.255.255.0 //设置网络接口的子网掩码
NETWORK=192.168.5.0
ONBOOT=yes
# iwconfig 列举无线网卡, 一般为"wlan0"
编辑 /etc/sysconfig/wpa_supplicant
INTERFACE="-iwlan0"
编辑 /etc/wpa_supplicant/wpa_supplicant.conf
wpa_passphrase ESSID PASSWORD >> /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="NETWORKSSID"
scan_ssid=1
key_mgmt=WPA-PSK
psk="NETWORKPSK"
}
----------------------------------------------------------------------------
×××配置
1. 安装工具
# yum install ppp
# yum install pptp
# yum install pptp-setup (其实就是个脚本)
2. ×××配置
# pptpsetup --create ***_company --server ***.company.com --user ***_user
--password ***_pass --encrypt
3. 检查配置结果
# cat /etc/ppp/chap-secrets
***_user ***_company "vpm_pass" *
# cat /etc/ppp/peers/***_company
pty "pptp ***.company.com --nolaunchpppd"
lock
refuse-eap
noauth
nobsdcomp
nodeflate
name ***_user
remotename ***_company
ipparam ***_company
require-mppe-128
4. 注册内核模块
# modprobe ppp_mppe
5. 连接×××
# pppd call ***_company
6. 检查连接状态
检查日志 /var/log/messages
7. 断开连接
# killall pppd
成功后会多出一个虚拟网口ppp0
[root@localhost peers]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
112.124.132.142 192.168.10.1 255.255.255.255 UGH 0 0 0 eth0
192.168.8.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.10.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
0.0.0.0 192.168.10.1 0.0.0.0 UG 0 0 0 eth0
并且用ifconfig也可以看到
添加默认路由
[root@localhost peers]# route add -net 0.0.0.0 dev ppp0 //添加默认路由
[root@localhost peers]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
112.124.132.142 192.168.10.1 255.255.255.255 UGH 0 0 0 eth0
192.168.8.1 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0
192.168.10.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0
0.0.0.0 192.168.10.1 0.0.0.0 UG 0 0 0 eth0
断开***连接,只需要把网络重启就行了
[root@localhost peers]# /etc/init.d/network restart
======================================
a)没有默认网关
这时,你只需设置一个默认路由即可,例如:
1
|
#
route add -net 0.0.0.0 dev ppp0
|
b)已有默认网关
若像上面那样添加一条路由是不行的,需要先让访问×××服务端的流量可通过,然后才能转发其他的数据包。
1
2
|
#
ip route replace ×××地址IP via 默认网关IP dev eth0 src 本机IP # ip route replace default dev ppp0
|
转载于:https://blog.51cto.com/norman20000/1729757