Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm very new to the networking side of the house and am trying to set up SSH on my new Ubuntu machine. I have my DD-WRT router working with DDNS now and can log in to the router page -- but I'm not sure how to go about forwarding it to my server machine. I realize I would forward port 22 over (or a unique port) -- but to forward, DD-WRT wants to know the IP I'm pointing at. But that IP will change, won't it? How do I make the router point to the machine rather than the current IP? Or am I asking the wrong question?

share|improve this question
1  
Is the router also the thing handing out IP addresses, or is that another thing? –  Jenny D Apr 27 at 6:47
1  
Yes, the router hands them out with DHCP. I should note, the server is currently on wifi only. Yes, I know that's not ideal for a server -- I'm working on it. –  linus72982 Apr 27 at 6:54
add comment

1 Answer 1

up vote 5 down vote accepted

As long as the DD-WRT router is also the DHCP Server for the network, you can set up a static DHCP lease for the server in DD-WRT in Services > DHCP Server under the Static leases section. This will make sure that the DHCP server always hands out the same IP address for your server when it asks for a DHCP lease.

In order to do this, you need to know the MAC address for the server. You can determine this with the command ip addr on the server by looking at the link/ether entry for the interface connected to the router (most likely wlan0 in your case).

Alternatively, you can also get the MAC address with ifconfig (run with /sbin/ifconfig as regular user on Ubuntu, /sbin is most likely not in your PATH). In that case look at the HWaddr entry for the relevant interface.

Fill in the MAC Address, hostname for the server and the desired IP address to the list of static leases in DD-WRT, Save, and Apply Settings. Note that if the IP address you set up for the static lease is not the one currently assigned to the server, you'll need to have the server give up its current lease and request a new lease from the DHCP server in order for it to get the permanent IP address.

share|improve this answer
2  
On a related note, if you forward SSH port of the server to the public Internet, you might want to consider taking certain precautions against SSH password groping bots. At least disable root logins in your sshd configuration via the PermitRootLogin no option and make sure that system users (i.e. users used to run system services) cannot login (either by assigning them the nologin shell or by whitelisting allowed users via AllowUsers in sshd_config). Forwarding SSH on a non-standard port is not enough. –  Thomas Nyman Apr 27 at 7:43
    
Perfect. That's exactly what I needed. –  linus72982 Apr 27 at 7:54
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.