DHCP configuration

# Install packages 
opkg update
opkg install tcpdump
 
# Capture DHCP traffic
tcpdump -evni any udp port 67 & \
sleep 5; \
killall -SIGUSR1 udhcpc; \
sleep 5; \
killall tcpdump
 
# Capture DHCPv6 traffic
tcpdump -evni any udp port 547 & \
sleep 5; \
killall -SIGUSR1 odhcp6c; \
sleep 5; \
killall tcpdump

See also: Providing ISP DNS with DHCP, Hotplug

# Logging DHCP client
cat << "EOF" > /etc/udhcpc.user
logger -t ${0##*/} ${@} $(env)
EOF
 
# Logging DHCPv6 client
cat << "EOF" > /etc/odhcp6c.user
logger -t ${0##*/} ${@} $(env)
EOF
 
# Fetching new leases
ifup wan
ifup wan6
 
# Reading logs
logread -e dhcp.script
logread -e dhcpv6.script
 
# Checking status
ifstatus wan
ifstatus wan6
cat << "EOF" > /etc/udhcpc.user
DHCPC_EVENT="${1}"
DHCPC_IF="${interface}"
DHCPC_GW="${router}"
case ${DHCPC_EVENT} in
(bound|renew) ;;
(*) exit 0 ;;
esac
ip route delete default dev "${DHCPC_IF}"
ip route add default via "${DHCPC_GW}" dev "${DHCPC_IF}"
EOF
cat << "EOF" > /etc/odhcp6c.user
DHCPC_EVENT="${2}"
DHCPC_IF="${INTERFACE}"
DHCPC_GW="${SERVER}"
case ${DHCPC_EVENT} in
(bound|informed|updated|rebound|ra-updated) ;;
(*) exit 0 ;;
esac
ip -6 route delete default dev "${DHCPC_IF}"
ip -6 route add default via "${DHCPC_GW}" dev "${DHCPC_IF}"
EOF
cat << "EOF" > /etc/udhcpc.user
DHCPC_EVENT="${1}"
DHCPC_IF="${interface}"
DHCPC_SERV="${serverid}"
case ${DHCPC_EVENT} in
(bound|renew) ;;
(*) exit 0 ;;
esac
ip route delete "${DHCPC_SERV}" dev "${DHCPC_IF}"
ip route add "${DHCPC_SERV}" dev "${DHCPC_IF}"
EOF
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
  • Last modified: 2021/04/08 18:58
  • by vgaetera