Advertisement
shokti

ubuntu 13.04 - dhcp and nat server

Nov 22nd, 2013
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. configure your public and private network interface(use 2 nic):
  2. edit /etc/network/interfaces:
  3. sudo nano /etc/network/interfaces
  4.  
  5. # public network interface
  6. auto eth0
  7. iface eth0 inet dhcp
  8.  
  9. # private network interface
  10. auto eth1
  11. iface eth1 inet static
  12. address 192.168.182.1
  13. netmask 255.255.255.0
  14. broadcast 192.168.182.255
  15. network 192.168.182.0
  16.  
  17. install and configure DHCP service:
  18. install isc-dhcp-server:
  19. sudo apt-get install isc-dhcp-server
  20.  
  21. specify that the private network interface is the one using the dhcp service:
  22. edit /etc/default/isc-dhcp-server:
  23. sudo nano /etc/default/isc-dhcp-server
  24.  
  25. change the interface:
  26. INTERFACES="eth1"
  27.  
  28. configure the dhcp:
  29. edit /etc/dhcp/dhcpd.conf:
  30. sudo nano /etc/dhcp/dhcpd.conf
  31.  
  32. default-lease-time 600;
  33. max-lease-time 7200;
  34.  
  35. option subnet-mask 255.255.255.0;
  36. option broadcast-address 192.168.182.255;
  37. option routers 192.168.182.254;
  38. option domain-name-servers 8.8.8.8, 8.8.4.4;
  39. option domain-name "yourdomainname.com";
  40.  
  41. subnet 192.168.182.0 netmask 255.255.255.0 {
  42. range 192.168.182.100 192.168.182.199;
  43. }
  44.  
  45.  
  46. CONFIGURE NAT:
  47.  
  48. enable ufw(uncomplicated firewall):
  49.  
  50. by default deny everything:
  51. sudo ufw default deny
  52.  
  53. allow SSH:
  54. sudo ufw allow ssh
  55.  
  56. turn on firewall logging:
  57. sudo ufw logging on
  58.  
  59. enable ufw(firewall):
  60. sudo ufw enable
  61.  
  62.  
  63. enable ip forwarding:
  64. edit /etc/sysctl.conf:
  65. sudo nano /etc/sysctl.conf
  66.  
  67. uncomment:
  68. net.ipv4.ip_forward=1
  69.  
  70. configure iptables to allow internet connection sharing:
  71. edit /etc/rc.local:
  72. sudo nano /etc/rc.local
  73.  
  74. add the following below before the exit 0:
  75. /sbin/iptables -P FORWARD ACCEPT
  76. /sbin/iptables --table nat -A POSTROUTING -o eth0 -j MASQUERADE
  77.  
  78.  
  79. restart ubuntu server:
  80. sudo reboot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement