Advertisement
karamaz0v

DHCP server and NAT setup

Oct 25th, 2011
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Ubuntu/Debian Setup to make device eth0 dhcp server, and translate internet connection from wlan0
  2. always as ROOT!!!!!!
  3.  
  4. # vim /etc/default/dhcp3-server
  5. and set
  6. INTERFACES="eth0"
  7.  
  8. # vim /etc/network/interfaces
  9. and add
  10.  
  11. auto eth0
  12. iface eth0 inet static
  13. address 10.1.1.254
  14. netmask 255.255.255.0
  15. broadcast 10.1.1.255
  16. network 10.1.1.0
  17.  
  18. run
  19. # /etc/init.d/networking restart
  20.  
  21. # vim /etc/dhcp3/dhcpd.conf
  22. and set only
  23.  
  24. default-lease-time 600;
  25. max-lease-time 7200;
  26.  
  27. option domain-name-servers 208.67.222.222, 208.67.220.220;
  28.  
  29. subnet 10.1.1.0 netmask 255.255.255.0 {
  30. range 10.1.1.10 10.1.1.20;
  31. option routers 10.1.1.254;
  32. option broadcast-address 10.1.1.255;
  33. }
  34.  
  35. run
  36. # /etc/init.d/dhcp3-server restart
  37.  
  38. if e.g. wlan0 is connected to the net, to translate internet connection to any dhcp client connected to eth0 (directly or through a switch), must be executed this script (modify accordingly)
  39.  
  40. -- script start --
  41.  
  42. #!/bin/bash
  43.  
  44. echo 1 > /proc/sys/net/ipv4/ip_forward
  45.  
  46. WAN="wlan0"
  47. LAN="eth0"
  48.  
  49. /sbin/iptables -t nat -A POSTROUTING -o $WAN -j MASQUERADE
  50. /sbin/iptables -A FORWARD -i $WAN -o $LAN -m state --state RELATED,ESTABLISHED -j ACCEPT
  51. /sbin/iptables -A FORWARD -i $LAN -o $WAN -j ACCEPT
  52.  
  53. -- script end --
  54.  
  55. if things don't work following the steps, reboot client and server and rerun the script on server
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement