Latest interface: 0.3.1
Latest system: 010
Bramus
User

6 posts

Posted on 16 January 2017 @ 14:35
Hi,

I'm having trouble setting up my static ip. I modify my /etc/rc.conf, but after restarting I'm not getting any ip and especially not the one I set as static ip in rc.conf. Can somebody see what I'm doing wrong / forgetting. Thanks in advance:


# add interfaces at your leisure when requiring static configuration
# ifconfig_DEFAULT="DHCP"
# some examples (you can override your own interface keeping DEFAULT intact)
# example1: static IP address (also set defaultrouter and also /etc/resolv.conf)
ifconfig_em0=inet 192.168.0.201 netmask 255.255.255.0
# example2: enable 'Jumbo Frames' which is MTU larger than 1536 bytes
# ifconfig_em0="DHCP mtu 7000"
# example3: force interface to gigabit full-duplex link if autodetect is borked
# ifconfig_em0="DHCP media 1000baseTX mediaopt full-duplex"

# if you want static IP, you need to specify default gateway here
defaultrouter=192.168.0.1
# don't forget to edit /etc/resolv.conf for DNS configuration as well!
# note that DHCP interfaces may override the /etc/resolv.conf

As you notice I want 192.168.0.201 as static IP.

CiPHER
Developer

1199 posts

Posted on 17 January 2017 @ 11:32
First of all you should use " " parenthesis.

ifconfig_em0=inet 192.168.0.201 netmask 255.255.255.0
should be:
ifconfig_em0="inet 192.168.0.201 netmask 255.255.255.0"

Second, you should check whether 'em0' is your network adapter. Type 'ifconfig' to see all adapters you currently have. If you see an adapter having the line "status: no carrier" that means that no cable is connected to that adapter.
CiPHER
Developer

1199 posts

Posted on 19 February 2017 @ 04:55edited 05:14 32s
For other readers:

After having configured /etc/rc.conf you also need to configure the default gateway and the DNS servers. But first, make sure that dhclient (DHCP client) is not running:



Configuring default gateway

Automatic (upon boot), modify in /etc/rc.conf:
defaultrouter="192.168.0.1"

Note: How to know this IP number? It should be the same as on your Windows/Mac computer. Somewhere in the Network adapter settings (IP address) you should also find the default gateway address, at the same place where you would see (primary/secondary) DNS servers listed.



Configuring DNS (nameserver)
Overwrite the current /etc/resolv.conf by executing:

echo "nameserver 192.168.0.1" > /etc/resolv.conf



Test
Test using: ping google.com.
Test whether IPv4 internet works: ping 8.8.4.4
Test whether Google DNS works: drill google.com @8.8.4.4

You can change your nameserver to Google (8.8.4.4) to test, but i suggest you only use this for testing, and use your ISP DNS instead for privacy reasons.
Last Page

Valid XHTML 1.1