安装DHCP服务:sudo apt install isc-dhcp-server
打开相应防火墙:
sudo iptables -I INPUT -p tcp --dport 8080:8084 -j ACCEPT
sudo iptables -I INPUT -p udp --dport 69 -j ACCEPT
配置如下:
if everything is okay,your DUT can get IP from SERVER DHCP, and 'ping 101.1.2.4' is good.
and 'ifconfig' should be like this:
"<eth1> inet addr:101.1.2.4 Bcast:101.1.255.255 Mask:255.255.0.0"
Question:
1. How to match the real network card hardware with it's name?
ethtool -p <eth0> #the relative network card hardware will blinky.
2. How to config the static IP on server? ( in directory: /etc/network/interfaces )
# 配置网卡1,作为连接后端server的网卡与其静态IP (若无则不需要配置)
# config the static IP to connect backend server
auto eth1
iface eth1 inet static
address 192.168.253.85 #should be changed with different server/network card
netmask 255.255.255.0
gateway 192.168.253.1
##配置网卡2,作为服务器的网卡与其静态IP
auto p2p1 #不要忘记在 /etc/default/isc-dhcp-server 中配置默认的DHCP服务网卡!
iface p2p1 inet static
address 101.1.2.4
netmask 255.255.0.0#配置网卡3,作为连接互联网的网卡与其静态IP (若无则不需配置)
auto eth4
iface eth4 inet static
address 10.240.16.37 #click the wired connection info
netmask 255.255.255.0
gateway 10.240.16.250 #ip route | grep default
dns-nameserver 8.8.8.8
Note: [Important]Connect Internet will cause conflict, so you can just choose one way in one time
use cmd to verify, cmd: sudo /etc/init.d/networking restart
这里静态IP已经固定完成,可用 ifconfig 检查对应网口的IP是否正确
3. How to config the Bcast IP/the Mask IP? ( in directory: /etc/dhcp/dhcpd.conf )
subnet 101.1.0.0 netmask 255.255.0.0 {
range 101.1.5.10 101.1.200.255; #配置ip范围
option domain-name-servers 101.1.2.1;
option domain-name "example.org";
option broadcast-address 101.1.255.255;
option routers 101.1.2.4;
option subnet-mask 255.255.0.0;
# filename "vmlinux.bin";
# option dhcp-server-identifier 101.1.2.4;
next-server 101.1.2.4;
}host mydhcp {
hardware ethernet 00:0e:c6:fb:4b:8b; #(物理地址替换为你查到的)
fixed-address 101.1.2.4;
}
verify cmd:
sudo service networking restart; sudo service isc-dhcp-server restart && sudo reboot
sudo netstat –uap #检查DHCP服务是否正常进行
/var/log/syslog #查看系统log,定位配置问题
重启network-manager 服务
# service network-manager restart
# systemctl disable NetworkManager.service
# systemctl enable NetworkManager.service
其他
pci设备的网卡
lspci -v
激活网卡
sudo ifconfig 网卡设备名 up
查询USB网口
lsusb