Tag: network

Setup DHCP Server on Ubuntu

Sometimes you need to connect a device (Raspberry, IP Cam) directly to the PC. As these devices are mostly configured with dynamic IP, you need to setup a dhcp server.

sudo apt-get install dhcp3-server

Set to start manually if you do not want this service on your PC

sudo /etc/init.d/isc-dhcp-server stop
sudo sh -c "echo 'manual' > /etc/init/isc-dhcp-server.override"

Configure the INTERFACES setting to include eth0
Edit file: /etc/default/isc-dhcp-server , and change

INTERFACES="eth0"

Configure DHCP to assign network addresses in the range 192.168.1.100 to 192.168.1.200.
Edit File: /etc/dhcp/dhcpd.conf , add apppend.
> sudo nano /etc/dhcp/dhcpd.conf

subnet 192.168.1.0 netmask 255.255.255.0 { #network
 range 192.168.1.20 192.168.1.100; # Range
 option domain-name-servers 192.168.1.5, 8.8.8.8; #Pri DNS , Sec DNS
 option routers 192.168.1.1; #Gateway
 option broadcast-address 192.168.1.255; #Broadcast
 default-lease-time 600;
 max-lease-time 7200;
}

 

Configure Network (new Ethernet)

1. Open:

Selection_255.png

2. Add new Ethernet

Selection_253.png

3. Configure Static IP

Selection_254.png

4. Connecte in the newly created network

Start DHCP Server

# start DHCP service
sudo service isc-dhcp-server start

# enable forwarding from the ethernet to wireless router
sudo /sbin/iptables --table nat -A POSTROUTING -o wlan0 -j MASQUERADE

Testing the connection

tail /var/log/syslog

Testing the connection

Reference:
http://www.mccarroll.net/blog/rpi_netbook/index.html
http://www.krizna.com/ubuntu/setup-dhcp-server-ubuntu-14-04/
http://unix.stackexchange.com/a/42308