本地網卡設備 eth1 配置
IP配置
配置命令: ifconfig eth1 192.168.x.x
廣播地址、掩碼配置
配置命令: ifconfig eth1 192.168.x.x broadcast 192.168.1.255 netmask 255.255.255.0
網關配置
配置命令:route add default gw 192.168.x.254
【注意】以上配置命令均為單次生效,需要永久生效需要更改配置文件: /etc/sysconfig/network-scripts/ifcfg-eth1;
【經驗】能夠 ping 通本網段其他IP,不能 ping 通其他網段IP,往往是網關沒有配置;
Exp:172.16.33.175 能夠 ping 通 172.16.33.132,但是不能 ping 通 172.16.31.43,正常配置網關后能夠 ping通。
配置自動獲取IP
使用 udhcpc 工具進行配置
- 命令查看當前可自動分配IP情況
配置命令:udhcpc -i eth1
- 命令配置自動分配IP
配置命令:udhcpc -i eth1 -s /etc/udhcpc.script
配置腳本文件 udhcpc.script 可參考鏈接:https://blog.csdn.net/zhangboyj/article/details/6154846

