Solved Static IP cannot ping default gateway

Hi all,
DHCP is working but I want to use a static IP so I can SSH in. It seems like a simple change but it has not been working for me. I've looked at a few resources but nothing has helped.

/etc/rc.conf

Code:
hostname="server.cafe308.com"
sshd_enable="YES"
dumpdev="AUTO"
wlans_iwn0="wlan0"
#ifconfig_wlan0="WPA SYNCDHCP"
ifconfig_wlan0="inet 192.168.0.11 netmask 255.255.255.0"
defaultrouter="192.168.0.1"

hald_enable="YES"
dbus_enable='YES
apache24_enable="YES"
sshd_enabl="YES"

Any help is greatly appreciated
 
Code:
wlans_iwn0="wlan0"
#ifconfig_wlan0="WPA SYNCDHCP"
ifconfig_wlan0="inet 192.168.0.11 netmask 255.255.255.0"
defaultrouter="192.168.0.1"
This doesn't enable WPA and your wireless is never associated. So your connection isn't working.
 
Could you point me in a direction where I can read about associating the wireless? With a dynamic IP I connect to a WPA protected network by default, so I think WPA is at least enabled for DHCP. Here is wpa_supplicant.conf

Code:
ctrl_interface=/var/run/wpa_supplicant
eapol_version=2
ap_scan=1
fast_reauth=1
network={
        ssid="WiFiMaterial"
        psk=my psk
}
 
Look at your two ifconfig_wlan0 lines in /etc/rc.conf. Note how one has a WPA entry while the other doesn't. WPA is needed to enable wpa_supplicant support. Add that to your second line, and everything should just work.
 
Okay that got me a little closer! I can ping my router. However I still cannot ping google or fetch ports.
rc.conf now reads
Code:
hostname="server.cafe308.com"
sshd_enable="YES"
dumpdev="AUTO"
wlans_iwn0="wlan0"
#ifconfig_wlan0="WPA SYNCDHCP"
ifconfig_wlan0="WPA inet 192.168.0.11 netmask 255.255.255.0"
defaultrouter="192.168.0.1"

hald_enable="YES"
dbus_enable='YES
apache24_enable="YES"
sshd_enabl="YES"
 
It might be a copy/paste error, but this line is missing a ' and will cause issues with the rc.conf file at boot:
Code:
dbus_enable='YES

What do you have listed in /etc/resolv.conf? When using DHCP, this file is filled automatically with your DNS servers. When you switch to static IP, you need to make sure this file still have the correct DNS servers listed. You can determine it's a DNS issue by pinging a non-local IP address (like 8.8.8.8 which is the Google DNS server). That should succeed, while pinging the hostname (google-public-dns-a.google.com) will fail:
Code:
# ping -c 2 8.8.8.8
# ping -c 2 google-public-dns-a.google.com
 
Ah yes I copied that wrong. That line is
Code:
dbus_enable="YES"

/etc/resolv.conf:

Code:
# Generated by resolvconf
nameserver 209.18.47.61
nameserver 209.18.47.62

I cannot ping 8.8.8.8 nor google.com

EDIT: To be thorough

Code:
$ ping -c 2 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: No route to host
ping: sendto: No route to host
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 0 packets received, 100.0% packet loss
 
Code:
root@server:/usr/home/user # netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
127.0.0.1          link#3             UH          0        0    lo0
192.168.0.0/24     link#4             U           1       90  wlan0
192.168.0.11       link#4             UHS         0        0    lo0

Internet6:
Destination                       Gateway                       Flags      Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               link#3                        UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%lo0/64                     link#3                        U           lo0
fe80::1%lo0                       link#3                        UHS         lo0
fe80::%wlan0/64                   link#4                        U         wlan0
fe80::213:e8ff:feea:c0e5%wlan0    link#4                        UHS         lo0
ff01::%lo0/32                     ::1                           U           lo0
ff01::%wlan0/32                   fe80::213:e8ff:feea:c0e5%wlan0 U         wlan0
ff02::/16                         ::1                           UGRS        lo0
ff02::%lo0/32                     ::1                           U           lo0
ff02::%wlan0/32                   fe80::213:e8ff:feea:c0e5%wlan0 U         wlan0
 
If you can ping the default gateway, can you ping other machines on the network?

What's the output of ifconfig?

Some routers do not allow static configuration very well, due to poor firmwares, instead you could use DHCP and then just reserve your MAC address on the router for a specific IP address.
 
Yes I can ping other machines. I can also SSH in over the network. I'll keep that option in mind. My windows machine works with a static IP, so I think the router is okay.

Code:
root@server:/usr/home/user # ifconfig
iwn0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 2290
        ether 00:13:e8:ea:c0:e5
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
        media: IEEE 802.11 Wireless Ethernet autoselect mode 11ng
        status: associated
re0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=8209b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,WOL_MAGIC,LINKSTATE>
        ether 00:1b:24:c7:16:92
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: Ethernet autoselect (none)
        status: no carrier
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
        options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
        inet6 ::1 prefixlen 128 
        inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 
        inet 127.0.0.1 netmask 0xff000000 
        nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        ether 00:13:e8:ea:c0:e5
        inet 192.168.0.11 netmask 0xffffff00 broadcast 192.168.0.255 
        inet6 fe80::213:e8ff:feea:c0e5%wlan0 prefixlen 64 scopeid 0x4 
        nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
        media: IEEE 802.11 Wireless Ethernet MCS mode 11ng
        status: associated
        ssid WiFiMaterial channel 1 (2412 MHz 11g ht/20) bssid f0:7b:cb:5f:75:21
        country US authmode WPA2/802.11i privacy ON deftxkey UNDEF
        TKIP 2:128-bit txpower 14 bmiss 10 scanvalid 60 bgscan bgscanintvl 300
        bgscanidle 250 roam:rssi 7 roam:rate 64 protmode CTS ampdulimit 64k
        ampdudensity 8 -amsdutx amsdurx shortgi wme roaming MANUAL
 
Code:
root@server:/usr/home/user # netstat -rn
Routing tables

Internet:
Destination        Gateway            Flags    Refs      Use  Netif Expire
127.0.0.1          link#3             UH          0        0    lo0
192.168.0.0/24     link#4             U           1       90  wlan0
192.168.0.11       link#4             UHS         0        0    lo0

Internet6:
Destination                       Gateway                       Flags      Netif Expire
::/96                             ::1                           UGRS        lo0
::1                               link#3                        UH          lo0
::ffff:0.0.0.0/96                 ::1                           UGRS        lo0
fe80::/10                         ::1                           UGRS        lo0
fe80::%lo0/64                     link#3                        U           lo0
fe80::1%lo0                       link#3                        UHS         lo0
fe80::%wlan0/64                   link#4                        U         wlan0
fe80::213:e8ff:feea:c0e5%wlan0    link#4                        UHS         lo0
ff01::%lo0/32                     ::1                           U           lo0
ff01::%wlan0/32                   fe80::213:e8ff:feea:c0e5%wlan0 U         wlan0
ff02::/16                         ::1                           UGRS        lo0
ff02::%lo0/32                     ::1                           U           lo0
ff02::%wlan0/32                   fe80::213:e8ff:feea:c0e5%wlan0 U         wlan0

There's no default gateway defined. So you're only able to connect to directly connected hosts.
 
Hey all,
I think I was just forgetting to restart the routing when I changed my config files... :oops:
The WPA thing was really what I needed!
Thanks for all the help, couldn't have done it without you!
 
Back
Top