IP Address Assigning

I'm running a server with FreeBSD and I'm trying to make it use 192.168.1.140 whenever I'm connecting to my router (WRT54GL). When I'm using DHCP, it can assign a new ip when I restart, and then I'd have to change port numbers in port forwarding. In an attempt to fix this, I changed

Code:
ifconfig_em0="DHCP"

to

Code:
ifconfig_em0="inet 192.168.1.140 netmask 255.255.255.0"
j

in /etc/rc.conf.

I setup port forwarding for ssh (on port 21330) to go to 192.168.140 on my router, however I can't login remotely anymore. When I try to ssh in it just hangs without any error output.

Here is what sockstat -4 outputs

Code:
USER     COMMAND    PID   FD PROTO  LOCAL ADDRESS         FOREIGN ADDRESS      
root     sshd       5221  3  tcp4   192.168.1.140:21330   192.168.1.108:62433
root     sshd       5177  4  tcp4   *:21337               *:*
root     smbd       2071  20 tcp4   *:445                 *:*
root     smbd       2071  21 tcp4   *:139                 *:*
root     nmbd       2065  6  udp4   *:137                 *:*
root     nmbd       2065  7  udp4   *:138                 *:*
root     nmbd       2065  8  udp4   192.168.1.140:137     *:*

The local address doesn't match the foreign address. Also I can't log into mysql remotely either. Any help would be appreciated. Thanks for reading.
 
Unless you linked the wrong page, there's no default router setting in there. If you have this:

Code:
ifconfig_em0="DHCP"

and you want to get rid of DHCP, IIRC the bare minimum you need is this:

Code:
ifconfig_em0="inet 192.168.0.2 netmask 255.255.255.0"
defaultrouter="192.168.0.1"

Because DHCP is most likely configuring your default route for you as well. Simply removing DHCP and then restarting routing as well as networking isn't going to magically tell your machine who it talks to to get outside of your network (I apologize in advance if you meant to link a different article and do actually have a default route configured). :)

You'll also likely want to make sure you have a working resolver in /etc/resolv.conf, though that might stay put after you kill DHCP, I'm not sure.

Finally, make sure your static IP is outside of the pool of your DHCP server - you don't want your DHCP server handing out that IP to some other machine and kicking your FreeBSD machine offline.
 
fwaggle said:
Finally, make sure your static IP is outside of the pool of your DHCP server - you don't want your DHCP server handing out that IP to some other machine and kicking your FreeBSD machine offline.

DHCP servers are supposed to ping an address before handing it out, so it shouldn't assign an address if there's already something there. But that can break in various ways, so using static addresses outside the DHCP range is good practice.
 
Back
Top